Invisible JMenuBar in JFrame

I have two JFrames. The first is the main one, and has a JMenu that works just fine. I tried to add a menu to the other frame today, but no menu appeared. I thought that the menu may be invisible, so I tried setVisible(true) but that was no good. Then I experimented by clicking where the menu should have appeared, and the menu suddenly appeared! I'm able to click on items and they work as expected, except that the painting goes wrong: when the menu bar disappears, it doesn't update the background that was behind it.
I'm puzzled about the invisible menu and the painting problem, especially since I'm using the same code to make the menus (but I still have different variables for the menus).
I thought it'd be easy to just add a menu to the other JFrame, but I was wrong. Any help would be greatly appreciated.

Hi Michael,
sorry that I wasn't specific enough with the message. I only just discovered that my program was at fault. The menu bar wasn't initially invisible, but seemed that way because my code painted over it. (The JFrame was used for animating, and I was blasting an image over the whole frame, wiping out the menu in the process).
Andrew.

Similar Messages

  • Changing a JMenuBar after JFrame is visible

    Hi,
    I'm trying to get my UI in a JFrame(for curiosity), to totally change menubars when a sliding bar encounters a particular range. The menubar is just a simple JMenuBar with JMenus created and given random text labels. The catch seems to be that even though the new MenuBar is added to the JFrame via setJMenuBar, the new menu doesn't appear on the window until it is resized(suggesting that repaint isn't called)... I tried calling repaint on the frame and also on the MenuBar directly, but it doesn't seem to do anything... any advice? thx

    try "updateUI();" on it instead, that should fix it.

  • How to get the JMenuBar associated with a JMenuItem?

    How do I get the JMenuBar (or JFrame) associated with
    a JMenuItem?
    The JMenuItem is in a subMenu of a JMenu on the JMenuBar.

    Hi,
    JMenuBar is extending from the container class,
    When a menuItem is added to it,You can get the instance of JMenuBar by type casting the getParent method on JMenuItem
    ie..
    JMenuItem mi1 = new JMenuItem();
    JMenuBar jm = new JMenuBar();
    jm.add(mi1);
    JMenuBar jm2 = (JMenuBar) mi1.getParent();
    Hope this helps
    cheers
    Ravi

  • Printing JFrame

    HI i am tryin to print the second class which is pasted below .. The printer dialog comes up but the page does not print .. it just comes out blank .. can any one please help :S
    //this class is used to open the class below ..
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class RunView extends JFrame implements ActionListener
    private ButtonGroup cbg;
    private JRadioButton radio80;
    private JRadioButton radio79;
    private JRadioButton radio78;
    private JRadioButton radio77;
    private JRadioButton radio76;
    private JRadioButton radio75;
    private JRadioButton radio74;
    private JRadioButton radio73;
    private JRadioButton radio72;
    private JRadioButton radio71;
    private JRadioButton radio70;
    private JRadioButton radio69;
    private JRadioButton radio68;
    private JRadioButton radio67;
    private JRadioButton radio66;
    private JRadioButton radio65;
    private JRadioButton radio64;
    private JRadioButton radio63;
    private JRadioButton radio62;
    private JRadioButton radio61;
    private JRadioButton radio60;
    private JRadioButton radio59;
    private JRadioButton radio58;
    private JRadioButton radio57;
    private JRadioButton radio56;
    private JRadioButton radio55;
    private JRadioButton radio54;
    private JRadioButton radio53;
    private JRadioButton radio52;
    private JRadioButton radio51;
    private JRadioButton radio50;
    private JRadioButton radio49;
    private JRadioButton radio48;
    private JRadioButton radio47;
    private JRadioButton radio46;
    private JRadioButton radio45;
    private JRadioButton radio44;
    private JRadioButton radio43;
    private JRadioButton radio42;
    private JRadioButton radio41;
    private JRadioButton radio40;
    private JRadioButton radio39;
    private JRadioButton radio38;
    private JRadioButton radio37;
    private JRadioButton radio36;
    private JRadioButton radio35;
    private JRadioButton radio34;
    private JRadioButton radio33;
    private JRadioButton radio32;
    private JRadioButton radio31;
    private JRadioButton radio30;
    private JRadioButton radio29;
    private JRadioButton radio28;
    private JRadioButton radio27;
    private JRadioButton radio26;
    private JRadioButton radio25;
    private JRadioButton radio24;
    private JRadioButton radio23;
    private JRadioButton radio22;
    private JRadioButton radio21;
    private JRadioButton radio20;
    private JRadioButton radio19;
    private JRadioButton radio18;
    private JRadioButton radio17;
    private JRadioButton radio16;
    private JRadioButton radio15;
    private JRadioButton radio14;
    private JRadioButton radio13;
    private JRadioButton radio12;
    private JRadioButton radio11;
    private JRadioButton radio10;
    private JRadioButton radio9;
    private JRadioButton radio8;
    private JRadioButton radio7;
    private JRadioButton radio6;
    private JRadioButton radio5;
    private JRadioButton radio4;
    private JRadioButton radio3;
    private JRadioButton radio2;
    private JRadioButton radio1;
    private JLabel infoLabel1;
    private JLabel infoLabel2;
    private JButton submitButton;
    private JButton exitButton;
    static String exDescription="";
    static String exCode="";
    public RunView() {
         super("Running Exercise List");
              try{
              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              }catch(Exception e){
                   //e.printStackTrace();
    RunViewLayout customLayout = new RunViewLayout();
    getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
    getContentPane().setLayout(customLayout);
    cbg = new ButtonGroup();
    radio80 = new JRadioButton("rg080", false);
    cbg.add(radio80);
    getContentPane().add(radio80);
    radio80.addActionListener(this);
    radio79 = new JRadioButton("rg079", false);
    cbg.add(radio79);
    getContentPane().add(radio79);
              radio79.addActionListener(this);
    radio78 = new JRadioButton("rg078", false);
    cbg.add(radio78);
    getContentPane().add(radio78);
    radio78.addActionListener(this);
    radio77 = new JRadioButton("rg077", false);
    cbg.add(radio77);
    getContentPane().add(radio77);
    radio77.addActionListener(this);
    radio76 = new JRadioButton("rg076", false);
    cbg.add(radio76);
    getContentPane().add(radio76);
    radio76.addActionListener(this);
    radio75 = new JRadioButton("rg075", false);
    cbg.add(radio75);
    getContentPane().add(radio75);
    radio75.addActionListener(this);
    radio74 = new JRadioButton("rg074", false);
    cbg.add(radio74);
    getContentPane().add(radio74);
    radio74.addActionListener(this);
    radio73 = new JRadioButton("rg073", false);
    cbg.add(radio73);
    getContentPane().add(radio73);
    radio73.addActionListener(this);
    radio72 = new JRadioButton("rg072", false);
    cbg.add(radio72);
    getContentPane().add(radio72);
    radio72.addActionListener(this);
    radio71 = new JRadioButton("rg071", false);
    cbg.add(radio71);
    getContentPane().add(radio71);
    radio71.addActionListener(this);
    radio70 = new JRadioButton("rg070", false);
    cbg.add(radio70);
    getContentPane().add(radio70);
    radio70.addActionListener(this);
    radio69 = new JRadioButton("rg069", false);
    cbg.add(radio69);
    getContentPane().add(radio69);
    radio69.addActionListener(this);
    radio68 = new JRadioButton("rg068", false);
    cbg.add(radio68);
    getContentPane().add(radio68);
    radio68.addActionListener(this);
    radio67 = new JRadioButton("rg067", false);
    cbg.add(radio67);
    getContentPane().add(radio67);
    radio67.addActionListener(this);
    radio66 = new JRadioButton("rg066", false);
    cbg.add(radio66);
    getContentPane().add(radio66);
    radio66.addActionListener(this);
    radio65 = new JRadioButton("rg065", false);
    cbg.add(radio65);
    getContentPane().add(radio65);
    radio65.addActionListener(this);
    radio64 = new JRadioButton("rg064", false);
    cbg.add(radio64);
    getContentPane().add(radio64);
    radio64.addActionListener(this);
    radio63 = new JRadioButton("rg063", false);
    cbg.add(radio63);
    getContentPane().add(radio63);
    radio63.addActionListener(this);
    radio62 = new JRadioButton("rg062", false);
    cbg.add(radio62);
    getContentPane().add(radio62);
    radio62.addActionListener(this);
    radio61 = new JRadioButton("rg061", false);
    cbg.add(radio61);
    getContentPane().add(radio61);
    radio61.addActionListener(this);
    radio60 = new JRadioButton("rg060", false);
    cbg.add(radio60);
    getContentPane().add(radio60);
    radio60.addActionListener(this);
    radio59 = new JRadioButton("rg059", false);
    cbg.add(radio59);
    getContentPane().add(radio59);
    radio59.addActionListener(this);
    radio58 = new JRadioButton("rg058", false);
    cbg.add(radio58);
    getContentPane().add(radio58);
    radio58.addActionListener(this);
    radio57 = new JRadioButton("rg057", false);
    cbg.add(radio57);
    getContentPane().add(radio57);
    radio57.addActionListener(this);
    radio56 = new JRadioButton("rg056", false);
    cbg.add(radio56);
    getContentPane().add(radio56);
    radio56.addActionListener(this);
    radio55 = new JRadioButton("rg055", false);
    cbg.add(radio55);
    getContentPane().add(radio55);
    radio55.addActionListener(this);
    radio54 = new JRadioButton("rg054", false);
    cbg.add(radio54);
    getContentPane().add(radio54);
    radio54.addActionListener(this);
    radio53 = new JRadioButton("rg053", false);
    cbg.add(radio53);
    getContentPane().add(radio53);
    radio53.addActionListener(this);
    radio52 = new JRadioButton("rg052", false);
    cbg.add(radio52);
    getContentPane().add(radio52);
    radio52.addActionListener(this);
    radio51 = new JRadioButton("rg051", false);
    cbg.add(radio51);
    getContentPane().add(radio51);
    radio51.addActionListener(this);
    radio50 = new JRadioButton("rg050", false);
    cbg.add(radio50);
    getContentPane().add(radio50);
    radio50.addActionListener(this);
    radio49 = new JRadioButton("rg049", false);
    cbg.add(radio49);
    getContentPane().add(radio49);
    radio49.addActionListener(this);
    radio48 = new JRadioButton("rg048", false);
    cbg.add(radio48);
    getContentPane().add(radio48);
    radio48.addActionListener(this);
    radio47 = new JRadioButton("rg047", false);
    cbg.add(radio47);
    getContentPane().add(radio47);
    radio47.addActionListener(this);
    radio46 = new JRadioButton("rg046", false);
    cbg.add(radio46);
    getContentPane().add(radio46);
    radio46.addActionListener(this);
    radio45 = new JRadioButton("rg045", false);
    cbg.add(radio45);
    getContentPane().add(radio45);
    radio45.addActionListener(this);
    radio44 = new JRadioButton("rg044", false);
    cbg.add(radio44);
    getContentPane().add(radio44);
    radio44.addActionListener(this);
    radio43 = new JRadioButton("rg043", false);
    cbg.add(radio43);
    getContentPane().add(radio43);
    radio43.addActionListener(this);
    radio42 = new JRadioButton("rg042", false);
    cbg.add(radio42);
    getContentPane().add(radio42);
    radio42.addActionListener(this);
    radio41 = new JRadioButton("rg041", false);
    cbg.add(radio41);
    getContentPane().add(radio41);
    radio41.addActionListener(this);
    radio40 = new JRadioButton("rg040", false);
    cbg.add(radio40);
    getContentPane().add(radio40);
    radio40.addActionListener(this);
    radio39 = new JRadioButton("rg039", false);
    cbg.add(radio39);
    getContentPane().add(radio39);
    radio39.addActionListener(this);
    radio38 = new JRadioButton("rg038", false);
    cbg.add(radio38);
    getContentPane().add(radio38);
    radio38.addActionListener(this);
    radio37 = new JRadioButton("rg037", false);
    cbg.add(radio37);
    getContentPane().add(radio37);
    radio37.addActionListener(this);
    radio36 = new JRadioButton("rg036", false);
    cbg.add(radio36);
    getContentPane().add(radio36);
    radio36.addActionListener(this);
    radio35 = new JRadioButton("rg035", false);
    cbg.add(radio35);
    getContentPane().add(radio35);
    radio35.addActionListener(this);
    radio34 = new JRadioButton("rg034", false);
    cbg.add(radio34);
    getContentPane().add(radio34);
    radio34.addActionListener(this);
    radio33 = new JRadioButton("rg033", false);
    cbg.add(radio33);
    getContentPane().add(radio33);
    radio33.addActionListener(this);
    radio32 = new JRadioButton("rg032", false);
    cbg.add(radio32);
    getContentPane().add(radio32);
    radio32.addActionListener(this);
    radio31 = new JRadioButton("rg031", false);
    cbg.add(radio31);
    getContentPane().add(radio31);
    radio31.addActionListener(this);
    radio30 = new JRadioButton("rg030", false);
    cbg.add(radio30);
    getContentPane().add(radio30);
    radio30.addActionListener(this);
    radio29 = new JRadioButton("rg029", false);
    cbg.add(radio29);
    getContentPane().add(radio29);
    radio29.addActionListener(this);
    radio28 = new JRadioButton("rg028", false);
    cbg.add(radio28);
    getContentPane().add(radio28);
    radio28.addActionListener(this);
    radio27 = new JRadioButton("rg027", false);
    cbg.add(radio27);
    getContentPane().add(radio27);
    radio27.addActionListener(this);
    radio26 = new JRadioButton("rg026", false);
    cbg.add(radio26);
    getContentPane().add(radio26);
    radio26.addActionListener(this);
    radio25 = new JRadioButton("rg025", false);
    cbg.add(radio25);
    getContentPane().add(radio25);
    radio25.addActionListener(this);
    radio24 = new JRadioButton("rg024", false);
    cbg.add(radio24);
    getContentPane().add(radio24);
    radio24.addActionListener(this);
    radio23 = new JRadioButton("rg023", false);
    cbg.add(radio23);
    getContentPane().add(radio23);
    radio23.addActionListener(this);
    radio22 = new JRadioButton("rg022", false);
    cbg.add(radio22);
    getContentPane().add(radio22);
    radio22.addActionListener(this);
    radio21 = new JRadioButton("rg021", false);
    cbg.add(radio21);
    getContentPane().add(radio21);
    radio21.addActionListener(this);
    radio20 = new JRadioButton("rg020", false);
    cbg.add(radio20);
    getContentPane().add(radio20);
    radio20.addActionListener(this);
    radio19 = new JRadioButton("rg019", false);
    cbg.add(radio19);
    getContentPane().add(radio19);
    radio19.addActionListener(this);
    radio18 = new JRadioButton("rg018", false);
    cbg.add(radio18);
    getContentPane().add(radio18);
    radio18.addActionListener(this);
    radio17 = new JRadioButton("rg017", false);
    cbg.add(radio17);
    getContentPane().add(radio17);
    radio17.addActionListener(this);
    radio16 = new JRadioButton("rg016", false);
    cbg.add(radio16);
    getContentPane().add(radio16);
    radio16.addActionListener(this);
    radio15 = new JRadioButton("rg015", false);
    cbg.add(radio15);
    getContentPane().add(radio15);
    radio15.addActionListener(this);
    radio14 = new JRadioButton("rg014", false);
    cbg.add(radio14);
    getContentPane().add(radio14);
    radio14.addActionListener(this);
    radio13 = new JRadioButton("rg013", false);
    cbg.add(radio13);
    getContentPane().add(radio13);
    radio13.addActionListener(this);
    radio12 = new JRadioButton("rg012", false);
    cbg.add(radio12);
    getContentPane().add(radio12);
              radio12.addActionListener(this);
    radio11 = new JRadioButton("rg011", false);
    cbg.add(radio11);
    getContentPane().add(radio11);
              radio11.addActionListener(this);
    radio10 = new JRadioButton("rg010", false);
    cbg.add(radio10);
    getContentPane().add(radio10);
    radio10.addActionListener(this);
    radio9 = new JRadioButton("rg009", false);
    cbg.add(radio9);
    getContentPane().add(radio9);
    radio9.addActionListener(this);
    radio8 = new JRadioButton("rg008", false);
    cbg.add(radio8);
    getContentPane().add(radio8);
    radio8.addActionListener(this);
    radio7 = new JRadioButton("rg007", false);
    cbg.add(radio7);
    getContentPane().add(radio7);
    radio7.addActionListener(this);
    radio6 = new JRadioButton("rg006", false);
    cbg.add(radio6);
    getContentPane().add(radio6);
    radio6.addActionListener(this);
    radio5 = new JRadioButton("rg005", false);
    cbg.add(radio5);
    getContentPane().add(radio5);
    radio5.addActionListener(this);
    radio4 = new JRadioButton("rg004", false);
    cbg.add(radio4);
    getContentPane().add(radio4);
    radio4.addActionListener(this);
    radio3 = new JRadioButton("rg003", false);
    cbg.add(radio3);
    getContentPane().add(radio3);
    radio3.addActionListener(this);
    radio2 = new JRadioButton("rg002", false);
    cbg.add(radio2);
    getContentPane().add(radio2);
    radio2.addActionListener(this);
    radio1 = new JRadioButton("rg001", false);
    cbg.add(radio1);
    getContentPane().add(radio1);
    radio1.addActionListener(this);
    infoLabel1 = new JLabel("Please select from the below excercise codes the exercises that have been generated for");
    getContentPane().add(infoLabel1);
    infoLabel2 = new JLabel("you and shown in the table, then press submit to view detailed info about each one. ");
    getContentPane().add(infoLabel2);
    submitButton = new JButton("Submit");
    getContentPane().add(submitButton);
    submitButton.setToolTipText("Press to view detail about selected exercise");
    submitButton.setBackground(Color.white);
    submitButton.addActionListener(this);
    exitButton = new JButton("Exit");
    getContentPane().add(exitButton);
    exitButton.setBackground(Color.white);
    exitButton.setToolTipText("Press to go back to additional features menu");
    exitButton.addActionListener(this);
    setSize(getPreferredSize());
    setSize(600,680);
    show();
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    public static void main(String args[]) {
    new RunView();
    // window.setTitle("RunView");
    // window.pack();
    // window.show();
              public void actionPerformed(ActionEvent e)
                   Object s = e.getSource();
                   if(s instanceof JRadioButton)
                        if(s == radio1)
                             exDescription="This Exercise is a continuous short distance exercise which is at a brisk \n"
                                            +"pace however the length is quite short, it is really designed to build up \n"
                                            +"ones endurance, and should be done outdoors ideally. \n"
                                            +"\nThe exercise itself is a fitness building exercise and the main muscle \n"
                                            +"area targetted is the legs,and obviously should help increase stamina and \n"
                                            +"build muscle in the lower region of your body.\n"
                                            +"\nYou should aim to perform this exercise on a daily basis if you are to \n"
                                            +"recieve the results you want. The pace as stated is brisk you should aim \n"
                                            +"to cover from 1000-1500m approx as the duration of the run is 5mins long,\n"
                                            +"and try to set yourslef a target to improve and increase the distance on \n"
                                            +"each run, try to hold form throughout the run, by running at a steady pace \n"
                                            +"one which is not irratic or irregular.\n"
                                            +"\nplease ensure you worm up properly by doin all the nececary stretches \n"
                                            +"in legs and calves mainly. Ideally you should normally aim to carry out \n"
                                            +"this run for a minimum 3 week period before returning and performing the \n"
                                            +"exercise review";
                             exCode="rg001";
                        if(s == radio2)
                             exDescription="This Exercise is a continuous short distance exercise which is at a brisk \n"
                                            +"pace however the length is short, it is really designed to build up \n"
                                            +"ones endurance and stamina levels, and should be done outdoors ideally. \n"
                                            +"\nThe exercise itself is a fitness enhancing exercise and the main muscle \n"
                                            +"area targetted are in the legs, and obviously should help build muscle in \n"
                                            +"the lower region of your body. \n"
                                            +"\nYou should aim to perform this exercise on a daily basis if you are to \n"
                                            +"recieve the results you want. The pace as stated is brisk you should aim \n"
                                            +"to cover from 1500-2000m approx as the duration of the run is 10mins long, \n"
                                            +"and try to set yourself a target to improve and increase the distance on \n"
                                            +"each run while the time should remain the same, try to hold form throughout \n"
                                            +"the run, by running at a steady pace one which is not irratic or irregular.\n"
                                            +"\nplease ensure you worm up properly by doin all the nececary stretches in\n"
                                            +"should normally aim to carry out this run for a minimum 3 week period \n"
                                            +"legs and calves mainly. Ideally You before returning and performing the\n"
                                            +"exercise review";
                             exCode="rg002";
                        if(s == radio3)
                             exDescription="This Exercise is a continuous short distance exercise which is at a brisk \n"
                                            +"pace however the length is short, it is really designed to build up \n"
                                            +"ones endurance and stamina levels, and should be done outdoors ideally. \n"
                                            +"\nThe exercise itself is a fitness enhancing exercise and the main muscle \n"
                                            +"area targetted are focused on the lower region of your body as a whole \n"
                                            +"because the aim is to strengthen your legs for higher endurance \n"
                                            +"\nYou should aim to perform this exercise on a daily basis if you are to \n"
                                            +"recieve the results you want. The pace as stated is brisk you should aim \n"
                                            +"to cover from 1700-2200m approx as the duration of the run is 12mins long, \n"
                                            +"and try to set yourself a target to improve and increase the distance on \n"
                                            +"each run while the time should remain the same, try to hold form throughout \n"
                                            +"the run, by running at a steady pace one which is not irratic or irregular.\n"
                                            +"\nplease ensure you worm up properly by doin all the nececary stretches in\n"
                                            +"legs and calves mainly. Ideally You should normally aim to carry out this \n"
                                            +"run for a minimum 3 week period before returning and performing the\n"
                                            +"exercise review";
                             exCode="rg003";
                        if(s ==radio4)
                             exDescription="This Exercise is a continuous short distance exercise which is at a brisk \n"
                                            +"pace however the length is short, it is really designed to build up \n"
                                            +"ones endurance and stamina levels, and should be done outdoors ideally. \n"
                                            +"\nThe exercise itself is a fitness enhancing exercise and the main muscle \n"
                                            +"area targetted are focused on the lower region of your body as a whole \n"
                                            +"because the aim is to strengthen your legs for higher endurance \n"
                                            +"\nYou should aim to perform this exercise on a daily basis if you are to \n"
                                            +"recieve the results you want. The pace as stated is brisk you should aim \n"
                                            +"to cover from 1700-2200m approx as the duration of the run is 15mins long, \n"
                                            +"and try to set yourself a target to improve and increase the distance on \n"
                                            +"each run while the time should remain the same, try to hold form throughout \n"
                                            +"the run, by running at a steady pace one which is not irratic or irregular.\n"
                                            +"\nplease ensure you worm up properly by doin all the nececary stretches in\n"
                                            +"legs and calves mainly. Ideally You should normally aim to carry out this \n"
                                            +"run for a minimum 3 week period before returning and performing the\n"
                                            +"exercise review";
                             exCode="rg004";          
                        if(s ==radio5)
                             exDescription="rg005 is a continuous short distance exercise which is at a moderate \n"
                                            +"pace however the length is short, it is really designed to build up \n"
                                            +"ones endurance and stamina levels, and should be done outdoors ideally. \n"
                                            +"\nThe exercise itself is a fitness enhancing exercise and the main muscle \n"
                                            +"area targetted are focused on the lower region of your body as a whole \n"
                                            +"because the aim is to strengthen your legs for higher endurance \n"
                                            +"\nYou should aim to perform this exercise on a daily basis if you are to \n"
                                            +"recieve the results you want. The pace is moderate and you should aim \n"
                                            +"to cover from 2000-2200m approx as the duration of the run is 20mins long, \n"
                                            +"and try to set yourself a target to improve and increase the distance on \n"
                                            +"each run while the time should remain the same, try to hold form throughout \n"
                                            +"the run, by running at a steady pace one which is not irratic or irregular.\n"
                                            +"done correctly this exercise should reduce you fat levels progressively and\n"
                                            +"improve your fitness by ample amounts, but the longer the run is the more \n"
                                            +"emphasis is placed on keeping motivated and not stopping in duration no \n"
                                            +"matter how exausted you may feel.\n"
                                            +"\nplease ensure you worm up properly by doin all the nececary stretches in\n"
                                            +"legs and calves mainly. Ideally You should normally aim to carry out this \n"
                                            +"run for a minimum 3 week period before returning and performing the\n"
                                            +"exercise review";
                             exCode="rg005";
                        if(s ==radio6)
                             exDescription="rg006 is a continuous short distance exercise which is at a moderate \n"
                                            +"pace however the length is short, it is really designed to build up \n"
                                            +"ones endurance and stamina levels, and should be done outdoors ideally. \n"
                                            +"\nThe exercise itself is a fitness enhancing exercise and the main muscle \n"
                                            +"area targetted are focused on the lower region of your body as a whole \n"
                                            +"because the aim is to strengthen your legs for higher endurance \n"
                                            +"\nYou should aim to perform this exercise 4 times a week if you are to \n"
                                            +"recieve the results you want. The pace is moderate and you should aim \n"
                                            +"to cover from 2200-2500m approx as the duration of the run is 25mins long, \n"
                                            +"and try to set yourself a target to improve and increase the distance on \n"
                                            +"each run while the time should remain the same, try to hold form throughout \n"
                                            +"the run, by running at a steady pace one which is not irratic or irregular.\n"
                                            +"done correctly this exercise should reduce you fat levels progressively and\n"
                                            +"improve your fitness by ample amounts, but the longer the run is the more \n"
                                            +"emphasis is placed on keeping motivated and not stopping in duration no \n"
                                            +"matter how exausted you may feel.\n"
                                            +"\nplease ensure you worm up properly by doin all the nececary stretches in\n"
                                            +"legs and calves mainly. Ideally You should normally aim to carry out this \n"
                                            +"run for a minimum 3 week period before returning and performing the\n"
                                            +"exercise review";
                             exCode="rg006";
                        if(s ==radio7)
                             exDescription="This Exercise is a continuous short distance exercise which is at a slow \n"
                                            +"pace however the length is short, it is really designed to build up \n"
                                            +"ones endurance and stamina levels, and should be done outdoors ideally. \n"
                                            +"\nThe exercise itself is a fitness enhancing exercise and the main muscle \n"
                                            +"area targetted are focused on the lower region of your body as a whole \n"
                                            +"because the aim is to strengthen your legs for higher endurance \n"
                                            +"\nIn addtion there is the added bonus of benifitting from a high level of \n"
                                            +"stamina and good performance under stress as this exercise will increase \n"
                                            +"you mental toughness as you push yourself\n"
                                            +"\nYou should aim to perform this exercise 4 times a week if you are to \n"
                                            +"recieve the results you want. The pace as stated is slow and you should aim \n"
                                            +"to cover from 2000-2200m approx as the duration of the run is 30mins long, \n"
                                            +"and try to set yourself a target to improve and increase the distance on \n"
                                            +"each run while the time should remain the same, try to hold form throughout \n"
                                            +"the run, by running at a steady pace one which is not irratic or irregular.\n"
                                            +"done correctly this exercise should reduce you fat levels progressively and\n"
                                            +"improve your fitness by ample amounts, but the longer the run is the more \n"
                                            +"emphasis is placed on keeping motivated and not stopping in duration no \n"
                                            +"matter how exausted you may feel.\n"
                                            +"\nplease ensure you worm up properly by doin all the nececary stretches in\n"
                                            +"legs and calves mainly. Ideally You should normally aim to carry out this \n"
                                            +"run for a minimum 3 week period before returning and performing the review";
                             exCode="rg007";
                        if(s ==radio8)
                             exDescription="This Exercise is a continuous long distance exercise which is at a slow \n"
                                            +"pace however the length is short, it is really designed to build up \n"
                                            +"ones endurance and stamina levels, and should be done outdoors ideally. \n"

    Use this class to print your contentPane of your
    JFrame:
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.print.*;
    import javax.swing.*;
    public class ComponenteParaImprimir
    implements Printable {
    private Component mComponent;
    boolean isBook;
    boolean escala;
    boolean visible;
    public final static boolean PARA_BOOK = true;
    public final static boolean HARDCOPY = false;
    public final static boolean CON_ESCALADO = true;
    public final static boolean SIN_ESCALADO = false;
    public final static boolean VISIBLE = true;
    public final static boolean INVISIBLE = false;
    static JFrame invisibleContainer;
    public ComponenteParaImprimir(Component c, boolean
    book, boolean escala,
    boolean visible) {
    mComponent = c;
    isBook = book;
    this.escala = escala;
    this.visible = visible;
    public int print(Graphics g, PageFormat pageFormat,
    int pageIndex) {
    if (pageIndex > 0 && !isBook) {
    return NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D) g;
    AffineTransform oldTransform = g2.getTransform();
    double x0 = pageFormat.getImageableX(), y0 =
    pageFormat.getImageableY();
    double pw = pageFormat.getImageableWidth(),
    ph = pageFormat.getImageableHeight();
    g2.translate(pageFormat.getImageableX(),
    pageFormat.getImageableY());
    int cw = mComponent.getWidth(), ch =
    mComponent.getHeight();
    double scx = ( (double) pw) / cw;
    double scy = ( (double) ph) / ch;
    if (escala) {
    g2.scale(scx, scy);
    if (!visible) {
    if (invisibleContainer == null) {
    //obtener tama�o del frame
    invisibleContainer = new JFrame();
    invisibleContainer.getContentPane().add(mComponent);
    invisibleContainer.pack();
    invisibleContainer.setVisible(false);
    invisibleContainer.getContentPane().removeAll();
    invisibleContainer.getContentPane().add(mComponent);
    invisibleContainer.pack();
    invisibleContainer.setVisible(false);
    setDoubleBuffering(mComponent, false);
    mComponent.paint(g2);
    setDoubleBuffering(mComponent, true);
    g2.setTransform(oldTransform);
    return PAGE_EXISTS;
    public void limpiaPanelInvisible() {
    invisibleContainer.getContentPane().removeAll();
    invisibleContainer = null;
    private boolean disableDoubleBuffering(Component c) {
    if (c instanceof JComponent == false) {
    return false;
    JComponent jc = (JComponent) c;
    boolean wasBuffered = jc.isDoubleBuffered();
    jc.setDoubleBuffered(false);
    return wasBuffered;
    private void restoreDoubleBuffering(Component c,
    boolean wasBuffered) {
    if (c instanceof JComponent) {
    ( (JComponent) c).setDoubleBuffered(wasBuffered);
    private void setDoubleBuffering(Component c, boolean
    isEnabled) {
    RepaintManager manager =
    RepaintManager.currentManager(c);
    manager.setDoubleBufferingEnabled(isEnabled);
    use it lyke this : transform your contentPane to
    printable whith visible parameter to false....
    ComponenteParaImprimir cp = new
    ComponenteParaImprimir( (JPanel)
    this.getContentPane(),false,true,false);
    PageFormat pf = pj.defaultPage();
    attributes = new HashPrintRequestAttributeSet();
    attributes.add(MediaSizeName.ISO_A4);
    attributes.add(new MediaPrintableArea(5, 5, 200, 300,
    MediaPrintableArea.MM));
    Paper papel = new Paper();
    pf.setPaper(papel);
    pf.setOrientation(PageFormat.LANDSCAPE);
    pj.setPrintable(cp, pf);
    if (pj.printDialog()) {
    try {
    pj.print(attributes);
    catch (PrinterException pe) {
    System.out.println(pe);
    i hope its helps you...hi thanks very much for your help. but i do not understand how to implement the last piece of code you have included.. is this sopose to go in my original class? please indicate where i need to put it .. thanks for your assistance

  • How to add event handling for a menu?

    hi,
    I have created a menu and few mneu items.
    for eachmenu itme , i did event handling and it is workign fine.
    it was like this
    menuItem = new JMenuItem("Exit",KeyEvent.VK_X);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    menu.add(menuItem);
         public void actionPerformed(ActionEvent e)
    JMenuItem source = (JMenuItem)(e.getSource());
    String s = "Action event detected. Event source: " + source.getText();
    System.out.println(s);     
    public void itemStateChanged(ItemEvent e)
    JMenuItem source = (JMenuItem)(e.getSource());
    String s = "Item event detected. Event source: " + source.getText();
    System.out.println(s);
    now int he second menu i don't have any menu item and i want to do the event handling for the menu itself. any ideas how to do it. following is the code for the menu
    //Build the second menu.
    menu2 = new JMenu("Options");
    menu2.setMnemonic(KeyEvent.VK_O);
    menuBar.add(menu2);
    menu2.addActionListener(this);     //this does nto work

    You were on the right track. However, selecting a menu is different from selecting a menu item. MenuItem chucks an ActionEvent and Menu will send an ItemEvent.
    If you pile all action output to one actionPerformed method then be careful of your assumptions on what the source type will be. If by any chance the Menu has sent an ActinoEvent then your code will have caused a ClassCastException.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MenuTest implements ActionListener, ItemListener {
        JMenuItem menuItem;
        JMenu menu1, menu2;
        JMenuBar menubar;
        JFrame frame;
        public MenuTest() {
            frame = new JFrame("MenuTest");
            frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
            menubar = new JMenuBar();
            frame.setJMenuBar(menubar);
            menu1 = new JMenu("File");
            menu1.setMnemonic(KeyEvent.VK_F);
            menuItem = new JMenuItem("Exit",KeyEvent.VK_X);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
            menuItem.addActionListener(this);
            menu1.addItemListener(this);
            menu1.add(menuItem);
            menubar.add(menu1);
            //Build the second menu.
            menu2 = new JMenu("Options");
            menu2.setMnemonic(KeyEvent.VK_O);
            menu2.addActionListener(this); //this does not work
            menu2.addItemListener(this); // use this instead
            menubar.add(menu2);
            JPanel panel = new JPanel();
            panel.setPreferredSize(new Dimension(100,100));
            frame.getContentPane().add(panel);
            frame.pack();
            frame.show();
        public void actionPerformed(ActionEvent e)
            String s = "Action event detected. Event source: " + e.getSource();
            System.out.println(s);
        public void itemStateChanged(ItemEvent e)
            String s = "Item event detected. Event source: " + e.getSource();
            System.out.println(s);
        public static void main(String[] args) {
            new MenuTest();
    }

  • Handling event of a particular menuitem

    hi,
    I've created a form with a Jmenu,but i m unable to listen the event of a particular menuitem. I'm sending my code in which when i click on any of the menu item it is listening to all the remaining menuitems also. so what changes are required in my below code in order to listen to a particular menu item?
    And ya my second question regarding this code is i want my frame to be opened in maximized form so that it cannod be moved. My frame seems to b opened as maximized but its actually not bcoz its still movable,so is there any way to open it maximized?
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class menu implements ActionListener
    JMenu m;
    JMenuItem n,s,sa;
    JMenuBar mb;
    JFrame f = new JFrame();
    menu() //constructor
    f.getContentPane().setBackground(new Color(146,187,237));
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    f.setSize(screenSize.width,screenSize.height);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mb = new JMenuBar();
    m = new JMenu("File");
    mb.add(m);
    n= new JMenuItem("New");
    n.addActionListener(this);
    m.add(n);
    s= new JMenuItem("Save");
    s.addActionListener(this);
    m.add(s);
    sa = new JMenuItem("Save As");
    sa.addActionListener(this);
    m.add(sa);
    f.setJMenuBar(mb);
    f.setVisible(true);
    public void actionPerformed(ActionEvent e)
    if(e.getSource()==n);
    try
    System.out.println("new");
    catch(Exception e1)
    e1.getMessage();
    if(e.getSource()==s);
    try
    System.out.println("Save");
    catch(Exception e1)
    e1.getMessage();
    if(e.getSource()==sa);
    try
    System.out.println("Save As");
    catch(Exception e1)
    e1.getMessage();
    public static void main(String args[])
    menu a = new menu();
    }

    How to use Menus
    http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html
    just scroll down at the bottom of the page for examples.
    If you want to maximize a frame use setExtendedState(JFrame.MAXIMIZED_BOTH)

  • RTP Transmission, Receive Woes

    Hi ppl,
    I developed an app to transmit captured video and audio as RTP streams. I made a monitor of the video and audio being captured which is displayed on the Frame. I also made a player from the RTP data received from another system in the network which transmits the data as RTP streams.
    My problem is as soon as the player is realized and starts, the other components in the window, say a JList control, JButton controls are invisible and the JFrame upon which the Monitor and player is placed is also unresponsive. But the Monitor still displays video/audio being captured and the Player plays the video/audio being received from the network.
    Can anybody offer some help on this? Please ...

    Hi!
    You r probably suffering from the problem of light weight component(tat r swing components) n heavy weight component(getVideo..... method components). Here heavy weight components r not working properly with these light weight components so..... not working properly for it more read article available title something as "Heavy weight n light weight components" as this site.........
    I m not sure much but this might show u some direction to work properly..............

  • Can i call a JMenuBar in a number of JFrame(s) ?

    Hi ,
    I've a program with a number of JFrames.
    I wanted to add a JMenuBar for each frame of my program, this menu bar has the same design code and the same events code in all the program frames, so is there a way to create this JMenuBar once only & call it some how in every JFrame to load it directly instead of writing its same code a lot of times for every JFrame ?
    Thanks ,
    Hesham

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    class Test{
         public static void main( String[] argv ) throws Throwable {
              for(int i=0; i<10; i++){
                   SuperFrame f = new SuperFrame();
                   f.setLocation(i*10,i*10);
                   f.setSize(400,300);
                   f.setVisible(true);
    class SuperFrame extends JFrame{
         private static final long serialVersionUID = 1L;
          * All the menu item goes here
         JMenuBar mbar = new JMenuBar();
         JMenu menu = new JMenu("Menu");
         JMenuItem menuItem1  = new JMenuItem("Close");
         JMenuItem menuItem2  = new JMenuItem("Exit");
         public SuperFrame(){
              super("Testing");
              this.menu.add(menuItem1);
              this.menu.add(menuItem2);
              this.mbar.add(menu);
              this.setJMenuBar(mbar);
              menuItem1.addActionListener(new ActionListener(){
                   @Override
                   public void actionPerformed(ActionEvent arg0) {
                        dispose();
              menuItem2.addActionListener(new ActionListener(){
                   @Override
                   public void actionPerformed(ActionEvent arg0) {
                        System.exit(0);
    }

  • How to add a JMenubar and a JTable in a JFrame in a single application

    Hi all,
    I require an urgent help from you.I am a beginer in programming Swing.I want to add a menu,combobox,and a table in a single application.I did coding as below:
    package com.BSS;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    public class newssa extends JFrame
         public JMenuBar menuBar;
         public JToolBar toolBar;
         public JFrame frame;
         private JLabel jLabel1;
         private JLabel jLabel2;
         private JLabel jLabel3;
         private JLabel jLabel4;
         private JLabel jLabel5;
         private JLabel jLabel6;
         private JComboBox jComboBox1;
         private JComboBox jComboBox2;
         private JComboBox jComboBox3;
         private JComboBox jComboBox4;
         private JComboBox jComboBox5;
         private JComboBox jComboBox6;
         private JTable jTable1;
         private JScrollPane jScrollPane1;
         private JPanel contentPane;
         public newssa()
              super();
              initializeComponent();
              this.setVisible(true);
         private void initializeComponent()
              jLabel1 = new JLabel();
              jLabel2 = new JLabel();
              jLabel3 = new JLabel();
              jLabel4 = new JLabel();
              jLabel5 = new JLabel();
              jLabel6 = new JLabel();
              jComboBox1 = new JComboBox();
              jComboBox2 = new JComboBox();
              jComboBox3 = new JComboBox();
              jComboBox4 = new JComboBox();
              jComboBox5 = new JComboBox();
              jComboBox6 = new JComboBox();
              frame=new JFrame();
              //Included here
              JMenuBar menuBar = new JMenuBar();
              JMenu general = new JMenu("General");
         menuBar.add(general);
         JMenu actions =new JMenu("Actions");
         menuBar.add(actions);
         JMenu view=new JMenu("View");
         menuBar.add(view);
         JMenu Timescale=new JMenu("TimeScale");
         menuBar.add(Timescale);
         Timescale.add("Today CTRL+D");
         Timescale.add("Current Week CTRL+W");
         Timescale.add("Current Month CTRL+M");
         Timescale.add("Current Quarter CTRL+Q");
         Timescale.add("Current Year CTRL+Y");
         Timescale.add("Custom TimeScale CTRL+U");
         JMenu start=new JMenu("Start");
         menuBar.add(start);
         JMenu options=new JMenu("Options");
         menuBar.add(options);
         JMenu help=new JMenu("Help");
         menuBar.add(help);
         JFrame.setDefaultLookAndFeelDecorated(true);
         frame.setJMenuBar(menuBar);
         frame.pack();
         frame.setVisible(true);
         toolBar = new JToolBar("Formatting");
         toolBar.addSeparator();
              //Before this included new
              String columnNames[] = { "ColorStatus", "Flash", "Service Order","Configuration","Configuration Description"};
              // Create some data
              String dataValues[][] =
                   { "blue", "flash", "ORT001" },
                   { "AVCONF", "av configuration with warrenty"}
              // Create a new table instance
              //jTable1 = new JTable( dataValues, columnNames );
              jTable1 = new JTable(dataValues,columnNames);
              jScrollPane1 = new JScrollPane(jTable1);
              contentPane = (JPanel)this.getContentPane();
              //scrollPane = new JScrollPane( table );
              //topPanel.add( scrollPane, BorderLayout.CENTER );
              // jLabel1
              jLabel1.setText("Service Centers");
              // jLabel2
              jLabel2.setText("Service Areas");
              // jLabel4
              jLabel3.setText("Skills");
              jLabel4.setText("Availablity Types");
              // jLabel5
              jLabel5.setText("From Date");
              // jLabel6
              jLabel6.setText("To");
              // jComboBox1
              jComboBox1.addItem("Coimbatore");
              jComboBox1.addItem("Chennai");
              jComboBox1.addItem("Mumbai");
              jComboBox1.addItem("New Delhi");
              jComboBox1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox1_actionPerformed(e);
              // jComboBox2
              jComboBox2.addItem("North Zone");
              jComboBox2.addItem("South Zone");
              jComboBox2.addItem("Central Zone");
              jComboBox2.addItem("Eastern Zone");
              jComboBox2.addItem("Western Zone");
              jComboBox2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox2_actionPerformed(e);
              // jComboBox3
              jComboBox3.addItem("Microsoft Components");
              jComboBox3.addItem("Java Technologies");
              jComboBox3.addItem("ERP");
              jComboBox3.addItem("Others");
              jComboBox3.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox3_actionPerformed(e);
              // jComboBox4
              jComboBox4.addItem("One");
              jComboBox4.addItem("Two");
              jComboBox4.addItem("Three");
              jComboBox4.addItem("Four");
              jComboBox4.addItem("Five");
              jComboBox4.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox4_actionPerformed(e);
              // jComboBox5
              jComboBox5.addItem("12/12/2004");
              jComboBox5.addItem("13/12/2004");
              jComboBox5.addItem("14/12/2004");
              jComboBox5.setEditable(true);
              jComboBox5.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox5_actionPerformed(e);
              // jComboBox6
              jComboBox6.addItem("12/11/2004");
              jComboBox6.addItem("13/11/2004");
              jComboBox6.addItem("14/11/2004");
              jComboBox6.setEditable(true);
              jComboBox6.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox6_actionPerformed(e);
              // jTable1
              jTable1.setModel(new DefaultTableModel(4, 4));
              // jScrollPane1
              jScrollPane1.setViewportView(jTable1);
              // contentPane
              contentPane.setLayout(null);
              addComponent(contentPane, jLabel1, 2,29,84,18);
              addComponent(contentPane, jLabel2, 201,33,76,18);
              addComponent(contentPane, jLabel3, 384,32,59,18);
              addComponent(contentPane, jLabel4, 2,77,85,18);
              addComponent(contentPane, jLabel5, 197,79,84,18);
              addComponent(contentPane, jLabel6, 384,80,60,18);
              addComponent(contentPane, jComboBox1, 85,32,100,22);
              addComponent(contentPane, jComboBox2, 276,32,100,22);
              addComponent(contentPane, jComboBox3, 419,30,100,22);
              addComponent(contentPane, jComboBox4, 88,76,100,22);
              addComponent(contentPane, jComboBox5, 276,79,100,22);
              addComponent(contentPane, jComboBox6, 421,78,100,22);
              addComponent(contentPane, jScrollPane1, 33,158,504,170);
              // newssa
              this.setTitle("SSA Service Scheduler");
              this.setLocation(new Point(0, 0));
              this.setSize(new Dimension(560, 485));
         /** Add Component Without a Layout Manager (Absolute Positioning) */
         private void addComponent(Container container,Component c,int x,int y,int width,int height)
              c.setBounds(x,y,width,height);
              container.add(c);
         // TODO: Add any appropriate code in the following Event Handling Methods
         private void jComboBox1_actionPerformed(ActionEvent e)
              int index = jComboBox1.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("Area Coimbatore Selected "); break;
                   case 1: System.out.println("Area Chennai selected"); break;
                   case 2: System.out.println("Mumbai being selected"); break;
                   case 3: System.out.println("New Delhi being selected"); break;
         private void jComboBox2_actionPerformed(ActionEvent e)
              int index = jComboBox2.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("North Zone Selcted "); break;
                   case 1: System.out.println("South Zone being selected"); break;
                   case 2: System.out.println("Central Zone being selected"); break;
                   case 3: System.out.println("Eastern Zone being selected"); break;
                   case 4: System.out.println("Western Zone being selected"); break;
         private void jComboBox3_actionPerformed(ActionEvent e)
              int index = jComboBox3.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("Microsoft Components being selected"); break;
                   case 1: System.out.println("Java Technologies being selected"); break;
                   case 2: System.out.println("ERP Tehnologies being selected"); break;
                   case 3: System.out.println("Other's selected"); break;
         private void jComboBox4_actionPerformed(ActionEvent e)
              int index = jComboBox4.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("One selected"); break;
                   case 1: System.out.println("Two selected"); break;
                   case 2: System.out.println("Three selected"); break;
                   case 3: System.out.println("Four selected"); break;
                   case 4: System.out.println("Five selected"); break;
         private void jComboBox5_actionPerformed(ActionEvent e)
              int index = jComboBox5.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("12/12/2004 being selected"); break;
                   case 1: System.out.println("13/12/2004 being selected"); break;
                   case 2: System.out.println("14/12/2004 being selected"); break;
         private void jComboBox6_actionPerformed(ActionEvent e)
              int index = jComboBox6.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("12/11/2004 being selected"); break;
                   case 1: System.out.println("13/11/2004 being selected"); break;
                   case 2: System.out.println("14/11/2004 being selected"); break;
         public static void main(String[] args)
              newssa ssa=new newssa();
              //JFrame.setDefaultLookAndFeelDecorated(true);
              //JDialog.setDefaultLookAndFeelDecorated(true);
              //JFrame frame = new JFrame("SSA Service Scheduler");
    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //frame.setJMenuBar(ssa.menuBar);
    //frame.getContentPane( ).add(ssa.toolBar, BorderLayout.NORTH);
    //frame.getContentPane( ).add(ssa.pane, BorderLayout.CENTER);
    //frame.pack( );
    //frame.setVisible(true);
              try
                   //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
              catch (Exception ex)
                   System.out.println("Failed loading L&F: ");
                   System.out.println(ex);
    But as a O/P ,I am getting menu in a seperate windos and the rest of the combobox and jtable in a seperate window.Kindly help me to solve the application.
    VERY URGENT PLEASE..
    Thanks in advance
    with kind regds
    Satheesh.K

    But did u mean this as the next problem,Which I will come across..Yes, the second setVisible(true) seemed to be producing a smaller frame behind the main frame.
    And your JMenuBar is declared twice, but not sure if this will affect the code - haven't read it all.

  • Remove JMenuBar area from JFrame

    hi there,
    I have an application with a JFrame undecorated and it has a JMenuBar.
    I add a JPanel in the JFrame, and I change the JMenuBar to JPanel,
    panel.add(Menu);
    setJMenuBar(Menu);the JMenuBar it visible into the JPanel
    but, in the JFrame I have the JMenuBar area blank at the TOP.
    How do I do to remove the JMenuBar area from JFrame.
    thanks.

    I am trying make a JFrame undecorated,
    I want create my own title bar, with my title message,
    my icons, etc.
    I found an image from a SAP Application frame
    here
    http://help.sap.com/saphelp_46c/helpdata/en/73/69ee7d55bb11d189680000e829fbbd/Image84.gif
    I want make a frame like this
    can you help me?
    thanks

  • Subclass of JPanel invisible in a subclass of JFrame

    I am very, very new to Java GUI, so bear with me:).
    I create a subclass of JFrame and add a menu bar it. That is ok. Then I create a subclass of JPanel and added it to the contentPane of the subclass of the JFrame. But when I run the code, it is not visible, only the frame and the menu bar can be seen. I tried it differently, creating a class for the entire GUI that then creates an instance of JFrame and adds the instance of the said subclass of JPanel and it works fine. I do not see what is the difference. Also, when debugging the first version, I put the break point inside the painComponent of the JPanel subclass and it seems that the program never enters it. Can somebody please tell me why? Is the subclass of JPanel not properly added to the subclass of JFrame?
    Here is the code:
    * PlanITED.java
    * Created on 30 de Maio de 2008, 17:53
    * @author Branka
    package PlanITEDLibraries;
    public class PlanITED extends javax.swing.JFrame {
    /** Creates new form PlanITED */
    public PlanITED() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
    menuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    loadMapItem = new javax.swing.JMenuItem();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("PlanITED");
    fileMenu.setText("File");
    fileMenu.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    fileMenuActionPerformed(evt);
    loadMapItem.setText("Load map");
    loadMapItem.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    loadMapItemActionPerformed(evt);
    fileMenu.add(loadMapItem);
    menuBar.add(fileMenu);
    setJMenuBar(menuBar);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 400, Short.MAX_VALUE)
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 279, Short.MAX_VALUE)
    pack();
    }// </editor-fold>//GEN-END:initComponents
    private void fileMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileMenuActionPerformed
    // TODO add your handling code here:
    }//GEN-LAST:event_fileMenuActionPerformed
    private void loadMapItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadMapItemActionPerformed
    // TODO add your handling code here:
    }//GEN-LAST:event_loadMapItemActionPerformed
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    PlanITED oPlanITED = new PlanITED();
    oPlanITED.getContentPane().add(new DrawingArea());
    oPlanITED.setVisible(true);
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenuItem loadMapItem;
    private javax.swing.JMenuBar menuBar;
    // End of variables declaration//GEN-END:variables
    And the code for the class DrawingArea:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package PlanITEDLibraries;
    import javax.swing.*;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Color;
    * @author Branka
    public class DrawingArea extends JPanel {
    @Override
    public Dimension getPreferredSize() {
    return new Dimension(500,500);
    @Override
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.drawString("This is my custom Panel!",10,20);
    g.setColor(Color.RED);
    g.fillRect(0, 0, 500, 500);
    Thanks!

    Don't forget to use the [Code Formatting Tags|http://forum.java.sun.com/help.jspa?sec=formatting], so the posted code retains its original formatting.
    Is the subclass of JPanel not properly added to the subclass of JFrame?That would be my guess. I have no idea how GroupLayout works but you didn't set any constraints when you added the panel to the content pane so I would guess that is the problem.
    Don't use the IDE to create your code. Learn how to create GUIs yourself and then you will understand the code. Spend your time learning Java, not learning the IDE.

  • Can you get focus for an invisible JFrame?

    I'm writing a program where I use a JFrame for user input, and, after receiving input, the JFrame goes invisible, leaving the desktop clear while the program continues processing in the background. I want the same JFrame to be called back with user keyboard input (e.g. F12), but I don't know how to get KeyListener to work because I cannot obtain focus on the invisible JFrame. Is this possible?
    If not, is there a similar way to work around the problem?
    Any help is appreciated, thanks!

    I don't think that you can have focus on an invisible frame (though I'm not sure) but a goos way around would be to show a small dialog that says "Currently working, press a key to go back to main screen" and add a key listener to this dialog instead of the invisible frame.
    But if you want to work in the background, maybe you'll have to run the dialog on a new thread for both to work at the same time.
    Hope it helps

  • JMenuBar with no focused JFrame? Is this possible?

    Hi I'd like to know if there is some way to have a JMenuBar visible with no JFrame. I'm asking this because I'd like to add functions like New Window and other to my Mac menu bar. Can this be done? How?

    Buy another hard drive.  They're cheap these days.
    In fact, buy a couple of 'em.  I recommend a minimum of five internal hard drives.
    C: Windows and Programs
    D: Project, graphic and audio files
    E: Cache and Scratch
    F: Media
    G: Export

  • Align a JMenuBar to right in a JFrame

    I have next code and I don't know how to alignt to right my menuBar label:
    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html#custom

  • How to Capture the event when minimized button is clicked of a JFrame?

    Hi All,
    In my SWING application, I want to do something when the minimized button is clicked. But not able to understand how to do that.
    My basic requirement is like that, if I minimize the JFrame, it should be minimized to system tray with an icon. Again when the icon is clicked, the frame should be maximized in the Windows.
    Also, how to make my JFrame visible/invisible. If I close it, then the process will got killed... that I don't want to happen. Should I us setVisible(true/false) for the frame... Please suggest...
    Thanks,
    Ujjal

    There could be some mistake in my basic understanding... Anyway this is what I wrote...
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    public class WindowIconify extends JApplet
         JFrame jf;
         JPanel jp;
         public void run()
              jf = new JFrame("test");
              jf.setSize(200,200);
              jp = new JPanel();
              jp.setBackground(Color.BLACK);
              jf.add(jp);
              jf.setVisible(true);
         public boolean handleEvent(Event event)
              if ( event.id == Event.WINDOW_ICONIFY)
                   System.out.print("iconifying");
              return true;
         public static void main(String args[])
              WindowIconify wi = new WindowIconify();
              wi.run();
    }

Maybe you are looking for

  • IPod click wheel won't take any files

    I have an iPod with a click wheel, and have had many problems with it. When I first got it I loaded my music on it from my Dell PC. I have had many problems since, and currently I cannot get it to retain any files transferred from my G5 iMac. When I

  • Problem in parsing JMS TextMessages using DOM

    Hi I want to parse JMS TextMessages by using DOM parser.DomBuilder's parse method supports only Strings,input stream in its constructor. Is there anyway we can parse JMS TextMessages by using DOM.Your help would be appreciated. Thanks Kanth

  • Need some help here

    Ok here's whats going on: I'm making a portfolio using XML and AS3. Loading the XML is all fine, I put images in a loader using a for loop. However, i would like these images to be buttons and set a TextField.alpha at 1 when hovering the image. The p

  • Another strange behavior

    Hi, I've defined a stateless session bean as follows: @Stateless @Named("service") public class Service extends AbstractService { }And in one of my classes: @Names("claims") @SessionScoped ClaimsBean extends AbstractBean {     @EJB Service service;  

  • Website icon in address bar gone!

    Where is it gone? and how do I re enable it?