JMenu problem

Hi,
i'm developing a window consisting of a JMenuBar, y code is as follows..
mbar=new JMenuBar();
file=new JMenu("File");
item1=new JMenuItem("Open");
item2=new JMenuItem("Exit");
file.setMnemonic('f');
file.add(item1);
file.add(item2);
mbar.add(file);
the problem is While clicking JMenu "File", happens nothing,
is there any problem with this code???
please help;
thanks in adv

Read the Swing tutorial on "How to Use Menus" for working examples:
http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html
If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
http://homepage1.nifty.com/algafield/sscce.html
Don't forget to use the "Code Formatting Tags", so the posted code retains its original formatting.
http://forum.java.sun.com/help.jspa?sec=formatting

Similar Messages

  • JSlider in JMenu problem.

    I have recently switched to using jdk1.5.0_04 and have some problem.
    I have a JSlider contained in a JMenu. But I cannot drag the slider anymore, this worked in java 1.4. I can only click on a tick on the slider and the sldier will move to the location i clicked, but it is very slow.
    Anyone have any suggestions?
    Also, how do you disable selection in a JTextPane?

    Components that respond to MouseEvents and are embedded in a JMenu are broken in 1.5.
    Take a look at the last 3 messages in this thread, which includes a link to the bug report
    http://forum.java.sun.com/thread.jspa?threadID=654329&messageID=3849153

  • Add Drop Shadow to JMenu Problem

    Hi,
    I got this code from "Swing Hacks", for some reason it does not run for me, but throws exceptions. I can not figure out why this is happening. This code straight out of the book, should be runnable. Below is the custom class, then the driver-test class, then the Exception:
    import javax.swing.plaf.basic.*;
    import javax.swing.plaf.*;
    import javax.swing.border.*;
    import javax.swing.*;
    import java.awt.*;
    public class CustomPopupMenuUI extends BasicPopupMenuUI{
         public static ComponentUI createUI(JComponent c){
              return new CustomPopupMenuUI();
         public Popup getPopup(JPopupMenu popup, int x,
                   int y){
              Popup pp = super.getPopup(popup, x,y);
              JPanel panel = (JPanel)popup.getParent();
              panel.setBorder(new ShadowBorder(3,3));
              panel.setOpaque(false);
              return pp;
    class ShadowBorder extends AbstractBorder{
         int xoff,yoff;
         Insets insets;
         public ShadowBorder(int x, int y){
              this.xoff = x;
              this.yoff = y;
              insets = new Insets(0,0,xoff,yoff);
         public Insets getBorderInsets(Component c){
              return insets;
         public void paintBorder(Component comp, Graphics g,
                   int x, int y, int width, int height){
              g.setColor(Color.BLACK);
              g.translate(x,y);
              // draw right side
              g.fillRect(width-xoff,yoff,xoff,height-yoff);
              // draw bottom side
              g.fillRect(xoff,height-yoff,width-xoff,yoff);
              g.translate(-x,-y);
    // Driver Below
    import javax.swing.*;
    import javax.swing.plaf.ComponentUI;
    import java.awt.*;
    public class MenuTest {
         public static void main(String[] args)throws Exception{
              UIManager.put("PopupMenuUI","CustomPopupMenuUI");
              //UIManager.put("MenuItemUI","LucentMenuItemUI");
              JFrame frame = new JFrame();
              JMenuBar mb = new JMenuBar();
              //mb.setUI(new CustomMenuUI());
              frame.setJMenuBar(mb);
              JMenu menu = new JMenu("File");
              mb.add(menu);
              menu.add(new JMenuItem("Open"));
              menu.add(new JMenuItem("Save"));
              menu.add(new JMenuItem("Close"));
              menu.add(new JMenuItem("Exit"));
              menu = new JMenu("Edit");
              mb.add(menu);
              menu.add(new JMenuItem("Cut"));
              menu.add(new JMenuItem("Copy"));
              menu.add(new JMenuItem("Paste"));
              menu.add(new JMenuItem("Paste Special.."));
              frame.getContentPane().setLayout(new BorderLayout());
              frame.getContentPane().add("North",new JButton("Button"));
              frame.getContentPane().add("Center",new JLabel("Label"));
              frame.getContentPane().add("South",new JCheckBox("checkbox"));
              frame.pack();
              frame.setSize(200,150);
              frame.show();
    }Exception:
    UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JPopupMenu[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,desiredLocationX=0,desiredLocationY=0,label=,lightWeightPopupEnabled=true,margin=,paintBorder=true]
    java.lang.Error
         at javax.swing.UIDefaults.getUIError(Unknown Source)
         at javax.swing.MultiUIDefaults.getUIError(Unknown Source)
         at javax.swing.UIDefaults.getUI(Unknown Source)
         at javax.swing.UIManager.getUI(Unknown Source)
         at javax.swing.JPopupMenu.updateUI(Unknown Source)
         at javax.swing.JPopupMenu.<init>(Unknown Source)
         at javax.swing.JPopupMenu.<init>(Unknown Source)
         at javax.swing.JMenu.ensurePopupMenuCreated(Unknown Source)
         at javax.swing.JMenu.add(Unknown Source)
         at hacks.MenuTest.main(MenuTest.java:23)
    advTHANKSance

    I am also using xp and java version 1.4.2_08, but to no avail.. see below:
    C:\workspace\Swing Hacks\src>java -version
    java version "1.4.2_08"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
    Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
    C:\workspace\Swing Hacks\src>java hacks.MenuTest
    UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JPopupMenu[,0,0
    ,0x0,invalid,alignmentX=null,alignmentY=null,border=,flags=0,maximumSize=,minimu
    mSize=,preferredSize=,desiredLocationX=0,desiredLocationY=0,label=,lightWeightPo
    pupEnabled=true,margin=,paintBorder=true]
    java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:689)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:719)
    at javax.swing.UIManager.getUI(UIManager.java:784)
    at javax.swing.JPopupMenu.updateUI(JPopupMenu.java:204)
    at javax.swing.JPopupMenu.<init>(JPopupMenu.java:169)
    at javax.swing.JPopupMenu.<init>(JPopupMenu.java:154)
    at javax.swing.JMenu.ensurePopupMenuCreated(JMenu.java:521)
    at javax.swing.JMenu.add(JMenu.java:556)
    at hacks.MenuTest.main(MenuTest.java:23)
    UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JPopupMenu[,0,0
    ,0x0,invalid,alignmentX=null,alignmentY=null,border=,flags=0,maximumSize=,minimu
    mSize=,preferredSize=,desiredLocationX=0,desiredLocationY=0,label=,lightWeightPo
    pupEnabled=true,margin=,paintBorder=true]
    java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:689)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:719)
    at javax.swing.UIManager.getUI(UIManager.java:784)
    at javax.swing.JPopupMenu.updateUI(JPopupMenu.java:204)
    at javax.swing.JPopupMenu.<init>(JPopupMenu.java:169)
    at javax.swing.JPopupMenu.<init>(JPopupMenu.java:154)
    at javax.swing.JMenu.ensurePopupMenuCreated(JMenu.java:521)
    at javax.swing.JMenu.add(JMenu.java:556)
    at hacks.MenuTest.main(MenuTest.java:30)
    I don't understand what the issue could be..
    Can anyone reproduce this error??

  • Problems with JMenu

    Hi,
    i have a problem with the JMenu in a project.
    The JMenu starts with a normal behaviour.
    After a time an error occurs:
    One JMenuitem is selected, and every move in the JMenu changes the selection only for a short time.
    Then the selection jumps back to the former
    selection.
    Anyone who knows this problem?
    Thanks
    Guido

    I now know when the trouble starts. When i start a DragnDrop action and then moves above the JMenu the odd behaviour starts. With the same trick this behaviour ends.
    I'm now searching for a way to avoid this trouble.
    The JMenu is not a Droptarget.
    Any suggestions?
    Guido

  • JMenu pop-up SubMenu problem

    Hi,
    I'm having a problem displaying a submenu on a JMenu. My app has a tree with various nodes. After clicking on one of the nodes, you can either view the menu in pop-up form by right clicking on the node, or from a regular menu at the top of the screen. These menu's are identical and are generated by the same functions except one if pop-up and the other is not.
    Everything works fine, EXCEPT, when opening the pop-up menu, the submenu's do not appear - the "Select Files" item does not even have the submenu arrow next to it. I know this methos is entered and run without failure as I have debugged it but the submenus just do not appear.
    Here is the source:
    JMenuItem[] m_actions m_actions = new JMenuItem[actionNames.length];     // items for display in the popup menu for this object
    JMenu m_selectFiles = new JMenu("Select Files");                    // sub menu for select files option
    public void setMenu(JMenu aMenu, boolean aMultipleSelection) {          
         aMenu.removeAll();
         for(int i=0; i<m_actions.length; i++) {
              if (m_actions[i] instanceof JMenu) {
                   if (!m_actions.getText().equals("Select Files"))
                        aMenu.add((JMenu)m_actions[i]);
                   else                         
                        addSelectMenu (aMenu);                                             
              } else     {
                   aMenu.add(m_actions[i]);
                   if(aMultipleSelection & !m_multipleActions[i])
                        m_actions[i].setEnabled(false);
                        if(!aMultipleSelection & m_permittedActions[i])
                        m_actions[i].setEnabled(true);
    private void addSelectMenu (JMenu aMenu) {
         if (m_selectFiles.getItemCount() > 0) {
              m_selectFiles.removeAll();
         templateSubMenus = new JMenu("Output Templates");          
         if (templateNames == null)
              templateNames = getTemplates();
         else {
              templateNames.removeAllElements();
              templateNames = getTemplates();
         if (templateSubMenus.getItemCount() > 0) {
              templateSubMenus.removeAll();
         JMenu[] templateSubOptions = new JMenu[templateNames.size()];          
         for(int j=0; j<templateNames.size(); j++) {               
              templateSubOptions[j] = new JMenu((String)templateNames.elementAt(j));
              templateSubOptions[j].add(new JMenuItem("Modify"));
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).addActionListener(monListener);
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).setActionCommand("TempModify:"+(String)templateNames.elementAt(j));
              templateSubOptions[j].add(new JMenuItem("Copy"));
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).addActionListener(monListener);
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).setActionCommand("TempCopy:"+(String)templateNames.elementAt(j));
              templateSubOptions[j].add(new JMenuItem("Delete"));
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).addActionListener(monListener);
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).setActionCommand("TempDelete:"+(String)templateNames.elementAt(j));
              templateSubMenus.add((JMenu)templateSubOptions[j]);               
         templateSubMenus.addSeparator();
         templateSubMenus.add(new JMenuItem("New Template"));          
         templateSubMenus.getItem(templateSubMenus.getItemCount()-1).addActionListener(monListener);          
         m_selectFiles.add(templateSubMenus);
         aMenu.add((JMenu)m_selectFiles);          
    Any ideas would be greatly appreciated.
    Thanks!!!!!

    Hi,
    I have the same problem. Can anybody help please?
    Thanks,
    Kaveh

  • JMenu and Paint Problem

    Hello,
    I have been teaching my self Java and I have become quite proficient with it, however, I have a problem that I can not fix, or get around.
    I have a JMenuBar in a JFrame with some JMenu�s containing JMenuItems. I also have a JPanel that I draw inside (I Know that is probably not the wisest way to draw things, but it was the way I first learned to draw and now my program is too big and it is not worth while to change). Any ways, I draw some graphics inside of this JPanel.
    The menu items change the drawings; this is done by repainting the JPanel Graphic. However, when I click one of the menu items, the JPanel paints but there is a residual of the JMenu in the background that will not disappear.
    The menu is closed and if I open and then close the menu the residual goes away.
    => I would like to know how to prevent the residual from appearing?
    The problem also occurs when I use the popup menus outside of the JmenuBar.
    What I think is wrong.
    I think my problem is with the repaint. I don�t think the JFrame is repainting. I think I am simply repainting all the components in the JFrame but not the JFrame itself and thus the residual is not cleared from the JFrame. I don�t know how to fix this but I believe that is the problem because when I minimize the JFrame then Maximize it the JFrame will not paint, and I can see right through the JFrame, but the components paint fine.
    Sorry for the long question, but I don�t know what would be helpful.
    Any advice would be appreciated,
    Thank you
    Seraj

    // This is the code that listens for the menu item
    private void RBmmActionPerformed(java.awt.event.ActionEvent evt) {                                    
            calc.setIN(false);
            updateData();                    // updates some data
            paint2();                           // my special draw fuction shown below
        public void paint2()                          // this the special paint that draws on the JPanel
            Graphics page = jPanel1.getGraphics();
            if(start_end)
                myPic.draw(page);
            else
                page.setColor(Color.WHITE);
                page.fillRect((int)(OFFSET.getX()), (int)(OFFSET.getY()), (int)(R_BOUND-OFFSET.getX()), (int)(L_BOUND-OFFSET.getY()));
            repaint();             
    public void paint(Graphics g)               // this is the regular paint methode
            MessageHandler();
            ATD_age.repaint();
            StanderdCal.repaint();
            ChildSRF.repaint();
            MessageArea.repaint();
        }I hope that is helpful

  • JMenu and MouseListener problems

    I have a JMenu that is used as a JMenuItem in another JMenu in the menu bar. The same JMenu is added as a popup menu to a button.
    I added a MouseListener to the JMenu because I want to execute some code upon mouseEntered() and mouseExited().
    Problem: the listener is only fired when I enter or exit the menu from the menu bar, never when the popup menu of the button is entered or exited.
    What can I do to trigger the mouse listener?

    I have a JMenu that is used as a JMenuItem in another JMenu in the menu bar.Components can only have a single parent. I don't know how what you are describing is possible.
    If you want to share the ActionEvent then you should be using an Action when creating the menu. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/misc/action.html]How to use Actions.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Problems with disappearing JTextArea when activating JMenu

    Im having trouble with using JTextArea in conjunction with JMenu and JInternalFrame. I have a program that uses JInternalFrames for navigation, when the navigation been used I set the JInternalFrame to setVisible(false) and display a JMenuBar with several components and a JTextArea. The JTextArea gets displayed as it should and so is the JMenuBar but when a JMenuItem has been activated the JTextArea becomes invisible or partly invisible. Anyone have any suggestions?
    //Function that removes the JInternalFrame and adds the JMenuBar and JTextArea to the program
    public void ordBehandlare()
                   ramnav.setVisible(false); //ramnav == JInternalFrame
                   Container cont = getContentPane();
                   cont.add(ordbehandlarArea); //ordbehandlarArea == JTextArea
                   setJMenuBar(ordBehandBar); //ordBehandBar == JMenuBar
    Grateful for any answers...

    From the 5 lines of code you posted I have no idea whats wrong, but I'm sure you can create a 20 line program that we can compile and execute that demonstrates your problem. Chances are while your creating this simple program you will find your error.

  • ActionPerformed problem with jmenu

    hi i am trying to get the action performed for 'exit' in a JMenu but
    i cant seem to find the problem the program will run be nothing hapens when i click exit on the menu. any help would be greatly welcomed
    markimport java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    class MyFrame2 extends JFrame implements ActionListener{
         private JMenuBar bar = new JMenuBar();//create menubar
         private JMenu j1 = new JMenu();
         private JMenu j2 = new JMenu();
         private JMenu j3 = new JMenu();
         private JMenu j4 = new JMenu();
         private JMenu j5 = new JMenu();
         private JMenuItem jm1 = new JMenuItem();
         private JMenuItem jm2 = new JMenuItem();
         Container content;
    public MyFrame2(String str)
    {  super(str);
         content= this.getContentPane();
         content.setLayout(new FlowLayout());
    setSize(220,250);
         bar.add(j1);
         bar.add(j2);
         bar.add(j3);
         bar.add(j4);
         bar.add(j5);
         j1.setText("Register");
         j2.setText("Not Connected");
         j3.setText("New DB");
         j4.setText("Admin");
         j5.setText("Exit");
         j5.addActionListener(this);
         jm1.setText("Server Info");
         jm2.setText("User Admin");
         j4.add(jm1);
         j4.add(jm2);
         setJMenuBar(bar);
         setVisible(true); }
         public void actionPerformed(ActionEvent e){
         Object target=e.getSource();
              if (target== j5){System.exit(0);}
         public class Db4
         public static void main(String args[]) {
    MyFrame2 fr= new MyFrame2("Account Example");

    The problem is that your "j5" is a JMenu not a JMenuItem. JMenu objects respond to mouseclicks by displaying a popup menu not by calling an actionlistener. I changed "j5" to be a JMenuItem and it worked fine, although I won't advice placing JMenuItems directly on a menubar.

  • JMenu is behind Canvas. problem ?

    I have created a JFrame with a JMenuBar,
    I have added a ImageCanvas (sub class of Canvas) in the center of the JFrame
    but whenever i click on Menu it appears behind the canvas
    what to do pls help?

    Hey,
    Canvas is an awt component meaning it is a heavyweight
    component. The swing components are lightweight.
    Thats the problem.
    Have a look at the following URL.
    http://java.sun.com/products/jfc/tsc/articles/mixing/
    It should explain about mixing heavyweight/lightweight
    components
    Basically you either need to use Frame, Menu and
    canvas or JFrame, JMenu and JPanel.
    nesAnd heres the important part:
    "When a lightweight component overlaps a heavyweight component, the heavyweight component is always on top,
    regardless of the relative z-order of the two components."
    Use JPanel instead of canvas if your using swing.
    regards,
    Tim

  • JMenu behind JDialog - Z-index problem

    I have an application which contains a JFrame with a JMenuBar (and submenus) and several JDialogs. I have tried almost everything, but I cannot find a way to make the menu stay on top. I have written a small class that illustrates this problem.
    public class TestFrame extends JFrame {
    public static void main(String[] args) {
    new TestFrame();
    public TestFrame() {
    super("Smart Frame");
    JPopupMenu.setDefaultLightWeightPopupEnabled(true);
    initialize();
    private void initialize() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().add(new JScrollPane(new JTable()));
    setJMenuBar(createMenuBar());
    pack();
    setVisible(true);
    createAndshowTestDialog();
    private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Menu");
    menu.add(new JMenuItem("MenuItem1"));
    menu.add(new JMenuItem("MenuItem2"));
    menu.add(new JMenuItem("MenuItem3"));
    menu.add(new JMenuItem("MenuItem4"));
    menu.add(new JMenuItem("MenuItem5"));
    JMenu item = new JMenu("MenuItem6");
    item.add(new JMenuItem("MenuItem6.1"));
    menu.add(item);
    menuBar.add(menu);
    return menuBar;
    private void createAndshowTestDialog() {
    JDialog dialog = new JDialog(this, "Dumb dialog");
    dialog.getContentPane().add(new JScrollPane(new JTable()));
    dialog.pack();
    dialog.setVisible(true);
    The first time everything is ok. The menu shows itself on top of the dialog. The second time the menu goes to the back when the submenu is triggered. It is frustrating
    Just to make things clear ... I want the menu always to be on top. :-)
    Help is much appreciated.

    Well ... I'm using jdk5.0 ... on mac osx 10.4.8
    Well it works for the non-submenu. When you select the submenu ... the submenu comes to front and stays on top of the dialog. The parent menu goes to the back.
    But it could be a mac issue .... I will test it on my ubuntu machine when I get home. Only macs in the office.

  • Problem with Alt , JMenu and Mnemonics

    I have built an application with a JMenuBar containing several JMenu's, the first of which is a File menu. All JMenus and JMenuItems have mnemonics associated with them. When I press the alt key the underlines show and focus appears to be given to the File menu (though it has not dropped down). If I then press a key, for example 'S', that is a mnemonic of the 'Save' jmenuitem in the File menu, the Save action is invoked. This should not occur because the menu has not opened yet.
    The behavior is what I'd expect had an accelerator (Alt+S) been defined for the Save menu item. But I have not defined any accelerators.
    Why does this happen and more importantly, is there a work around?

    Except for the 1st line in jbinit() it's all pretty standard stuff. Here's a snippet of the code:
    public class MainFrame extends JFrame implements ChangeListener {
    JMenuBar jMenuBar1 = new JMenuBar();
    JMenu jMenuFile = new JMenu();
    JMenuItem jMenuFileNew = new JMenuItem();
    JMenuItem jMenuFileSave = new JMenuItem();
    JMenu m_editMenu = new JMenu();
    JMenuItem m_editCutMenuItem = new JMenuItem();
    JMenuItem m_editCopyMenuItem = new JMenuItem();
    JMenuItem m_editPasteMenuItem = new JMenuItem();
    public MainFrame() {
    jbInit();
    //Component initialization
    private void jbInit() {
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    KeyStroke.getKeyStroke(KeyEvent.VK_ALT, Event.ALT_MASK, false), "repaint");
    // file menu
    jMenuFile.setText("File");
    jMenuFile.setMnemonic(KeyEvent.VK_F);
    jMenuFileNew.setText("New...");
    jMenuFileNew.setMnemonic(KeyEvent.VK_N);
    jMenuFileNew.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jMenuFileNewSpecial_actionPerformed(e);
    jMenuFileSave.setText("Save");
    jMenuFileSave.setMnemonic(KeyEvent.VK_S);
    jMenuFileSave.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jMenuFileSaveSpecial_actionPerformed(e);
    jMenuFile.add(jMenuFileNew);
    jMenuFile.add(jMenuFileSave);
    // edit menu
    m_editMenu.setText("Edit");
    m_editMenu.setMnemonic(KeyEvent.VK_E);
    m_editCutMenuItem.setText("Cut");
    m_editCutMenuItem.setMnemonic(KeyEvent.VK_T);
    m_editCutMenuItem.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    editCutMenuItem_actionPerformed(e);
    m_editCopyMenuItem.setText("Copy");
    m_editCopyMenuItem.setMnemonic(KeyEvent.VK_C);
    m_editPasteMenuItem.setText("Paste");
    m_editPasteMenuItem.setMnemonic(KeyEvent.VK_P);
    m_editMenu.add(m_editCutMenuItem);
    m_editMenu.add(m_editCopyMenuItem);
    m_editMenu.add(m_editPasteMenuItem);
    jMenuBar1.add(jMenuFile);
    jMenuBar1.add(m_editMenu);
    this.setJMenuBar(jMenuBar1);
    etc...
    Pressing Alt+S invokes the action listener for the jMenuFileSave menu item. It should do nothing since there is no top level menu with a mnemonic of 'S'.

  • Problem with JMENU / JTEXTAREA

    Hello All,
    I have the following problem:
    I want to create a little text editor. I just have a window containing
    a menu bar and a text area. The basic functions work fine. I can open a
    file and read it into the text area.
    The problem I have is, that my menu is affected by the file chooser window. When I close the file chooser parts of the selected file or the
    file chooser will be painted in my menu. In the worst case it deletes menu items.
    Does anybody knows help?
    Thank you in advance.
    Ralf

    It sounds like your program is busy doing something else after the filechooser closes, which is causing your GUI not to repaint. I assume you are performing some io on the file after the user click the OK button, that is probably whats causing it to not redisplay your menus. Or you could be getting an exception opening your file which usually causes the GUI to hang. If you not getting an exception and your sure your io code isn't infinite looping, then your best option to fix this is to run the io code in a separate thread.

  • Problem with JMenu

    I have a JMenu and When I click on a JItem a JPanel is displayed but while it is being charged (some seconds... ) a gray rectangle remains instead the JMenu ...
    do you know how to avoid this?

    Try putting the panel showing method/action in a SwingUtilities.invokeLater call
    ICE

  • JMenu causing image problems!

    I have Installed a JMenu that has an Image directly below , but! When i open the menu, The Text Value of the menu Disappears and the image has "Gray-Space"where the menu drop down was opened.
    Can anyone Help and tell me why this is happening and how to Solve?
    JMenuBar menuBar = new JMenuBar();
         JMenu menu = new JMenu("Setup");
         JMenuItem numOver = new JMenuItem("Input: # of Over's");
         JMenuItem numTarget = new JMenuItem("Input: Target");
    public Scorebook()
           menuBar.add(menu);
           menu.add(numOver);
          menu.add(numTarget);}

    Thanx for the pointer, wasnt sure on what i needed to add in code: heres the ClassLoader and ImageIcon
    as for Setting Visability, i dont think i have set it i just tried menu.setVisable(true) but it didnt like it!
    ClassLoader ldr = this.getClass().getClassLoader();
         java.net.URL cbURL = ldr.getResource("cricketball.png");
         ImageIcon cBall = new ImageIcon(cbURL);
         JLabel cBallL = new JLabel(cBall);
    JMenuBar menuBar = new JMenuBar();
         JMenu menu = new JMenu("Setup");
         JMenuItem numOver = new JMenuItem("Input: # of Over's");
         JMenuItem numTarget = new JMenuItem("Input: Target");
    public Scorebook()
           menuBar.add(menu);
           menu.add(numOver);
           menu.add(numTarget);}
           pnl.add(CBallL);

Maybe you are looking for

  • Error while publishing service definition in Services Registry

    I created a service interface in ESR and published the WSDL to my Services Registry. Now when I go to the "Publish" tab in the Services Registry to provide a definition for this service, after entering the WSDL and clicking on "Next" I get a pop-up f

  • Idoc import

    Hi, IDOC with same basic type will overwrite with each other when we import from SAP to XI? Eventh the extension type and Idoc type are different.

  • Classical Music podcasts anyone

    Anyone recommend well-produced, up-to-date, informative and frequent podcasts for Classical music, both 'early' (1000 - 1750) and contemporary (1945 and after), please?

  • NAC 4.1.3

    Hello Friends, I have setup a New NAC 4.1.3. when users login they get the popup of certificate to press the YES button, i have generated the certificate in manager and server as per the user guide, where i m missing something???? i think something i

  • US elimiation

    HI friends, i'm working on US elimination. Dim: ENTITY , is it mandatory  to maintain INTCO property for each of entity. Eg: two entities E_US,E_UK in ENTITY Dim and I_US,I_UK are ids of INTCO dim. Usually in INTCO dim, for each intco member id (I_US