Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By Apprentice123

Thread: MenuBar

  1. #1
    Apprentice123 is offline Member
    Join Date
    Jul 2012
    Posts
    20
    Rep Power
    0

    Default MenuBar

    Hi, I create a menubar:

    Java Code:
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    JMenu CadastreMenu = new JMenu("Cadastre");
    menuBar.add(CadastreMenu);
    JMenuItem client = new JMenuItem("Client", iconClient);
    CadastreMenu.add(client);
    
    client.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              new Client().setVisible(true);
          }
    });
    I have a Jframe Client, but when i click on submenu client not open my Jframe Client

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: MenuBar

    I don't think that the cause of your problem can be deduced from the data that has been presented so far. You may need to tell and show us more.

  3. #3
    Apprentice123 is offline Member
    Join Date
    Jul 2012
    Posts
    20
    Rep Power
    0

    Default Re: MenuBar

    Quote Originally Posted by Fubarable View Post
    I don't think that the cause of your problem can be deduced from the data that has been presented so far. You may need to tell and show us more.
    The problem is that when I click on menubar client open a new JFrame but not open my client JFrame.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: MenuBar

    Quote Originally Posted by Apprentice123 View Post
    The problem is that when I click on menubar client open a new JFrame but not open my client JFrame.
    I understand the misbehavior, but what I'm saying is that short of reading your mind and our being able to magically see code not shown, there's no way we can guess what you're doing wrong based on the little bit you've posted so far.

  5. #5
    Apprentice123 is offline Member
    Join Date
    Jul 2012
    Posts
    20
    Rep Power
    0

    Default Re: MenuBar

    Quote Originally Posted by Fubarable View Post
    I understand the misbehavior, but what I'm saying is that short of reading your mind and our being able to magically see code not shown, there's no way we can guess what you're doing wrong based on the little bit you've posted so far.
    Thanks. I find my problem.
    I forgot to call initComponents() in Client.java


  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: MenuBar

    Quote Originally Posted by Apprentice123 View Post
    Thanks. I find my problem.
    I forgot to call initComponents() in Client.java
    Good, I'm glad you've solved your problem. But you see the problem I was having? There was absolutely no way that I could have guessed this based on the limited information presented. When asking questions here (or anywhere), you'll want to take pains to give enough information so that folks will have a chance of being able to help. Assume that we know nothing about your program and that we can't read minds, ask your question as if you were in our shoes, and we'll all do better here.

  7. #7
    Apprentice123 is offline Member
    Join Date
    Jul 2012
    Posts
    20
    Rep Power
    0

    Default Re: MenuBar

    Quote Originally Posted by Fubarable View Post
    Good, I'm glad you've solved your problem. But you see the problem I was having? There was absolutely no way that I could have guessed this based on the limited information presented. When asking questions here (or anywhere), you'll want to take pains to give enough information so that folks will have a chance of being able to help. Assume that we know nothing about your program and that we can't read minds, ask your question as if you were in our shoes, and we'll all do better here.
    Yes I understand. I was posting the code when I found my mistake.
    Fubarable likes this.

Similar Threads

  1. runtime MenuBar Generator
    By vishrut_n_shah in forum AWT / Swing
    Replies: 5
    Last Post: 10-31-2011, 07:46 AM
  2. Vertical menubar
    By Java Unknown in forum New To Java
    Replies: 0
    Last Post: 02-22-2011, 05:50 AM
  3. About MenuBar
    By makpandian in forum AWT / Swing
    Replies: 1
    Last Post: 03-20-2009, 11:50 AM
  4. Help about Java Menubar
    By makpandian in forum AWT / Swing
    Replies: 5
    Last Post: 02-09-2009, 08:17 AM
  5. menubar in splitpane
    By masa in forum AWT / Swing
    Replies: 1
    Last Post: 12-16-2008, 09:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •