?
Solved

JTabbedPane - updating data in each tab

Posted on 2000-05-10
2
Medium Priority
?
311 Views
Last Modified: 2011-09-20
i'm working on a newsgroups application , using a server and a client.
on the client side i use JTabbedPane.
each Tab has some option : like displaying the groups in a list ,delete a list etc..
i want to updated the data of a tab each time the user clicks the tab(by calling a method connect to the server.
how di i do that?
0
Comment
Question by:itzikb
2 Comments
 

Expert Comment

by:MoRs
ID: 2799511
Hi, get the model of your TabbedPane by calling getModel() method, then register ChangeListener to this model. Code would like smth like this:

JTabbedPane tabs = new JTabbedPane();
//form your tabs
tabs.getModel().addChangeListener(new ChangeListener()
{
   public void stateChanged(ChangeEvent e)
   {
      //do smth what you need
   }
})
0
 

Accepted Solution

by:
skipper051100 earned 260 total points
ID: 2800202

add a ChangeListener to the JTabbedPane object:


1.make this class implement changeListener
2  register change listener with tabs
    tabs.addChangeListener ( this );
3. implement ChageListener methods - there is one

  public void stateChanged ( ChangeEvent e )
 {
    if ( e.getSource ( ) == tabs ) {
     //call server method
   }
 }
  //probably no need to do a check though
 
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question