Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java tabs

  • 19-04-2008 5:51pm
    #1
    Registered Users, Registered Users 2 Posts: 538 ✭✭✭


    Hello,
    I have written a java program that can enter a new customer into a MSSQL DB. I was thinking of creating a simular program that enters products into the DB and was wondering how i could create a tab so they are on one application but do diffrent functions. can anyone help

    [PHP]import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    class DB_NewCustomers extends JFrame
    {
    String mySqlString = "INSERT INTO Customer VALUES('";

    //declare the objects we need
    JPanel myJPanel1 = new JPanel(new GridLayout(18,2));
    JPanel myJPanel2 = new JPanel(new FlowLayout());

    Popup myPopup = new Popup("");

    JLabel myLabel1 = new JLabel("First Name:");
    JTextField myTextField1 = new JTextField(20);
    JLabel myLabel2 = new JLabel("Surname:");
    JTextField myTextField2 = new JTextField(20);
    JLabel myLabel3 = new JLabel("Street:");
    JTextField myTextField3 = new JTextField(20);
    JLabel myLabel4 = new JLabel("City:");
    JTextField myTextField4 = new JTextField(20);
    JLabel myLabel5 = new JLabel("County:");
    JTextField myTextField5 = new JTextField(20);

    JLabel myLabel6 = new JLabel("Phone Number:");
    JTextField myTextField6 = new JTextField(20);
    JLabel myLabel7 = new JLabel("User Name (E-Mail Address):");
    JTextField myTextField7 = new JTextField(20);
    JLabel myLabel8 = new JLabel("Password:");
    JTextField myTextField8 = new JTextField(20);
    JLabel myLabel9 = new JLabel("Credit Card Type:");
    JTextField myTextField9 = new JTextField(20);
    JLabel myLabel10 = new JLabel("Card Number:");
    JTextField myTextField10 = new JTextField(20);
    JLabel myLabel11 = new JLabel("Expiry Date:");
    JTextField myTextField11 = new JTextField(20);




    JButton myButton = new JButton("Add New Customer");
    JButton myButton1 = new JButton("Retrive");
    JButton myButton2 = new JButton("Previous");
    JButton myButton3 = new JButton("Next");


    //declare an object of the type described below which implements ActionListener
    ItemHandler myHandler = new ItemHandler();
    NewCustomers tempCustomer;
    Vector myCustomers = new Vector();
    int index;
    Color myColor= new Color (204,207,208);
    Font myFont= new Font ("Arial",0,14);


    public DB_NewCustomers ()
    {
    //add the objects to the frame
    getContentPane().setLayout(new GridLayout(13,2));
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(myJPanel1);
    getContentPane().add(myJPanel2);
    getContentPane().setBackground (myColor);
    //getContentPane.setFont (myFont);
    myLabel1.setFont(myFont);
    myLabel2.setFont(myFont);
    myLabel3.setFont(myFont);
    myLabel4.setFont(myFont);
    myLabel5.setFont(myFont);
    myLabel6.setFont(myFont);
    myLabel7.setFont(myFont);
    myLabel8.setFont(myFont);
    myLabel9.setFont(myFont);
    myLabel10.setFont(myFont);
    myLabel11.setFont(myFont);

    // getContentPane().setJPanel (myColor);
    myJPanel1.setBackground(myColor);
    myJPanel1.setFont(myFont);
    myJPanel1.add(myLabel1);
    myJPanel1.add(myTextField1);
    myJPanel1.add(myLabel2);
    myJPanel1.add(myTextField2);
    myJPanel1.add(myLabel3);
    myJPanel1.add(myTextField3);
    myJPanel1.add(myLabel4);
    myJPanel1.add(myTextField4);
    myJPanel1.add(myLabel5);
    myJPanel1.add(myTextField5);

    myJPanel1.add(myLabel6);
    myJPanel1.add(myTextField6);
    myJPanel1.add(myLabel7);
    myJPanel1.add(myTextField7);
    myJPanel1.add(myLabel8);
    myJPanel1.add(myTextField8);
    myJPanel1.add(myLabel9);
    myJPanel1.add(myTextField9);
    myJPanel1.add(myLabel10);
    myJPanel1.add(myTextField10);
    myJPanel1.add(myLabel11);
    myJPanel1.add(myTextField11);




    myJPanel1.add(myButton);
    myJPanel1.add(myButton1);
    myJPanel1.add(myButton2);
    myJPanel1.add(myButton3);
    getContentPane().add(myPopup);







    //if one of your objects is a button make the listener listen to it
    myButton.addActionListener(myHandler);
    myButton1.addActionListener(myHandler);
    myButton2.addActionListener(myHandler);
    myButton3.addActionListener(myHandler);
    //use the addActionListener method
    }


    public static void main(String args[])
    {
    DB_NewCustomers thisApp = new DB_NewCustomers ();
    thisApp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    thisApp.setSize(800,400);
    thisApp.setVisible(true);
    }

    //declare a class which implements the ActionListener Interface
    class ItemHandler implements ActionListener
    {
    public void actionPerformed(ActionEvent myEvent)
    {
    if (myEvent.getSource()==myButton)
    {
    mySqlString=mySqlString + myTextField1.getText()+"','"+ myTextField2.getText()+"','"+ myTextField3.getText()+"','"+ myTextField4.getText()+"','"+ myTextField5.getText()+"',"+ myTextField6.getText()+",'"+ myTextField7.getText()+"','"+ myTextField8.getText()+"','"+ myTextField9.getText()+"',"+ myTextField10.getText()+","+ myTextField11.getText()+")";
    //System.out.print(mySqlString);
    DBUseful.insertData(mySqlString);
    }

    if (myEvent.getSource()==myButton1)
    {


    String sqlStatement = "select * from Customer";
    myCustomers = DBUseful.getData(sqlStatement);
    NewCustomers tempCustomer = (NewCustomers) myCustomers.get(index);

    myTextField1.setText(""+tempCustomer.getFirst_Name());
    myTextField2.setText(""+tempCustomer.getSurname());
    myTextField3.setText(""+tempCustomer.getStreet());
    myTextField4.setText(""+tempCustomer.getCity());
    myTextField5.setText(""+tempCustomer.getCounty());

    myTextField6.setText(""+tempCustomer.getPhone_number());
    myTextField7.setText(""+tempCustomer.getUsername());
    myTextField8.setText(""+tempCustomer.getPass_word());
    myTextField9.setText(""+tempCustomer.getCredit_card_type());
    myTextField10.setText(""+tempCustomer.getCard_number());
    myTextField11.setText(""+tempCustomer.getExpiry_date());

    DBUseful.getData(sqlStatement);
    }

    if (myEvent.getSource()==myButton2)
    {
    index--;
    tempCustomer=(NewCustomers)myCustomers.get(index);
    myTextField1.setText(""+tempCustomer.getFirst_Name());
    myTextField2.setText(""+tempCustomer.getSurname());
    myTextField3.setText(""+tempCustomer.getStreet());
    myTextField4.setText(""+tempCustomer.getCity());
    myTextField5.setText(""+tempCustomer.getCounty());

    myTextField6.setText(""+tempCustomer.getPhone_number());
    myTextField7.setText(""+tempCustomer.getUsername());
    myTextField8.setText(""+tempCustomer.getPass_word());
    myTextField9.setText(""+tempCustomer.getCredit_card_type());
    myTextField10.setText(""+tempCustomer.getCard_number());
    myTextField11.setText(""+tempCustomer.getExpiry_date());
    System.out.println(index);
    if(index == 0)
    {
    myPopup.setText("Please Press Next");

    }

    }

    if (myEvent.getSource()==myButton3)
    {
    index++;
    tempCustomer=(NewCustomers)myCustomers.get(index);
    myTextField1.setText(""+tempCustomer.getFirst_Name());
    myTextField2.setText(""+tempCustomer.getSurname());
    myTextField3.setText(""+tempCustomer.getStreet());
    myTextField4.setText(""+tempCustomer.getCity());
    myTextField5.setText(""+tempCustomer.getCounty());

    myTextField6.setText(""+tempCustomer.getPhone_number());
    myTextField7.setText(""+tempCustomer.getUsername());
    myTextField8.setText(""+tempCustomer.getPass_word());
    myTextField9.setText(""+tempCustomer.getCredit_card_type());
    myTextField10.setText(""+tempCustomer.getCard_number());
    myTextField11.setText(""+tempCustomer.getExpiry_date());

    if(index ==(myCustomers.size()-1))
    {
    myPopup.setText("End of Customer Details");

    }


    }

    }




    }

    }[/PHP]


