MyFrame(){
String titel = "Rezept";
JLabel label = new JLabel(titel);
JButton abutton = new JButton("Abbrechen");
JButton sbutton = new JButton("Speichern");
JPanel jp1 = new JPanel();
jp1.setLayout(new FlowLayout(FlowLayout.CENTER));
jp1.add(label);
JPanel jp2 = new JPanel();
jp2.setLayout(new GridLayout(1,2));
jp2.add(abutton);
jp2.add(sbutton);
setLayout(new BorderLayout());
setSize(300,500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
add(jp1, BorderLayout.NORTH);
add(jp2, BorderLayout.SOUTH);
}
public static void main(String[]args){
new MyFrame();
}
I just don't get it. When I run this GUI it doesn't print out anything at all.
I only get an empty frame. What am I doing wrong here?
(Code is in "MyFrame extends JFrame" class)
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.