• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Create a tab that invokes a method on press

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic