This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create a tab that invokes a method on press

 
Tom Josephits
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"?
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic