• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Swing - Display table in sub menu

 
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?
 
Rancher
Posts: 3051
22
  • 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.

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!