How do i call a method string(printBestillingsordre) into another method and create a JPanel to it
public String printBestillingsordre(){
JButton button = new JButton("Varemodtaget");
String temp = "";
for(HentbestillingsordreRegistrer hentboregistrer: hbor){
if(status == "Leveret"){
temp += "Bestillings Status: " + hentboregistrer.BestillingsStatus+" \n" +
"LeverandoerID: "+ hentboregistrer.LeverandoerID+" \n";
}else{
temp += hentboregistrer.BestillingsStatus+ button + "\n" +
"LeverandoerID: "+ hentboregistrer.LeverandoerID+" \n";
}
System.out.println(temp);
}
return temp;
}
into this code
public JPanel HentOrdreGUI(){
JPanel info = new JPanel();
info.setLayout(new BorderLayout());
info.add(printBestillingsordre());
return null;
}
btw this code is long from done
Assuming you want to add visual text from "printBestillingsordre()" to a Panel, the easiest way is to change the line:
info.add(printBestillingsordre());
to
info.add(new JLabel(printBestillingsordre());
That will create a visual representative of your string. To organise your GUI components I would recommend looking at the following link:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.