I'm Having a problem with trying to figure out how to get my program to switch from one tab to another after a specific "Jbutton" is clicked. As displayed Below.

The Picture

I also need help with regards to linking a checkbox with boolean column in the derby database on a netbeans platform.

Hi Clif40RD!

Pleae post your code, what you have tried, that will help to understand your level..,

Oh my programming is that of a low level, believe me, final year of high school level. the only reason why I posted this question is because I didn't have an idea of where to start...but I tried this.

tblStaff.setVisible(true);
 this.setVisible(false);
 pnlStaff.setVisible(false);
 tblStaff.setSize(820, 770); 

I also tried setting the panel I placed within the Jtabbed form to true but that didn't work either.

Assuming you asre using a JTabbedPane (if not, you should be), you can learn how to respond to a button click here
http://docs.oracle.com/javase/tutorial/uiswing/components/button.html
and how to work with tabbed panes here
http://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html

Look for how to add an action listener to the button, and how to switch to a specific tab programmatically.

Oh thanks I hope it helps though.

public void setSelectedComponent(Component c)
Sets the selected component for this tabbedpane. This will automatically set the selectedIndex to the index corresponding to the specified component.
Throws:
IllegalArgumentException - if component not found in tabbed pane
See Also:
getSelectedComponent()

Thats the code I got that looks like it will work but I'm not sure on how exactly to use it especially with regards to the last ''getSelectedComponent()what should I put inside the bracket? According to me, the tab number, but ofcourse on the other hand, even I know thats not going to work.

You will probably find it easier to use the next method
public void setSelectedIndex(int index)
where index is 0 for the first tab, 1 for the second etc

To be honest Right now Im lost, I don't know how to use any of the methods.

To be brutally honest, it seems like you're not ready to tackle a compicated GUI program yet. You'll get far better long-term results by going back and learning the basics first.

If I had the time to go back I would but I don't I'm busy with a project thats due on the upcoming Monday and I'm struggling not because I don't pay attention in class but instead due to insuffiient teaching and to make matters even worse the same educator left...So like can you execute the code that which I required? or not?.

Sorry to hear about your trouble learning Java. Programming should be fun and it can be, but if you fall behind or if a project is assigned that you aren't ready for yet, it gets frustrating. If you like this stuff and get into it, you can learn it well with or without a teacher. The most important thing is to NOT GIVE UP. Be methodical about what you are working on and force yourself to do (and learn) one thing at a time.

Post ALL your code. Add comments before your methods explainine what you want to do. Forget about what you don't understand for a minute and write down what you want to do in plain English as a comment before every method you wrote. Then post everything.
Getting a button to switch tabs only takes a few lines of code.

Which IDE are you using?

Thank you I really appreciate that...But I really don't have time for long cuts at the moment on my side of the world its 11:05 PM.The thing is I have been trying and not giving up for a very long actually being here trying to gather information is one of the ways in which I am doing so and I'm here trying to 2 to do more than one thing because my time is really limited.I'm using Netbeans IDE 8.0.

public class DatabaseForm extends javax.swing.JFrame {
    //Objects
    Animals animal;
    Staff staffs;
   ListIterator<Staff>iterator;
  ListIterator<Animals>iterator1;





