JPanel & JMenu
Hi Im new to this Java business and just wanted a bit of help if I can.
I am trying to get a JMenu and a JPanel showing on the screen at the same time. The Jpanel is displaying all my graphics and I want the JMenu for options.
The problem is when I am trying to add the JMenu it doesnt show just the JPanel
Here is the list for my JPanel, How can I add the Menu so it will show up with my graphics?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.*;
class Game1extends Canvas{
BufferStrategy strategy;
Game1(){
JFrame frame=new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel=(JPanel)frame.getContentPane();
setBounds(0,0,1024, 704);
panel.setPreferredSize(new Dimension(1024,704));
panel.setLayout(null);
panel.add(this);
frame.setBounds(0,0,1024, 704);
frame.setVisible(true);
requestFocus();
createBufferStrategy(2);
strategy = getBufferStrategy();
}
publicstaticvoid main(String args[]){
JFrame.setDefaultLookAndFeelDecorated(true);
Game1 game=new Game1();
game.init();
}
publicvoid init(){
paintTextBox();
}
publicvoid paintTextBox(){
Graphics g = strategy.getDrawGraphics();
g.drawString("HELLO",20,20);
strategy.show();
}
}

