Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Use Menu bar and Paint Component in JApplet .

MSCSep 19 2012 — edited Sep 20 2012
Hi ,

I am trying to do very simple application with JApplet , on top I need one menu bar and below that menu , I just use paint components which I draw some line or some string or shape .

The sample code for my application is below , but if you run this code you will see the menu will be covert by paint stage unless you click on the menu bar area . I search in google , but I could not find match solution for it .

If anyone can suggest me what is the correct root for it , I will be thankful .
public class MyApplication extends JApplet {

    public void init() {
        setSize(400, 400);
         this.setBackground(new Color(0x646060));
         
        JMenuBar menubar = new JMenuBar();

        JMenu menuOption = new JMenu("Options");
        JMenuItem Camera01 = new JMenuItem("Camera 01", 1);
        menuOption.add(Camera01);
        menubar.add(menuOption);
        setJMenuBar(menubar);
    }

   public void paint(Graphics g) {
        g.setColor(Color.CYAN);
        g.drawRect(0, 0, 100, 100);
    }
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2012
Added on Sep 19 2012
4 comments
750 views