Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Swing - Display table in sub menu

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3280
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic