Does anyone of you have an idea why my JMenuBar menuBar isn't showing up?
I'm using a JFrame and a JPanel.
My class extends JPanel and has a paint method inherited (already with super.paint(g)).
I want to display some JLabels and JTextFields on my JMenuBar (I know that's not the purpose of it)
Here's my code:
public void createMenuBar(){
menuBar = new JMenuBar();
menuBar.setBounds(0,0,1463,29);
menuBar.setLayout(null);
this.add(menuBar);
ipLbl = new JLabel("IP-Adresse:");
ipLbl.setBounds(5,2,150,25);
ipLbl.setLabelFor(ip);
menuBar.add(ipLbl);
ip = new JTextField();
ip.setBounds(150,2,100,25);
menuBar.add(ip);
}
I'm calling this method after creating the JFrame, but right before doing setVisible(true).
Look:
public IceHockey(){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e){}
fenster = new JFrame("IceHockey");
fenster.setSize(1479, 941);
fenster.setLayout(null);
fenster.addKeyListener(this);
fenster.addMouseListener(this);
fenster.setResizable(false);
fenster.setLocationRelativeTo(null);
fenster.setContentPane(this);
this.addKeyListener(this);
this.addMouseListener(this);
createMenuBar();
fenster.setVisible(true);
fenster.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}