The Artima Developer Community
Sponsored Link

Java Answers Forum
Action on JTabbedPane

2 replies on 1 page. Most recent reply: Jun 15, 2003 10:39 PM by guillaume

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
guillaume

Posts: 21
Nickname: salulezami
Registered: May, 2003

Action on JTabbedPane Posted: Jun 13, 2003 4:20 AM
Reply to this message Reply
Advertisement
Hello world,

I would like to know How can I get the following event :
"User change of active Tab in a JTabbedPane"

It'll help me so... thanks a lot..


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: Action on JTabbedPane Posted: Jun 13, 2003 7:20 PM
Reply to this message Reply
> Hello world,
>
> I would like to know How can I get the following event :
> "User change of active Tab in a JTabbedPane"
>
> It'll help me so... thanks a lot..

You will have to register changeListener with your JTabbedPane.

eg.

if you have a JTabbedPane _tabbedPane, after instantiating, you add a changeListener to _tabbedPane...

_tabbedPane.addChangeListner(new YourChangeListener());

-------

now, this class called YourChangeListener, will get notifications if a diffrent tab is selected.

the definition of the class will look like this:
public class YourChangeListener implements ChangeListener{
 
//you will also need a method called stateChanged
 
    public void stateChanged(ChangeEvent changeEvent) {
        JTabbedPane sourceTabbedPane = (JTabbedPane)changeEvent.getSource();
        int index = sourceTabbedPane.getSelectedIndex();
        System.err.println("Currently selected tab no. is : "+index);
    }

}

guillaume

Posts: 21
Nickname: salulezami
Registered: May, 2003

Re: Action on JTabbedPane Posted: Jun 15, 2003 10:39 PM
Reply to this message Reply
Thanks a lot my love...

Flat View: This topic has 2 replies on 1 page
Topic: Very convenient programs on <a href="http://www.blotsoft.com/">http://www.blotsoft.com/</a> Previous Topic   Next Topic Topic: how do you create a shortcut to run a java program on windows desktop?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use