Jump to content


Need To Send Info To Class File Can Smeone Help


  • Please log in to reply
No replies to this topic

#1 thedogger

thedogger

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 23 January 2012 - 02:28 PM

i cant find out how to send my text box info to the recipt can any one help me hears what i got



import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.Font;

public class Exam implements ActionListener{
JFrame frame;
JFrame frame1;
JFrame frame2;
JFrame frame3;
JPanel contentPane;
JPanel contentPane1;
JPanel contentPane2;
JPanel contentPane3;
JLabel label1;
JLabel label2;
JLabel label3;
JLabel label4;
JLabel label5;
JLabel label6;
JLabel label7;
JLabel label8;
JLabel label9;
JLabel label10;
JLabel label11;
JLabel label12;
JLabel label13;
JLabel label14;
JLabel label15;
JLabel label16;
JButton button;
JButton button1;
JButton button2;
JTextField textBox1;
JTextField textBox2;
JTextField textBox3;
JTextField textBox4;
JTextField textBox5;
JTextField textBox6;
JTextField textBox7;
JTextField textBox8;
JTextField textBox9;
JTextField textBox10;
JTextField textBox11;
JTextField textBox12;
JTextField textBox13;
JTextField textBox14;




public Exam (){

frame = new JFrame("EXAM");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame1 = new JFrame("Mailing info");
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame2 = new JFrame("Inventory");
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setBounds(10,10,100,40);

frame3 = new JFrame("Recipt");
frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame3.setBounds(10,10,100,40);


contentPane = new JPanel();
contentPane.setBackground(Color.orange);
contentPane.setLayout(new BoxLayout(contentPane,
                                   BoxLayout.PAGE_AXIS));
contentPane.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));


contentPane1 = new JPanel();
contentPane1.setBackground(Color.orange);
contentPane1.setLayout(new BoxLayout(contentPane1,
                                   BoxLayout.PAGE_AXIS));
contentPane1.setBorder(BorderFactory.createEmptyBorder(40,40,40,40));

contentPane2 = new JPanel();
contentPane2.setBackground(Color.orange);
contentPane2.setLayout(new BoxLayout(contentPane2,
                                   BoxLayout.PAGE_AXIS));
contentPane2.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));

contentPane3 = new JPanel();
contentPane3.setBackground(Color.orange);
contentPane3.setLayout(new BoxLayout(contentPane3,
                                   BoxLayout.PAGE_AXIS));
contentPane3.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));                            



label1 =new JLabel("Welcome To Nigel's Store!!");
label1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label1.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
contentPane.add(label1);

label2 =new JLabel("This program will let you buy");
label2.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label2.setBorder(BorderFactory.createEmptyBorder(11, 11, 11, 11));
contentPane.add(label2);

label3 =new JLabel("items and send them to your house.");
label3.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label3.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
contentPane.add(label3);

//order page labels

label4 =new JLabel("PencilsX12");
label4.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label4.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label5 =new JLabel("Eraser");
label5.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label5.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label6 =new JLabel("Calculator");
label6.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label6.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label7 =new JLabel("Binder");
label7.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label7.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label8 =new JLabel("Pen");
label8.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label8.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label9 =new JLabel("Book");
label9.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label9.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label10 =new JLabel("Paper");
label10.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label10.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label11 =new JLabel("Ruler");
label11.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label11.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label12 =new JLabel("Staples");
label12.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label12.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label13 =new JLabel("Stapler");
label13.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label13.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label14 =new JLabel("Mailing Information");
label14.setFont(new Font("sansserif",Font.BOLD,22));
label14.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label14.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label15 =new JLabel("Inventory");
label15.setFont(new Font("sansserif",Font.BOLD,22));
label15.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label15.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

label16 =new JLabel("Recipt");
label16.setFont(new Font("sansserif",Font.BOLD,22));
label16.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label16.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    
button = new JButton("Continue");
button.setAlignmentX(JButton.CENTER_ALIGNMENT);
button.setActionCommand("Continue");
        button.addActionListener(this);
        button.setVisible(true);
        
        button1 = new JButton("Continue");
button1.setAlignmentX(JButton.CENTER_ALIGNMENT);
button1.setActionCommand("Continue.");
        button1.addActionListener(this);
        button1.setVisible(true);
        
        button2 = new JButton("Check Out");
