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();

}

}

[2378 byte] By [cw410005a] at [2007-10-3 4:23:11]
# 1

Lots of stuff wrong here.

1) Never mix Swing and AWT. Never. But it doesn't matter, you seem to extend Canvas just for the laughs

2) Painting just once isn't that helpful in the long run.

3) I don't see you displaying anything.

4) - not even a menu. Where is the menu that gives you problems?

CeciNEstPasUnProgrammeura at 2007-7-14 22:25:30 > top of Java-index,Java Essentials,New To Java...
# 2
I can't see where you're creating the JMenu, but you need to create a JMenuBar and add JMenus to it, and add JMenuItems to the JMenus. Then call frame.setJMenuBar(menuBar), don't add it the same way you add JPanels and other components.
BinaryDigita at 2007-7-14 22:25:30 > top of Java-index,Java Essentials,New To Java...