Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTabbedPane - listeners?  RSS feed

 
Inuka Jayasekera
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm having problems with adding listeners to my JTabbedPanes.
Basically, i have 5 tabs and each one contains a JPanel. what i need is the JPanel to be updated every time the user selects the corresponding tab, as information input in one tab effects the output in the others. Please can someone help me with what listeners to use for the JTabbedPanes??
any help would be GREATLY APPRECIATED!!
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Inuka.
Listeners supported by Swing components tells us that a ChangeListener can be added to a JTabbedPane. When the selected tab changes, such listener receives a ChangeEvent. ChangeEvent.getSource() can be used to get a reference to the JTabbedPane and obtain the selected index or component by JTabbedPane.getSelectedIndex/getSelectedComponent. Then, modify that component.
Alternatively, attach listeners to the components that receive the input on which the other tabs depend on; and modify the JPanels accordingly before the user changes the tab.
 
Inuka Jayasekera
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks... problem sorted, that was huge great help!!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!