aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Create a tab that invokes a method on press Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Create a tab that invokes a method on press" Watch "Create a tab that invokes a method on press" New topic
Author

Create a tab that invokes a method on press

Tom Josephits
Ranch Hand

Joined: Mar 11, 2012
Posts: 31
Basically, I need for my GUI, a way to add a tab on the top of a component that will invoke a method when pressed with a contianer.

One way I though of was to make a button and use the layout to add it on top of the other component, but I don't know how I would get it to act like a tab.

Another idea I had was to add a JTabbedPane and use that for the GUI, but then I don't know how I would get it to do a function rather than switch to something else.
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

I didn't really understand your request. Can you please post some code to demonstrate the problem? What's wrong with the approach of using JTabbedPane, if you want a "button that acts like a tab"?


The quieter you are, the more you are able to hear.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10246
    
    8

I am with Kemal Kemal . JTabbedPane is the way to go if you want tabbed behavior. Why reinvent the wheel?

If you are still insistent on
Tom Josephits wrote:
One way I though of was to make a button and use the layout to add it on top of the other component, but I don't know how I would get it to act like a tab.

Check out CardLayout. Of course you will not inherit the visual clues on the UI that it is a tabbed behavior.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create a tab that invokes a method on press