Dmitriy
asked on
TabbedPane exit
Could someone show me how to make a Tab that says "Exit" and when you click on it, it exits the program?
ASKER
Adjusted points to 50
ASKER
How do I import ChangeListener? I get a message that the interface not found.
Here is what I have so far... I made two tabs that have different properties. One of them has name Exit.
tabbedPane.addTab("Exit",n ull,panel3 , "Exit");
where panel3 is Component type, which will have a function Exit(). This function will have to have the necessary code to exit the program. Is it possible to make it in form of a function instead of a separate class?
Here is what I have so far... I made two tabs that have different properties. One of them has name Exit.
tabbedPane.addTab("Exit",n
where panel3 is Component type, which will have a function Exit(). This function will have to have the necessary code to exit the program. Is it possible to make it in form of a function instead of a separate class?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if jtp is a JTabbedPane, add the change listener like this
class aa implements ChangeListener{
public aa(){
///code
jtp.addChangeListener (this);
///code
}
public void stateChanged(ChangeEvent e){
System.out.println (" change occurred at " + jtp.getSelectedIndex ());
// Get the index of the tab say(1)
if(jtp.getSelectedIndex ()==1){
System.exit (0);
}
}