Results 1 to 9 of 9
- 10-02-2010, 07:12 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
Data wouldnt't read from my form called 'express' in form'ticketing'
Java Code:import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.border.TitledBorder; public class express extends JFrame { private JTextField txtUsername , txtCustomerID, txtNumberChildren, txtNumberAdult, txtReward, txtPassword, txticnumber; private JButton btnRegister, btnsave, btncancel; private JLabel lblUsername, lblCustomerID, lblNumberChildren, lblNumberAdult, lblstation, lblto, lblReward, lblPassword, lblicnumber; private JLabel lblCurrentTime; private JTextField txtCurrentTime; private JPanel CustomerInformation; private JComboBox cbostation ; private JComboBox cbostation2; private int customerid; // ArrayList contains Parcels entered by user int counter=0; private member Newmember[]=new member[500]; public express(String title) { //set the title super(title); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); //set layout setLayout(null); Container cp= getContentPane(); customerid= 200000; //Add controls to form lblUsername = new JLabel("Username"); lblCurrentTime = new JLabel("Current Time"); lblCustomerID = new JLabel("Customer ID"); lblPassword = new JLabel("Password"); lblicnumber = new JLabel("IC No"); txtUsername = new JTextField("Username"); txtUsername = new JTextField(20); txtCustomerID = new JTextField("Customer ID"); txtCustomerID = new JTextField(20); txtCurrentTime = new JTextField("Current Time"); txtCurrentTime = new JTextField(50); txtPassword = new JTextField("Password"); txtPassword = new JTextField(20); txticnumber = new JTextField("IC No"); txticnumber = new JTextField(30); btnRegister = new JButton("Register"); btnsave = new JButton("Save"); btncancel = new JButton("Cancel"); CustomerInformation = new JPanel(); CustomerInformation.setBounds( 9, 51, 300, 200 ); CustomerInformation.setBorder(new TitledBorder( "Customer Information" ) ); CustomerInformation.setLayout( null ); //contentPane.add( CustomerInformation ); CustomerInformation.add(lblUsername); CustomerInformation.add(txtUsername); cp.add(lblCurrentTime); cp.add(txtCurrentTime); cp.add(btnRegister); cp.add(CustomerInformation); cp.add(btnsave); cp.add(btncancel); CustomerInformation.add(txtCustomerID); CustomerInformation.add(lblCustomerID); CustomerInformation.add(txtPassword); CustomerInformation.add(lblPassword); CustomerInformation.add(txticnumber); CustomerInformation.add(lblicnumber); btnRegister.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { ID(event); } }); btnsave.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { save(event); } }); btncancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { cancel(event); } }); lblicnumber.setBounds(15, 65, 66, 25 ); txtUsername.setBounds(130, 103, 150, 21); btnRegister.setBounds(340, 200, 100, 50); btnsave.setBounds(340, 250, 100, 50); btncancel.setBounds(340, 300, 100, 50); lblCurrentTime.setBounds(22, 0, 90, 70); txtCurrentTime.setBounds(138,20,150,21); txtCustomerID.setBounds(130, 27, 150, 21); lblCustomerID.setBounds(15, 27, 84, 24); lblUsername.setBounds(15, 100, 84, 24); txticnumber.setBounds(130, 65, 150, 21); txtPassword.setBounds(130, 150, 150, 21); lblPassword.setBounds(15, 150, 84, 24); setBounds(100, 400, 300, 200); } public void ID(ActionEvent evt){ int i; i=0; Newmember[0]=new member(); while(Newmember[i].getname()!=null){ i=i+1; counter=i; customerid=customerid+1; } JOptionPane.showMessageDialog(null,"pp"); customerid= customerid + 1; txtCustomerID.setText(String.valueOf(customerid)); } public void save(ActionEvent evt){ int i=0; Newmember[counter].setname(txtUsername.getText()); Newmember[counter].setcustomerid(Integer.parseInt(txtCustomerID.getText())); Newmember[counter].seticnumber(Integer.parseInt(txticnumber.getText())); while(Newmember[i].getname()!=null){ JOptionPane.showMessageDialog(null,Newmember[i].getname()); i=i+1; } } public void cancel(ActionEvent evt){ if(evt.getSource()==btncancel){ dispose(); } } } form ticketing : import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.border.TitledBorder; public class ticketing extends JFrame { private JTextField txtNumberChildren, txtNumberAdult, txttotal, txtdiscount, txtsubtotal, txtcustomer_id, txtic_number; private JButton btncomfirm, btncancel,btnsearch; private JLabel lblNumberChildren, lblNumberAdult, lblstation, lblto, lbltime, lbltotal, lbldiscount, lblsubtotal, lblcustomer_id, lblic_number; private JPanel Ticketing ; private JComboBox cbostation , cbotime; private JComboBox cbostation2; private String[] station = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" , "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30" }; private String[] station2 = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" , "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30" }; private String[] time = { "6:00AM", "6:15AM", "6:30AM", "6:45AM", "7:00AM", "7:15AM", "7:30AM", "7:45AM", "8:00AM", "8:15AM", "8:30AM", "8:45AM", "9:00AM", "9:15AM", "9:30AM", "9:45AM", "10:00AM", "10:15AM", "10:30AM", "10:45AM", "11:00AM","11:15AM", "11:30AM", "11:45AM", "12:00PM", "12:15PM", "12:30PM", "12:45PM", "1:00PM", "1:15PM", "1:30PM", "1:45PM", "2:00PM", "2:15PM", "2:30PM", "2:45PM", "3:00PM", "3:15PM", "3:30PM", "3:45PM", "4:00PM", "4:15PM", "4:30PM", "4:45PM", "5:00PM", "5:15PM", "5:30PM", "5:45PM","6:00PM", "6:15PM", "6:30PM", "6:45PM", "7:00PM", "7:15PM", "7:30PM", "7:45PM", "8:00PM", "8:15PM", "8:30PM", "8:45PM", "9:00PM", "9:15PM", "9:30PM", "9:45PM", "10:00PM", "10:15PM", "10:30PM", "10:45PM", "11:00PM", "11:15PM", "11:30PM", "11:45PM", "12:00AM", "12:15AM", "12:30AM", "12:45AM", "1:00AM", "1:15AM", "1:30AM", "1:45AM", "2:00AM", "2:15AM", "2:30AM", "2:45AM", "3:00AM", "3:15AM", "3:30AM", "3:45AM", "4:00AM", "4:15AM", "4:30AM", "4:45AM", "5:00AM", "5:15AM", "5:30AM", "5:45AM" }; private member Newmember[]=new member[500]; public ticketing(String title) { //set the title super(title); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); //set layout setLayout(null); Container cp= getContentPane(); lblNumberChildren = new JLabel("Number of Children"); lblNumberAdult = new JLabel("Number of Adults"); lblstation = new JLabel("Station"); lblto = new JLabel("to"); lbltime = new JLabel("Time"); lbltotal = new JLabel("Total"); lbldiscount = new JLabel("Discount"); lblsubtotal = new JLabel("Subtotal"); lblic_number = new JLabel("IC Number"); txtic_number = new JTextField("IC Number"); txtic_number = new JTextField(30); lblcustomer_id = new JLabel("CustomerID"); txtcustomer_id = new JTextField("customerid"); txtcustomer_id = new JTextField(20); txtNumberChildren = new JTextField("Number of Children"); txtNumberChildren = new JTextField(10); txtNumberAdult = new JTextField("Number of Adults"); txtNumberAdult = new JTextField(10); txttotal = new JTextField("Total"); txttotal = new JTextField(20); txtdiscount = new JTextField("Discount"); txtdiscount = new JTextField(20); txtsubtotal = new JTextField("Subtotal"); txtsubtotal = new JTextField(20); cbostation = new JComboBox (station); cbostation2 = new JComboBox (station2); cbotime = new JComboBox (time); btncomfirm = new JButton("Comfirm"); btncancel = new JButton("Cancel"); btnsearch = new JButton("search"); // Ticketing = new JPanel(); // Ticketing.setBounds( 9, 51, 300, 200 ); // Ticketing.setBorder(new TitledBorder( "Ticketing" ) ); // Ticketing.setLayout( null ); // contentPane.add( Ticketing ); cp.add(lblNumberChildren); cp.add(lblNumberAdult); cp.add(lblstation); cp.add(lblto); cp.add(lbltime); cp.add(lbltotal); cp.add(lbldiscount); cp.add(txtNumberChildren); cp.add(txtNumberAdult); cp.add(txttotal); cp.add(txtdiscount); cp.add(cbostation); cp.add(cbostation2); cp.add(cbotime); cp.add(txtsubtotal); cp.add(lblsubtotal); cp.add(btncomfirm); cp.add(btncancel); cp.add(txtic_number); cp.add(lblic_number); cp.add(txtcustomer_id); cp.add(lblcustomer_id); cp.add(btnsearch); btnsearch.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { search(event); } }); btncomfirm.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { comfirm(event); } }); btncancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { cancel(event); } }); lblcustomer_id.setBounds(15, 10, 129, 24); lblNumberAdult.setBounds(15, 60, 129, 24); lblNumberChildren.setBounds(15, 110, 129, 24); txtNumberAdult.setBounds(135, 60, 129, 24); txtNumberChildren.setBounds(135, 110, 129, 24); txtic_number.setBounds(135, 160, 129, 24); lblic_number.setBounds(15, 170, 129, 24); lblstation.setBounds(340, 60, 129, 24); cbostation.setBounds(390, 60, 45, 24); lblto.setBounds(440, 60, 40, 24); cbostation2.setBounds(460, 60, 45, 24); lbltime.setBounds(340, 110, 129, 24); cbotime.setBounds(390, 110, 80, 24); lblsubtotal.setBounds(340, 300, 129, 24); txtsubtotal.setBounds(410, 300, 90, 24); lbldiscount.setBounds(340, 350, 129, 24); txtdiscount.setBounds(410, 350, 90, 24); lbltotal.setBounds(340, 400, 129, 24); txttotal.setBounds(410, 400, 90, 24); txtcustomer_id.setBounds(135,10,129,24); btncomfirm.setBounds(150,450,100,28); btncancel.setBounds(300,450,100,28); btnsearch.setBounds(150, 500,100, 28); } public void search(ActionEvent evt){ int i; i=0; while( Newmember[i].getname()!=null){ i=i+1; //if( txtcustomer_id.getText().equals(String.valueOf(Newmember[i].getname()))){ JOptionPane.showMessageDialog(null,Newmember[i].getname()); //} JOptionPane.showMessageDialog(null,Newmember[i].getname()); } JOptionPane.showMessageDialog(null,"search"); } public void comfirm(ActionEvent evt){ //int i; //i=0; //Newmember[0]=new member(); //while(Newmember[i].getname()!=null){ //i=i+1; //counter=i; //customerid=customerid+1; } JOptionPane.showMessageDialog(null,"comfirm"); //customerid= customerid + 1; //txtCustomerID.setText(String.valueOf(customerid)); } public void cancel(ActionEvent evt){ //int i; //i=0; //Newmember[0]=new member(); //while(Newmember[i].getname()!=null){ //i=i+1; //counter=i; //customerid=customerid+1; } JOptionPane.showMessageDialog(null,"cancel"); //customerid= customerid + 1; //txtCustomerID.setText(String.valueOf(customerid)); } }Last edited by realmadrid_000; 10-03-2010 at 04:45 AM.
-
If you need help, you'll want to edit your post above and use code tags to format the ton of code you've posted (please see my signature link to find out how to do this), and you'll want to ask an actual question complete with a full description of your problem. Much luck.
- 10-02-2010, 10:12 PM #3
i just looked at your code and you must specify from which pushed button which data from the class express you want to transfer in which field of the class ticketing. if you can tell me, i may help you.
- 10-03-2010, 04:15 AM #4
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
it is when i press the button called ' btnsearch' in ticketing form.. it will display data from the form called 'express'. thx a lot..
-
- 10-03-2010, 04:45 AM #6
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
so is this the way?
- 10-03-2010, 05:27 AM #7
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
So how hard is it to write a couple of sentences describing your problem? Is it so secret that you're not allowed to tell us the details? Or are we supposed to use a crystal ball and guess?
- 10-03-2010, 05:52 AM #8
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
My problem is when i register a new customer. i go to ticketing form, search the member ID, ntg is displaying out.
- 10-03-2010, 09:45 AM #9
you declare
private member Newmember[]=new member[500];
first of all, where does this member or Newmember come from?
to your problem: you declare the member array in both classes express and ticketing. if i understand right you want to make a search from the ticketing in the member of express, right? with your code each class store its own array of members, and since they have the access private, they even can't be seen from an other class.
the question is how to share the member array, so that the ticketing can read it. a solution is passing the reference of member to the constructor of ticketing. an other is writing a static method getMemberArray in the class express, so that in your search method you can make a call to it and get the member array for the class express.Last edited by j2me64; 10-03-2010 at 09:50 AM.
Similar Threads
-
want to generate a html form page with dynamic data and submit this form to a url
By vishalkrsrivastava in forum Java AppletsReplies: 10Last Post: 08-12-2009, 04:02 PM -
how to capture jsf form data
By Srikala in forum JavaServer Faces (JSF)Replies: 2Last Post: 07-16-2009, 09:06 AM -
enctype=multipart/form-data with form data in struts
By vk_satheesh in forum New To JavaReplies: 0Last Post: 09-19-2008, 12:48 PM -
how to read a form with JFS
By crispy in forum JavaServer Faces (JSF)Replies: 2Last Post: 05-01-2008, 03:07 PM -
Some form to read pixels in Java and to handle Another plate VGA?
By Albert in forum Advanced JavaReplies: 1Last Post: 06-07-2007, 05:29 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks