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

tabbedpane ignorant  RSS feed

 
Juan Matos
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello java folks.
Could someone please help me? I want to run some code when a user clicks a tab in a tabbed pane. Do I have to add a listner to the tabbed pane? If so, can someone give me code snippet example. Then how do I run a method when the click occurs.
-Juan Matos
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
Sascha Herrmann
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implement in a class the javax.swing.event.ChangeListener interface and add an instance of that class to the tabbed pane's change listeners.
To implement the interface you'll have to implement the stateChanged( ChangeEvent event ) method where you can react to the user's action.
 
Sascha Herrmann
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like this:

[ January 20, 2004: Message edited by: Sascha Herrmann ]
 
Juan Matos
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Sascha. I have just read your post reply but haven't tried it. I'll be able to try the code tommorow but wanted to let you know how much I appreciate your help right now. Thanks a million.
-Juan
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!