Comments

  • Moderators, Science, Health & Environment Moderators Posts: 10,088 Mod ✭✭✭✭marco_polo


    Sounds like you are looking for the CardLayout manager or a tabbed pane.

    Tabbed panes are pretty straight forward to use, you are basically just add your JPanels as tabs to the pane component.
    JTabbedPane tabbedPane = new JTabbedPane();
    
        JPanel jpanel1 = new JPanel() {
        JPanel jpanel2 = new JPanel();
        
        tabbedPane.addTab("Tab 1 text", jpanel1);
        tabbedPane.addTab("Tab 2 text", jpanel2);
    

    Tutorial here

    http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html


  • Registered Users, Registered Users 2 Posts: 538 ✭✭✭ComplyOrDie


    marco_polo wrote: »
    Sounds like you are looking for the CardLayout manager or a tabbed pane.

    Tabbed panes are pretty straight forward to use, you are basically just add your JPanels as tabs to the pane component.
    JTabbedPane tabbedPane = new JTabbedPane();
     
        JPanel jpanel1 = new JPanel() {
        JPanel jpanel2 = new JPanel();
     
        tabbedPane.addTab("Tab 1 text", jpanel1);
        tabbedPane.addTab("Tab 2 text", jpanel2);
    

    Tutorial here

    http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html

    Marco i have been trying to follow the instructions you sent the link for, but i keep getting compiler errors, where do i enter the pieces of code that are above
    Regards
    Complyordie


  • Moderators, Science, Health & Environment Moderators Posts: 10,088 Mod ✭✭✭✭marco_polo


    Marco i have been trying to follow the instructions you sent the link for, but i keep getting compiler errors, where do i enter the pieces of code that are above
    Regards
    Complyordie

    Could you post up the error you are getting.

    In yor code you would delete the statements that add your JPanels to the contentPane and replace it with one adding the tabbedPane to the contentPane. Then you would add your JPanels to the tabbedPane instance instead. In your code something like this;
    //Delete these lines
    //getContentPane().add(myJPanel1);
    //getContentPane().add(myJPanel2);
    
    /**corrected statments**/
        tabbedPane.add("myPanel 1",myJPanel1);
        tabbedPane.add("myPanel 2",myJPanel2);
    
        getContentPane().add(tabbedPane);
    

    Post up the error and/or some code if you are still stuck.


  • Registered Users, Registered Users 2 Posts: 538 ✭✭✭ComplyOrDie


    As you can see i am rubbish at java, but here is the error.

    [PHP]import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    class DB_NewCustomers extends JFrame
    {
    String mySqlString = "INSERT INTO Customer VALUES('";
    //declare the objects we need
    JPanel myJPanel1 = new JPanel(new GridLayout(20,2));
    JPanel myJPanel2 = new JPanel(new FlowLayout());
    JLabel myLabel0 = new JLabel("Customer ID:");
    JTextField myTextField0 = new JTextField(20);
    JLabel myLabel1 = new JLabel("First Name:");
    JTextField myTextField1 = new JTextField(20);
    JLabel myLabel2 = new JLabel("Surname:");
    JTextField myTextField2 = new JTextField(20);
    JLabel myLabel3 = new JLabel("Street:");
    JTextField myTextField3 = new JTextField(20);
    JLabel myLabel4 = new JLabel("City:");
    JTextField myTextField4 = new JTextField(20);
    JLabel myLabel5 = new JLabel("County:");
    JTextField myTextField5 = new JTextField(20);
    JLabel myLabel6 = new JLabel("Phone Number:");
    JTextField myTextField6 = new JTextField(20);
    JLabel myLabel7 = new JLabel("User Name (E-Mail Address):");
    JTextField myTextField7 = new JTextField(20);
    JLabel myLabel8 = new JLabel("Password:");
    JTextField myTextField8 = new JTextField(20);
    JLabel myLabel9 = new JLabel("Credit Card Type:");
    JTextField myTextField9 = new JTextField(20);
    JLabel myLabel10 = new JLabel("Card Number:");
    JTextField myTextField10 = new JTextField(20);
    JLabel myLabel11 = new JLabel("Expiry Date:");
    JTextField myTextField11 = new JTextField(20);


    JButton myButton = new JButton("Add New Customer");
    JButton myButton1 = new JButton("Retrive");
    JButton myButton2 = new JButton("Previous");
    JButton myButton3 = new JButton("Next");

    //declare an object of the type described below which implements ActionListener
    ItemHandler myHandler = new ItemHandler();
    NewCustomers tempCustomer;
    Vector myCustomers = new Vector();
    int index;
    Color myColor= new Color (204,207,208);
    Font myFont= new Font ("Arial",0,14);

    public DB_NewCustomers ()
    {
    //add the objects to the frame
    getContentPane().setLayout(new GridLayout(16,2));
    getContentPane().setLayout(new FlowLayout());
    //getContentPane().add(myJPanel1);
    //getContentPane().add(myJPanel2);
    tabbedPane.add("myPanel 1",myJPanel1
    tabbedPane.add("myPanel 2",myJPanel2)
    getContentPane().add(tabbedPane);
    getContentPane().setBackground (myColor);
    //getContentPane.setFont (myFont);
    myLabel0.setFont(myFont);
    myLabel1.setFont(myFont);
    myLabel2.setFont(myFont);
    myLabel3.setFont(myFont);
    myLabel4.setFont(myFont);
    myLabel5.setFont(myFont);
    myLabel6.setFont(myFont);
    myLabel7.setFont(myFont);
    myLabel8.setFont(myFont);
    myLabel9.setFont(myFont);
    myLabel10.setFont(myFont);
    myLabel11.setFont(myFont);
    // getContentPane().setJPanel (myColor);
    myJPanel1.setBackground(myColor);
    myJPanel1.setFont(myFont);
    myJPanel1.add(myLabel0);
    myJPanel1.add(myTextField0);
    myJPanel1.add(myLabel1);
    myJPanel1.add(myTextField1);
    myJPanel1.add(myLabel2);
    myJPanel1.add(myTextField2);
    myJPanel1.add(myLabel3);
    myJPanel1.add(myTextField3);
    myJPanel1.add(myLabel4);
    myJPanel1.add(myTextField4);
    myJPanel1.add(myLabel5);
    myJPanel1.add(myTextField5);
    myJPanel1.add(myLabel6);
    myJPanel1.add(myTextField6);
    myJPanel1.add(myLabel7);
    myJPanel1.add(myTextField7);
    myJPanel1.add(myLabel8);
    myJPanel1.add(myTextField8);
    myJPanel1.add(myLabel9);
    myJPanel1.add(myTextField9);
    myJPanel1.add(myLabel10);
    myJPanel1.add(myTextField10);
    myJPanel1.add(myLabel11);
    myJPanel1.add(myTextField11);


    myJPanel1.add(myButton);
    myJPanel1.add(myButton1);
    myJPanel1.add(myButton2);
    myJPanel1.add(myButton3);



    //if one of your objects is a button make the listener listen to it
    myButton.addActionListener(myHandler);
    myButton1.addActionListener(myHandler);
    myButton2.addActionListener(myHandler);
    myButton3.addActionListener(myHandler);
    //use the addActionListener method
    }

    public static void main(String args[])
    {
    DB_NewCustomers thisApp = new DB_NewCustomers ();
    thisApp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    thisApp.setSize(800,400);
    thisApp.setVisible(true);
    }
    //declare a class which implements the ActionListener Interface
    class ItemHandler implements ActionListener
    {
    public void actionPerformed(ActionEvent myEvent)
    {
    if (myEvent.getSource()==myButton)
    {
    mySqlString=mySqlString + myTextField1.getText()+"','"+ myTextField2.getText()+"','"+ myTextField3.getText()+"','"+ myTextField4.getText()+"','"+ myTextField5.getText()+"',"+ myTextField6.getText()+",'"+ myTextField7.getText()+"','"+ myTextField8.getText()+"','"+ myTextField9.getText()+"',"+ myTextField10.getText()+","+ myTextField11.getText()+")";
    //System.out.print(mySqlString);
    DBUseful.insertData(mySqlString);
    }
    if (myEvent.getSource()==myButton1)
    {

    String sqlStatement = "select * from Customer";
    myCustomers = DBUseful.getData(sqlStatement);
    NewCustomers tempCustomer = (NewCustomers) myCustomers.get(index);
    myTextField0.setText(""+tempCustomer.getCustomer_ID());
    myTextField1.setText(""+tempCustomer.getFirst_Name());
    myTextField2.setText(""+tempCustomer.getSurname());
    myTextField3.setText(""+tempCustomer.getStreet());
    myTextField4.setText(""+tempCustomer.getCity());
    myTextField5.setText(""+tempCustomer.getCounty());
    myTextField6.setText(""+tempCustomer.getPhone_number());
    myTextField7.setText(""+tempCustomer.getUsername());
    myTextField8.setText(""+tempCustomer.getPass_word());
    myTextField9.setText(""+tempCustomer.getCredit_card_type());
    myTextField10.setText(""+tempCustomer.getCard_number());
    myTextField11.setText(""+tempCustomer.getExpiry_date());
    DBUseful.getData(sqlStatement);
    }
    if (myEvent.getSource()==myButton2)
    {
    index--;
    tempCustomer=(NewCustomers)myCustomers.get(index);
    myTextField0.setText(""+tempCustomer.getCustomer_ID());
    myTextField1.setText(""+tempCustomer.getFirst_Name());
    myTextField2.setText(""+tempCustomer.getSurname());
    myTextField3.setText(""+tempCustomer.getStreet());
    myTextField4.setText(""+tempCustomer.getCity());
    myTextField5.setText(""+tempCustomer.getCounty());
    myTextField6.setText(""+tempCustomer.getPhone_number());
    myTextField7.setText(""+tempCustomer.getUsername());
    myTextField8.setText(""+tempCustomer.getPass_word());
    myTextField9.setText(""+tempCustomer.getCredit_card_type());
    myTextField10.setText(""+tempCustomer.getCard_number());
    myTextField11.setText(""+tempCustomer.getExpiry_date());
    System.out.println(index);
    if(index == 0);
    }

    if (myEvent.getSource()==myButton3)
    {
    index++;
    tempCustomer=(NewCustomers)myCustomers.get(index);
    myTextField0.setText(""+tempCustomer.getCustomer_ID());
    myTextField1.setText(""+tempCustomer.getFirst_Name());
    myTextField2.setText(""+tempCustomer.getSurname());
    myTextField3.setText(""+tempCustomer.getStreet());
    myTextField4.setText(""+tempCustomer.getCity());
    myTextField5.setText(""+tempCustomer.getCounty());
    myTextField6.setText(""+tempCustomer.getPhone_number());
    myTextField7.setText(""+tempCustomer.getUsername());
    myTextField8.setText(""+tempCustomer.getPass_word());
    myTextField9.setText(""+tempCustomer.getCredit_card_type());
    myTextField10.setText(""+tempCustomer.getCard_number());
    myTextField11.setText(""+tempCustomer.getExpiry_date());
    if(index ==(myCustomers.size()-1));


    }


    }
    }
    }[/PHP]


  • Moderators, Science, Health & Environment Moderators Posts: 10,088 Mod ✭✭✭✭marco_polo


    You are missing this variable declaration from you code.

    JTabbedPane tabbedPane = new JTabbedPane();

    Also there were a couple of missing ;'s in the tabbedPane.add() code I posted previously. :)

    I have edited the previous post to to correct it.

    It should compile fine then.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 538 ✭✭✭ComplyOrDie


    Thanks for your help earlier marco.
    I have been getting a problem when trying to get a simular layout on tab 2, to that of the 1st tab. I have tried a number of ways but it appears to ignore the grid layout. so i have panel 2 inside panel 3. the result is that it is centered. All help would be appriceated
    [PHP]import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    class DB_NewCustomers extends JFrame
    {
    String mySqlString = "INSERT INTO Customer VALUES('";
    //declare the objects we need
    JPanel myJPanel1 = new JPanel(new GridLayout(20,2));
    JPanel myJPanel2 = new JPanel(new FlowLayout());
    JPanel myJPanel3 = new JPanel(new FlowLayout());
    JTabbedPane tabbedPane = new JTabbedPane();
    JLabel myLabel0 = new JLabel("Customer ID:");
    JTextField myTextField0 = new JTextField(20);
    JLabel myLabel1 = new JLabel("First Name:");
    JTextField myTextField1 = new JTextField(20);
    JLabel myLabel2 = new JLabel("Surname:");
    JTextField myTextField2 = new JTextField(20);
    JLabel myLabel3 = new JLabel("Street:");
    JTextField myTextField3 = new JTextField(20);
    JLabel myLabel4 = new JLabel("City:");
    JTextField myTextField4 = new JTextField(20);
    JLabel myLabel5 = new JLabel("County:");
    JTextField myTextField5 = new JTextField(20);
    JLabel myLabel6 = new JLabel("Phone Number:");
    JTextField myTextField6 = new JTextField(20);
    JLabel myLabel7 = new JLabel("User Name (E-Mail Address):");
    JTextField myTextField7 = new JTextField(20);
    JLabel myLabel8 = new JLabel("Password:");
    JTextField myTextField8 = new JTextField(20);
    JLabel myLabel9 = new JLabel("Credit Card Type:");
    JTextField myTextField9 = new JTextField(20);
    JLabel myLabel10 = new JLabel("Card Number:");
    JTextField myTextField10 = new JTextField(20);
    JLabel myLabel11 = new JLabel("Expiry Date:");
    JTextField myTextField11 = new JTextField(20);
    JLabel myLabel12 = new JLabel("lbl 1:");
    JTextField myTextField12 = new JTextField(20);
    JLabel myLabel13 = new JLabel("lbl 2:");
    JTextField myTextField13 = new JTextField(20);

    JButton myButton = new JButton("Add New Customer");
    JButton myButton1 = new JButton("Retrive");
    JButton myButton2 = new JButton("Previous");
    JButton myButton3 = new JButton("Next");
    JButton myButton4 = new JButton("Add New Customer");
    JButton myButton5 = new JButton("Retrive");

    //declare an object of the type described below which implements ActionListener
    ItemHandler myHandler = new ItemHandler();
    NewCustomers tempCustomer;
    Vector myCustomers = new Vector();
    int index;
    Color myColor= new Color (204,207,208);
    Font myFont= new Font ("Arial",0,14);

    public DB_NewCustomers ()
    {
    //add the objects to the frame
    //getContentPane().setLayout(new GridLayout(16,2));
    //getContentPane().setLayout(new FlowLayout());
    //getContentPane().add(myJPanel1);
    //getContentPane().add(myJPanel2);
    myJPanel1.setLayout(new GridLayout(16,2));
    myJPanel2.setSize(200,200);
    myJPanel2.setLayout(new GridLayout(9,2));
    //tabbedPane.setLayout(new FlowLayout());
    tabbedPane.add("myPanel 1",myJPanel1);
    tabbedPane.add("myPanel 2",myJPanel3);
    getContentPane().add(tabbedPane);
    getContentPane().setBackground (myColor);
    //getContentPane.setFont (myFont);
    myLabel0.setFont(myFont);
    myLabel1.setFont(myFont);
    myLabel2.setFont(myFont);
    myLabel3.setFont(myFont);
    myLabel4.setFont(myFont);
    myLabel5.setFont(myFont);
    myLabel6.setFont(myFont);
    myLabel7.setFont(myFont);
    myLabel8.setFont(myFont);
    myLabel9.setFont(myFont);
    myLabel10.setFont(myFont);
    myLabel11.setFont(myFont);
    // getContentPane().setJPanel (myColor);
    myJPanel1.setBackground(myColor);
    myJPanel1.setFont(myFont);
    myJPanel1.add(myLabel0);
    myJPanel1.add(myTextField0);
    myJPanel1.add(myLabel1);
    myJPanel1.add(myTextField1);
    myJPanel1.add(myLabel2);
    myJPanel1.add(myTextField2);
    myJPanel1.add(myLabel3);
    myJPanel1.add(myTextField3);
    myJPanel1.add(myLabel4);
    myJPanel1.add(myTextField4);
    myJPanel1.add(myLabel5);
    myJPanel1.add(myTextField5);
    myJPanel1.add(myLabel6);
    myJPanel1.add(myTextField6);
    myJPanel1.add(myLabel7);
    myJPanel1.add(myTextField7);
    myJPanel1.add(myLabel8);
    myJPanel1.add(myTextField8);
    myJPanel1.add(myLabel9);
    myJPanel1.add(myTextField9);
    myJPanel1.add(myLabel10);
    myJPanel1.add(myTextField10);
    myJPanel1.add(myLabel11);
    myJPanel1.add(myTextField11);



    myJPanel1.add(myButton);
    myJPanel1.add(myButton1);
    myJPanel1.add(myButton2);
    myJPanel1.add(myButton3);
    myJPanel2.add(myLabel12);
    myJPanel2.add(myTextField12);
    myJPanel2.add(myLabel13);
    myJPanel2.add(myTextField13);
    myJPanel3.add(myJPanel2);
    myJPanel2.add(myButton4);
    myJPanel2.add(myButton5);



    //if one of your objects is a button make the listener listen to it
    myButton.addActionListener(myHandler);
    myButton1.addActionListener(myHandler);
    myButton2.addActionListener(myHandler);
    myButton3.addActionListener(myHandler);
    //use the addActionListener method
    }
    [/PHP]


  • Registered Users, Registered Users 2 Posts: 538 ✭✭✭ComplyOrDie


    Sorry for wasting ur time, but i got it 2 work
    Thanks anyway
    ComplyOrDie

    :)


Advertisement