Informatiker Board (http://www.informatikerboard.de/board/index.php)
- Themengebiete (http://www.informatikerboard.de/board/board.php?boardid=1)
-- Praktische Informatik (http://www.informatikerboard.de/board/board.php?boardid=6)
--- Java GUI - meine Buttons zeigen sich nicht an (http://www.informatikerboard.de/board/thread.php?threadid=782)


Geschrieben von Dummiinmathe am 04.11.2010 um 09:37:

  Java GUI - meine Buttons zeigen sich nicht an

Meine Frage:
ich muss in Java ein programm schreiben das auch eine GUI hat..
ich wollte zu meinem hauptfenster ein hintergrundbild haben.. das hintergrundbild wird angezeigt aber wenn ich mein ButtonPanel in die mitte setze wird es nicht angezeigt??


Meine Ideen:
ich verkuerz mein Code jetzt..da er richtig lang is und kopier nur die teile die relevant sind.

public MyJFrame(){

super("LizRace");

initComponents();
this.setContentPane(contentPanel);

this.setVisible(true);
}

public void initComponents(){

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setSize(FIELD_WIDTH, FIELD_HEIGHT);
contentPanel = new JPanel();
buttonPanel = new JPanel();
buttonPanel.add(startGame); ... //jetz werden weitere Buttons addiert

contentPanel.setLayout(new BorderLayout());

/// das addieren des HIntergrundbildes

ImageIcon icon = new ImageIcon("C:\\Documents and Settings\\workspace\\LizRace\\src\\Images\\lizracelogo.jpg");
JLabel label = new JLabel();
label.setIcon(icon);
contentPanel.add(label);


contentPanel.add(buttonPanel, BorderLayout.CENTER);


Forensoftware: Burning Board, entwickelt von WoltLab GmbH