Solved

JTabbedPane - updating data in each tab

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

707 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

15 Experts available now in Live!

Get 1:1 Help Now