Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with submenus  RSS feed

 
Stephen Murray
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new to using Swing components and I have a quick question. I want to do a submenu within a project I am working on, for example, in eclipse when you click Search in the menu bar, Text (submenu) and choose from the options presented. When an option is selected the menu panels are unselected and it application processes your request. I have tried using JList within the submenu as I do not see what other components could would but upon selection the list does not disappear. I have it set to single selection. Maybe I am totally off with my approach but I would appreciate it if someone could give me some advice.

Thanks.
 
K. Tsang
Bartender
Posts: 3628
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

When you talk about submenus, are you referring to the ones in the menu bar? Or in a panel or another component?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should consider looking at the code in the Oracle tutorial about Swing menus: How to Use Menus.

In fact any time you're starting out with Technology X in Java and you don't know how to get started, you should read the Oracle tutorial about X. The Google keywords to find it are Java X tutorial.
 
Stephen Murray
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Welcome to the Ranch.

When you talk about submenus, are you referring to the ones in the menu bar? Or in a panel or another component?


Thank you, yes in the menu bar. I have several JMenus added to the menu bar and one of those JMenus has another JMenu added to make it a submenu. I have a JLIst in that submenu populated with 10 items. When I selected one I want the screen to disappear, at present once I select an item from the JList it remains showing. Any advice?
 
Stephen Murray
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:You should consider looking at the code in the Oracle tutorial about Swing menus: How to Use Menus.

In fact any time you're starting out with Technology X in Java and you don't know how to get started, you should read the Oracle tutorial about X. The Google keywords to find it are Java X tutorial.


Thanks, found what I was looking for in that link you sent.
 
K. Tsang
Bartender
Posts: 3628
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephen Murray wrote:
K. Tsang wrote:Welcome to the Ranch.

When you talk about submenus, are you referring to the ones in the menu bar? Or in a panel or another component?


Thank you, yes in the menu bar. I have several JMenus added to the menu bar and one of those JMenus has another JMenu added to make it a submenu. I have a JLIst in that submenu populated with 10 items. When I selected one I want the screen to disappear, at present once I select an item from the JList it remains showing. Any advice?


A JList is then not necessarily. The submenu itself is a JMenu and the items under that are JMenuItems. The tutorial will make it clearer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!