button2.setAlignmentX(JButton.CENTER_ALIGNMENT);
button2.setActionCommand("Checkout..");
        button2.addActionListener(this);
        button2.setVisible(true);
        
        
        
        textBox1 = new JTextField("Name", 40);
        textBox1.setAlignmentX(JTextField.CENTER_ALIGNMENT);
        textBox1.setVisible(true);
        
        textBox2 = new JTextField("Full Mailing Address", 40);
        textBox2.setAlignmentX(JTextField.CENTER_ALIGNMENT);
    textBox2.setVisible(true);

textBox3 = new JTextField("Phone number", 40);
textBox3.setAlignmentX(JTextField.CENTER_ALIGNMENT);
    textBox3.setVisible(true);

textBox4 = new JTextField("email", 40);
textBox4.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox4.setVisible(true);




//order page
textBox5 = new JTextField("Qunaity", 10);
textBox5.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox5.setVisible(true);

textBox6 = new JTextField("Qunaity", 10);
textBox6.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox6.setVisible(true);

textBox7 = new JTextField("Qunaity", 10);
textBox7.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox7.setVisible(true);

textBox7 = new JTextField("Qunaity", 10);
textBox7.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox7.setVisible(true);

textBox8 = new JTextField("Qunaity", 10);
textBox8.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox8.setVisible(true);

textBox9 = new JTextField("Qunaity", 10);
textBox9.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox9.setVisible(true);

textBox10 = new JTextField("Qunaity", 10);
textBox10.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox10.setVisible(true);

textBox11 = new JTextField("Qunaity", 10);
textBox11.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox11.setVisible(true);

textBox12 = new JTextField("Qunaity", 10);
textBox12.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox12.setVisible(true);

textBox13 = new JTextField("Qunaity", 10);
textBox13.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox13.setVisible(true);


textBox14 = new JTextField("Qunaity", 10);
textBox14.setAlignmentX(JTextField.CENTER_ALIGNMENT);
textBox14.setVisible(true);

contentPane1.add(label14);

contentPane1.add(textBox1);
contentPane1.add(textBox2);
contentPane1.add(textBox3);
contentPane1.add(textBox4);
contentPane.add(button);
contentPane1.add(button1);

//order page panes
contentPane2.add(label15);

contentPane2.add(label4);
contentPane2.add(textBox5);
contentPane2.add(label5);
contentPane2.add(textBox6);
contentPane2.add(label6);
contentPane2.add(textBox7);
contentPane2.add(label7);
contentPane2.add(textBox8);
contentPane2.add(label8);
contentPane2.add(textBox9);
contentPane2.add(label9);
contentPane2.add(textBox10);
contentPane2.add(label10);
contentPane2.add(textBox11);
contentPane2.add(label11);
contentPane2.add(textBox12);
contentPane2.add(label12);
contentPane2.add(textBox13);
contentPane2.add(label13);
contentPane2.add(textBox14);


contentPane2.add(button2);

contentPane3.add(label16);





frame.setContentPane(contentPane);
frame.pack();
frame.setVisible(true);
frame1.setContentPane(contentPane1);
frame1.pack();
frame1.setVisible(false);
frame2.setContentPane(contentPane2);
frame2.pack();
frame2.setVisible(false);
frame3.setContentPane(contentPane3);
frame3.pack();
frame3.setVisible(false);

}

public void actionPerformed (ActionEvent event){
String eventName = event.getActionCommand();
if (eventName.equals("Continue")){
frame.setVisible(false);
frame1.setVisible(true);
contentPane.setVisible(true);
     contentPane1.setVisible(true);
textBox1.setVisible(true);
textBox2.setVisible(true);
textBox3.setVisible(true);
textBox4.setVisible(true);
button.setVisible(false);
button1.setVisible(true);
}
     if (eventName.equals("Continue.")){
     frame1.setVisible(false);
frame2.setVisible(true);
contentPane1.setVisible(true);
contentPane2.setVisible(true);
   button2.setVisible(true);
     }
        if (eventName.equals("Checkout..")){
     frame2.setVisible(false);
frame3.setVisible(true);
contentPane2.setVisible(true);
contentPane3.setVisible(true);
  
   }
  }
  
   private static void runGUI() {
   JFrame.setDefaultLookAndFeelDecorated(true);
  
   Customer greeting = new Customer();
   Exam nigel = new Exam();
   }
  
  
   public static void main (String[] args){
   javax.swing.SwingUtilities.invokeLater(new Runnable() {
   public void run () {
   runGUI();
   }
   });
   }
}