Solved

JTabbedPane - updating data in each tab

Posted on 2000-05-10
2
275 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 65 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now