Switch to full style
Graphics and animation Java code examples
Post a reply

Run different function based on the selected Tab JTabbedPane

Fri Feb 01, 2013 1:15 am

This example show how to run different scenario based on the selected Tab using getSelectedIndex() function of JTabbedPane class.
java code
// Add Button.
AddBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{


switch(Tabbed.getSelectedIndex())
{
case 0:((new VisitorPanel(conn,myMother))).show();break;
case 1:(new BookPanel(conn,myMother)).show();break;
case 2:(new AuthorPanel(conn,myMother)).show();break;
case 3:(new PublisherPanel(conn,myMother)).show();break;
case 4:(new BookStorePanel(conn,myMother)).show();break;

default :break;
}

}
});
// Search Button
SearchBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {


switch(Tabbed.getSelectedIndex())
{
case 0:(new VisitorSearch(conn,myMother)).show();break;
case 1:(new BookSearch(conn,myMother)).show();break;
case 2:(new AuthorSearch(conn,myMother)).show();break;
case 3:(new PublisherSearch(conn,myMother)).show();break;
case 4:(new BookStoreSearch(conn,myMother)).show();break;

default :break;
}


}
});
// Edit Button
ModifyBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {



switch(Tabbed.getSelectedIndex())
{
case 0:(new VisitorModifyPanel(conn,myMother)).show();break;
case 1:(new BookModifyPanel(conn,myMother)).show();break;
case 2:(new AuthorModifyPanel(conn,myMother)).show();break;
case 3:(new PublisherModifyPanel(conn,myMother)).show();break;
case 4:(new BookStoreModifyPanel(conn,myMother)).show();break;

default :break;
}

}
});




Post a reply
  Related Posts  to : Run different function based on the selected Tab JTabbedPane
 JTabbedPane usage example     -  
 Dropdown list in ASP.NET - How to get value selected     -  
 The selected attachment does not exist anymore     -  
 Reading selected data from a source file     -  
 Cookie based login in php     -  
 Takes a string apart based on a delimiter     -  
 prapose me a web based mini project     -  
 Home Based Research Jobs.     -  
 what is the query to retrieve to student data based on least     -  
 Simple Text-Based RPG Java Project Help!     -  

Topic Tags

Java Swing