File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Menu based on text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Menu based on text" Watch "Menu based on text" New topic
Author

Menu based on text

Lovro Posaric
Greenhorn

Joined: Jul 01, 2012
Posts: 11

Hi!
I want to make menu on left side of frame, buttons'd be text...when clicked they'd open submenu and after that new jframe/panel...Hope you know what I want...
I read lots of examples but they wasn't what I wanted..most of them was on upper side..opening while clicked(I want it to be there opened all time while program is running)...
Please answer!
Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Well, of course your "menu" can't be a JMenu because that automatically goes at the top of the frame with dropdowns and so on, and you said you didn't want that.

But you can still create a JPanel whose layout manager splits it into two parts vertically. In the left part is where you want your menu buttons, correct? So in the left pane you would use a layout manager which arranged your menu buttons in a vertical list. Although you mentioned "submenus", so maybe you should have a JTree there with your menu options.

At any rate you should go through the Swing tutorial, especially the parts which cover the common layout managers, so you have a better idea of what things are possible.
Lovro Posaric
Greenhorn

Joined: Jul 01, 2012
Posts: 11


In the left part is where you want your menu buttons, correct?

Yes and no, I want them look like just text that is clickable..I mean, when you click on it, it opens some window or so...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
You probably still want buttons, then. But see if you can take the borders off the buttons, so only the text remains visible.
Lovro Posaric
Greenhorn

Joined: Jul 01, 2012
Posts: 11

Thanks for answers!

this worked, but when I click on button it becomes blue(eclipse's default) until cursor is on it...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Menu based on text