Hiho!
Frage: Wie kann ich denn von einem in Swing programmierten JFrame die Größe ändern?? Also ich hab schon irgendwie mit setSize(int a,int b) gearbeitet... aber bekomms einfach net so hin, dass es funzt...
Wie muss man denn die Methode richtig implementieren?
meine Klasse heisst wie folgt:
Alles anzeigen
Ich bin echt ratlos... hab schon allen möglichen scheiss probiert, aber ich komm einfach net drauf. =) Danke schonmal für Hilfe!
Frage: Wie kann ich denn von einem in Swing programmierten JFrame die Größe ändern?? Also ich hab schon irgendwie mit setSize(int a,int b) gearbeitet... aber bekomms einfach net so hin, dass es funzt...
Wie muss man denn die Methode richtig implementieren?
meine Klasse heisst wie folgt:
Quellcode
- JFrame ButtonBox = new JFrame("ButtonBox");
- JPanel Hintergrund = new JPanel(new GridLayout(3,1));
- JButton Gelb, Rot, Blau;
- public void Buttons(){
- Gelb = new JButton("faerbe Buttons gelb");
- Gelb.setBackground(Color.yellow);
- Gelb.addActionListener(this);
- Rot = new JButton("faerbe Buttons rot");
- Rot.setBackground(Color.yellow);
- Rot.addActionListener(this);
- Blau = new JButton("faerbe Buttons blau");
- Blau.setBackground(Color.yellow);
- Blau.addActionListener(this);
- Hintergrund.add(Gelb);
- Hintergrund.add(Rot);
- Hintergrund.add(Blau);
- ButtonBox.getContentPane().add(Hintergrund);
- ButtonBox.pack();
- ButtonBox.setVisible(true);
- }
- public static void main(String[] args) {
- ButtonBox MeinSwing = new ButtonBox();
- MeinSwing.Buttons();
- }
- public void actionPerformed(ActionEvent e){
- Object button = e.getSource();
- if (button == Gelb) {
- this.Gelb.setBackground(Color.yellow);
- this.Rot.setBackground(Color.yellow);
- this.Blau.setBackground(Color.yellow);
- this.Hintergrund.setBackground(Color.yellow);
- }
- if (button == Rot) {
- this.Gelb.setBackground(Color.red);
- this.Rot.setBackground(Color.red);
- this.Blau.setBackground(Color.red);
- this.Hintergrund.setBackground(Color.red);
- }
- if (button == Blau) {
- this.Gelb.setBackground(Color.blue);
- this.Rot.setBackground(Color.blue);
- this.Blau.setBackground(Color.blue);
- this.Hintergrund.setBackground(Color.blue);
- }
- }
- }
Ich bin echt ratlos... hab schon allen möglichen scheiss probiert, aber ich komm einfach net drauf. =) Danke schonmal für Hilfe!
\\.-'´´ Alw4ys k33p on burn!ng, 'cAu$e if you are buRnT out y0ur l!fe sURreNd3Rs deAth! ``'-.//