  /**
     * Creates new form DatabaseForm
     */
    public DatabaseForm()
    {
    initComponents();
    }
//Declared For Responses In data changes
public void setStaffs(Staff staffs)
{
Staff oldStaffs = this.staffs;
this.staffs = staffs;
    firePropertyChange("staffs", oldStaffs, staffs);
}        
 public void setAnimal(Animals animal)       
 {     
 Animals oldAnimal = this.animal; 
 this.animal = animal;
 firePropertyChange("animal", oldAnimal, animal);
 }       
 int q = 0;
int chance = 0;
String logged = "";
String user[] = new String[100];
String pass[] = new String[100];
String job[] = new String[100];
    private void btnAddanimalActionPerformed(java.awt.event.ActionEvent evt) {                                             

        // TODO add your handling code here:
    }                                            
//User Login
    private void btnConfirmActionPerformed(java.awt.event.ActionEvent evt) {                                           
try
       {
           BufferedReader br = new BufferedReader(new FileReader("user.txt"));
           user[q] = br.readLine();
           while(user[q]!=null)
           {
               pass[q] = br.readLine();
               job[q] = br.readLine();
               q++;
               user[q] = br.readLine();
           }
       }

       catch(Exception e)
       {
       JOptionPane.showMessageDialog(null,"" +e);
       } 

        chance++;
       if(chance<3)
       {
        String use = txtUser.getText();
        String pas = Passw.getText();
        for (int i = 0; i < q; i++) {


        if(use.equalsIgnoreCase(user[i])&&pas.equals(pass[i])&&job[i].equals("Administrator"))
        {
           i=q;
            chance = 0;
            txtLogged.setText("Logged in as:"+use); 
             txtLogged.setEditable(false); 
            txtLogged1.setText("Logged in as:"+use);
             txtLogged1.setEditable(false); 
            txtLogged2.setText("Logged in as:"+use);
            txtLogged2.setEditable(false); 
            txtLogged3.setText("Logged in as:"+use);
            txtLogged3.setEditable(false); 
            txtLogged4.setText("Logged in as:"+use);
            txtLogged4.setEditable(false); 
            JOptionPane.showMessageDialog(null, "Welcome Administrator");
             String Screen = JOptionPane.showInputDialog(null,"Which Screen Would You Like To Be Directed To?");
            if(Screen.equalsIgnoreCase("Animal Cruelty"))   
     { 
       AnimalCruelty.setVisible(true);
        this.setVisible(false);
         AnimalCruelty.setSize(820, 601);
     }     
        if(Screen.equalsIgnoreCase("Animals"))  
{        
    Animals.setVisible(true);
        this.setVisible(false);
         Animals.setSize(820, 770);  
}   
            if(Screen.equalsIgnoreCase("Staff"))  
{        
    Staff.setVisible(true);
        this.setVisible(false);
         Staff.setSize(835, 670);
}         
   if(Screen.equalsIgnoreCase("Fundraising"))  
{        
    Fundraising.setVisible(true);
        this.setVisible(false);
         Fundraising.setSize(820, 525);
}     



if(Screen.equalsIgnoreCase("Branches"))  
{        
    Branches.setVisible(true);
        this.setVisible(false);
         Branches.setSize(800, 560);  
}                 
 }            

       else if(use.equalsIgnoreCase(user[i])&&pas.equals(pass[i])&&job[i].equals("Financial_Administrator"))
        {
           i=q;
            chance = 0;    
            txtLogged.setText("Logged in as:"+use); 
            txtLogged.setEditable(false); 
            txtLogged1.setText("Logged in as:"+use);
            txtLogged1.setEditable(false); 
            txtLogged2.setText("Logged in as:"+use);
            txtLogged2.setEditable(false); 
            txtLogged3.setText("Logged in as:"+use);
            txtLogged3.setEditable(false); 
            txtLogged4.setText("Logged in as:"+use);
            txtLogged4.setEditable(false); 
            JOptionPane.showMessageDialog(null, "Welcome Financial Administrator");
             String Screen = JOptionPane.showInputDialog(null,"Which Screen Would You Like To Be Directed To?");
            if(Screen.equalsIgnoreCase("Animal Cruelty"))   
     { 
       JOptionPane.showMessageDialog(null,"Access Denied, You Have No Permissions To Access Such Information");
    }
if(Screen.equalsIgnoreCase("Animals"))  
{        
     JOptionPane.showMessageDialog(null,"Access Denied, You Have No Permissions To Access Such Information");
}   


if(Screen.equalsIgnoreCase("Staff"))  
{        
Staff.setVisible(true);
        this.setVisible(false);
         Staff.setSize(835, 670);
        }     

if(Screen.equalsIgnoreCase("Fundraising"))  
{        
  Fundraising.setVisible(true);
        this.setVisible(false);
         Fundraising.setSize(820, 525);
 }     



if(Screen.equalsIgnoreCase("Branches"))  
{        
    JOptionPane.showMessageDialog(null,"Access Denied, You Have No Permissions To Access Such Information");
}         
        }                              

       else if  (use.equalsIgnoreCase(user[i])&&pas.equals(pass[i])&&job[i].equals("Staff"))           
       {      
          i=q;
            chance = 0;    
            txtLogged.setText("Logged in as:"+use); 
            txtLogged.setEditable(false); 
            txtLogged1.setText("Logged in as:"+use);
           txtLogged1.setEditable(false); 
            txtLogged2.setText("Logged in as:"+use);
            txtLogged2.setEditable(false); 
            txtLogged3.setText("Logged in as:"+use);
            txtLogged3.setEditable(false); 
            txtLogged4.setText("Logged in as:"+use);  
           txtLogged4.setEditable(false); 
            JOptionPane.showMessageDialog(null, "Welcome Staff Member");
   String Screen = JOptionPane.showInputDialog(null,"Which Screen Would You Like To Be Directed To?");
     if(Screen.equalsIgnoreCase("Animal Cruelty"))   
     { 
       AnimalCruelty.setVisible(true);
        this.setVisible(false);
         AnimalCruelty.setSize(820, 601);
    }
if(Screen.equalsIgnoreCase("Animals"))  
{        
    Animals.setVisible(true);
        this.setVisible(false);
         Animals.setSize(820, 770); 
}   


if(Screen.equalsIgnoreCase("Staff"))  
{        
    JOptionPane.showMessageDialog(null,"Access Denied, You Have No Permissions To Access Such Information");
}     

if(Screen.equalsIgnoreCase("Fundraising"))  
{        
 JOptionPane.showMessageDialog(null,"Access Denied, You Have No Permissions To Access Such Information");  
}     



if(Screen.equalsIgnoreCase("Branches"))  
{        
    JOptionPane.showMessageDialog(null,"Access Denied, You Have No Permissions To Access Such Information");
}         
       }             
   else
        {
           JOptionPane.showMessageDialog(null,"Wrong username and password");
        }
       }//for
       }//if - chance
       else
       {
           JOptionPane.showMessageDialog(null,"Too many wrong attempts");
           System.exit(0);
       }           








// TODO add your handling code here:
    }                                          

