Hallo zusammen,
Bin relativ neu in der Java Szene ca. 1 Woche und wollte eine GUI programmieren (Um genuaer zu sein einen Taschenrechner). Aber irgendwie komm ich beim Design schon durcheinander ich hoffe ihr könnt mir helfen 🙂
Ich habe das layout mit setlayout auf null gesetzt. Jedoch passiert nun rein garnichts wenn ich das Programm starte.. Hilfe!
Bin relativ neu in der Java Szene ca. 1 Woche und wollte eine GUI programmieren (Um genuaer zu sein einen Taschenrechner). Aber irgendwie komm ich beim Design schon durcheinander ich hoffe ihr könnt mir helfen 🙂
Code:
super("Rechner");
Container c = getContentPane();
setSize(250,240);
setLocation(300,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(true);
panel = new JPanel();
panel1 = new JPanel();
c.add(panel);
c.add(panel1);
c.setLayout(null);
ta = new JTextArea();
ta.setBounds(0,0,220,50);
ta.setEditable(false);
button1 = new JButton ("1");
button1.setBounds(10,10,40,25);
button1.setFont(new Font("Arial", 10, 10));
button2 = new JButton ("2");
button2.setBounds(10,10,40,25);
button2.setFont(new Font("Arial", 10, 10));
button3 = new JButton ("3");
button3.setBounds(10,10,40,25);
button3.setFont(new Font("Arial",10, 10));
button4 = new JButton ("4");
button4.setBounds(10,10,40,25);
button4.setFont(new Font("Arial", 10, 10));
button5 = new JButton ("5");
button5.setBounds(10,10,40,25);
button5.setFont(new Font("Arial", 10, 10));
button6 = new JButton ("6");
button6.setBounds(10,10,40,25);
button6.setFont(new Font("Arial", 10, 10));
button7 = new JButton ("7");
button7.setBounds(10,10,40,25);
button7.setFont(new Font("Arial", 10, 10));
button8 = new JButton ("8");
button8.setBounds(10,10,40,25);
button8.setFont(new Font("Arial", 10, 10));
button9 = new JButton ("9");
button9.setBounds(10,10,40,25);
button9.setFont(new Font("Arial", 10, 10));
button10 = new JButton ("+");
button10.setBounds(10,10,40,25);
button10.setFont(new Font("Arial", 10, 10));
button11 = new JButton ("-");
button11.setBounds(10,10,40,25);
button11.setFont(new Font("Arial", 10, 10));
button12 = new JButton ("x");
button12.setBounds(10,10,40,25);
button12.setFont(new Font("Arial", 10, 10));
button13 = new JButton ("=");
button13.setBounds(10,10,40,100);
button13.setFont(new Font("Arial", 10, 10));
panel1.add(ta);
panel.add(button1);
panel.add(button2);
panel.add(button3);
panel.add(button10);
panel.add(button13);
panel.add(button4);
panel.add(button5);
panel.add(button6);
panel.add(button11);
panel.add(button7);
panel.add(button8);
panel.add(button9);
panel.add(button12);
setVisible(true);
Ich habe das layout mit setlayout auf null gesetzt. Jedoch passiert nun rein garnichts wenn ich das Programm starte.. Hilfe!
Zuletzt bearbeitet: