• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing - Display table in sub menu

 
Stephanie Johnson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a menu that displays say

Item1
Item2
Item3
Item 4

etc. Clicking on Item1 should display me a Table with 2 columns.
I looked at JMenu and JMenuItem classes, tried various methods. But I cant make it work.
Can somebody help me please?
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I cant make it work.


That does not describe the problem.

Is the problem that you don't know how to use a JMenuItem? Do you know how to add an ActionListener to a menu item? Do you know how to create a table? Are you trying to create a popup JDialog to display the table or are you trying to add the JTable to an existing panel in the GUI?

There is no way we can help you because you question is so vague.

All I can suggest it to read the JMenuItem API or the JTable API and you will find links to the Swing tutorial that given examples of using menu items and tables.

Then is you have further questions you can post a SSCCE with the question showing the problems you are having.

 
Stephanie Johnson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried something below with displaying just a label. But the label gets displayed somewhere in the screen where as I am expecting it to be a submenu under menuitem1.

 
Darryl Burke
Bartender
Posts: 5153
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recommended reading: http://download-llnw.oracle.com/javase/tutorial/uiswing/index.html

And of course the SSCCE link that Rob posted. It's clear you haven't even glanced at the page.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!