    private void btnStaffViewActionPerformed(java.awt.event.ActionEvent evt) {                                             


// TODO add your handling code here:
    }                                            
//Insert New Record Into Database
    private void btnSave1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
Staff mbs = new Staff(); 
mbs.setIdNo(txtStaffid.getText());
mbs.setName(txtStaffname.getText());
mbs.setSurname(txtStaffsir.getText());
mbs.setAddress(txtStaffaddr.getText());
mbs.setCellphone(txtStaffcell.getText());
mbs.setSalary(Integer.parseInt(txtStaffsalary.getText()));
String status = txtFrequency.getText();
if(status.equalsIgnoreCase("Weekly") )
{
mbs.setWeekly(true);
mbs.setMonthly(false);
mbs.setDaily(false);
}
else if(status.equalsIgnoreCase("Monthly") )
{
mbs.setWeekly(false);
mbs.setMonthly(true);
mbs.setDaily(false);
}
else
{
mbs.setWeekly(false);
mbs.setMonthly(false);
mbs.setDaily(true);
}
CliftonSteenkampPatPUEntityManager.getTransaction().begin();
CliftonSteenkampPatPUEntityManager.persist(mbs);
CliftonSteenkampPatPUEntityManager.getTransaction().commit();



// TODO add your handling code here:
    }                                        

    private void btnFrequencyActionPerformed(java.awt.event.ActionEvent evt) {                                             
txtFrequency.setText(cbFrequency.getSelectedItem().toString());
// TODO add your handling code here:
    }                                            

    private void btnImportantActionPerformed(java.awt.event.ActionEvent evt) {                                             
JOptionPane.showMessageDialog(null,"Please Ensure That you Fill In The 'Frequency Of Payment' Text Field Before Clicking"
        + "The 'Frequency Of Payment' Button ");        // TODO add your handling code here:
    }                                            
//Search Record
    private void btnSearchStaffActionPerformed(java.awt.event.ActionEvent evt) {                                               
iterator = staffList.listIterator(0);
String Search1 = JOptionPane.showInputDialog(null,"Enter Staff Members ID Number");
boolean found = false;
        for (int i = 0; i < staffList.size(); i++) 
        {
            setStaffs(iterator.next());
           if(staffs.getIdNo().equalsIgnoreCase(Search1))        
           {        
        found  = true;
         break;  


          }
        }
if(found==false)
{
JOptionPane.showMessageDialog(null,"Invalid Staff ID Number");
}






// TODO add your handling code here:
    }                                              
//Delete Record
    private void btnDeletestaffActionPerformed(java.awt.event.ActionEvent evt) {                                               
try
{       

String Staffid = JOptionPane.showInputDialog("Please Enter The ID Number Of the staff Member You Wish To Delete");
Staff mbs = CliftonSteenkampPatPUEntityManager.find(Staff.class,Staffid);
CliftonSteenkampPatPUEntityManager.getTransaction().begin();
CliftonSteenkampPatPUEntityManager.remove(mbs);
CliftonSteenkampPatPUEntityManager.getTransaction().commit();
CliftonSteenkampPatPUEntityManager.clear();
iterator = staffList.listIterator();
setStaffs(iterator.next());
staffList.clear();
staffList.addAll(staffQuery.getResultList());
JOptionPane.showMessageDialog(null,"The record has successfully been deleted");
}




catch(Exception e)
{
System.out.println(e);
}

// TODO add your handling code here:
    }                                              

    private void txtInfectionsActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:
    }                                             

    private void btnImportant2ActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:       

I would like to know, how do I display a specific record, That is in Message Dialog form, after a successful search by the user heres what I got so Far:

iterator = staffList.listIterator(0);
String Search1 = JOptionPane.showInputDialog(null,"Enter Staff Members ID Number");
boolean found = false;
        for (int i = 0; i < staffList.size(); i++) 
        {
            setStaffs(iterator.next());
           if(staffs.getIdNo().equalsIgnoreCase(Search1))        
           {        
        found  = true;
         break;  


          }
        }
if(found==false)
{
JOptionPane.showMessageDialog(null,"Invalid Staff ID Number");
}

You need to store the Staff object as you search for it. An easier way to do this is with an enhanced for loop which uses Iterators for you, but they are hidden.

    Staff displayMe = null;
    boolean found = false;
    for (Staff s : staffList) {
        if(s.getIdNo().equalsIgnoreCase(Search1)) {        
           found  = true;
           displayMe = s;
         }
     }
     //now you have the Staff object you want to display if found.
     //just for testing purposes, start with this:
     System.out.println(displayMe);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.