Hallo liebe Community,
leider funktioniert meine GUI nicht so, wie ich es gerne hätte. Der Titel, sowie der Startbutton werden nicht angezeigt, wenn ich den Startbutton entferne, wird Titel wieder angezeigt.
Hoffe auf eure Hilfe
leider funktioniert meine GUI nicht so, wie ich es gerne hätte. Der Titel, sowie der Startbutton werden nicht angezeigt, wenn ich den Startbutton entferne, wird Titel wieder angezeigt.
Hoffe auf eure Hilfe
Code:
package test;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Game2 {
JFrame window;
Container con;
JPanel titleNamePanel;
JPanel startButtonPanel;
JLabel title;
Font titlefont = new Font("Times New Roman", Font.PLAIN, 90);
Font normalfont = new Font("Times New Roman", Font.PLAIN, 40);
JButton startButton;
public static void main(String[] args) {
new Game2();
}
public Game2(){
window = new JFrame();
window.setSize(800, 600);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.getContentPane().setBackground(Color.black);
window.setLayout(null);
window.setVisible(true);
con = window.getContentPane();
titleNamePanel = new JPanel();
titleNamePanel.setBounds(100, 100, 600, 150);
titleNamePanel.setBackground(Color.black);
title = new JLabel("ADVENTURE");
title.setForeground(Color.white);
title.setFont(titlefont);
startButtonPanel = new JPanel();
startButtonPanel.setBounds(300, 400, 200, 100);
startButtonPanel.setBackground(Color.black);
startButton = new JButton("START");
startButton.setBackground(Color.black);
startButton.setForeground(Color.white);
startButton.setFont(normalfont);
titleNamePanel.add(title);
startButtonPanel.add(startButton);
con.add(titleNamePanel);
con.add(startButtonPanel);
}
}