The Artima Developer Community
Sponsored Link

Java Answers Forum
JTabbedPane..

2 replies on 1 page. Most recent reply: Apr 1, 2002 2:17 PM by Kishori Sharan

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
Maysoon

Posts: 64
Nickname: hm
Registered: Mar, 2002

JTabbedPane.. Posted: Mar 30, 2002 12:07 PM
Reply to this message Reply
Advertisement
hi all..

how can i do actionperformed on JTabbedpane?
i mean when i click on on of these tabbed i want an event to
be occured other than to get layout?

please help
thanks..


Maysoon

Posts: 64
Nickname: hm
Registered: Mar, 2002

Re: JTabbedPane.. Posted: Apr 1, 2002 11:33 AM
Reply to this message Reply
hi all

is this question difficult ??????
no one reply..

Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: JTabbedPane.. Posted: Apr 1, 2002 2:17 PM
Reply to this message Reply
It was really very tough question. It took me more than three days to figure it out!!!!!!
I think you can add a ChangeListener to JTabbedPane and you are notified when you select a tab page.

Thanks
Kishori
///////////////////
import java.awt.* ;
import javax.swing.* ;
 
public class FrameTest extends JFrame {
	JButton b1 = new JButton ( "Hello 1" ) ;
	JButton b2 = new JButton ( "Hello 2" ) ;
	JTabbedPane tab = new JTabbedPane() ;
	JPanel p1 = new JPanel ( ) ;
	JPanel p2 = new JPanel ( ) ;
	public FrameTest () {
		setBounds ( 20, 20 , 300, 300 ) ;
		
		p1.add ( b1 ) ;
		p2.add ( b2 ) ;
						
		tab.addTab ( "Tab 1", p1 );
		tab.addTab ( "Tab 2", p2 );		
		
		getContentPane().add ( tab , "Center" ) ;
		
		// Add change lister to your tab so that you get notified
		// when you click on any tab page
		tab.addChangeListener ( new javax.swing.event.ChangeListener ( ) {				         
				public void stateChanged( javax.swing.event.ChangeEvent e) {
					System.out.println ( "selected Index:" + tab.getSelectedIndex ( ) ) ;
				}
		
		}
		) ;
		
	}
	
	public static void main ( String[] args ) {
		FrameTest f = new FrameTest () ;
		f.show ( ) ;
	}
}

Flat View: This topic has 2 replies on 1 page
Topic: Please help Previous Topic   Next Topic Topic: Banner which displays Three Images

Sponsored Links



Google
  Web Artima.com   

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