Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: adding data in table but the table is in another frame

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default adding data in table but the table is in another frame

    this is my codes in a button that if I click it . that information will send to Jtable but the problem is the jtable is in another frame so how can i connect this ? help me plese


     DefaultTableModel model = (DefaultTableModel)
            new admin().tableBagtags.getModel();
     
           if (txtName.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "Please fill out all fields.", "Error!", JOptionPane.ERROR_MESSAGE);
            }
            else if (txtAddress.getText().equals("")) {
                JOptionPane.showMessageDialog(rootPane, "Please fill out all fields.","Error!", JOptionPane.ERROR_MESSAGE);
            }
            else if (txtContacts.getText().equals("")) {
                JOptionPane.showMessageDialog(rootPane, "Please fill out all fields.","Error!", JOptionPane.ERROR_MESSAGE);
            }
            else if (txtEmail.getText().equals("")) {
                JOptionPane.showMessageDialog(rootPane, "Please fill all out fields.","Error!", JOptionPane.ERROR_MESSAGE);
            } else if (jLabel8.getText().equals("*Invalid input*")) {
                jLabel8.setText("Downpayment: Invalid input.");
     
            }   else if (txtDesign.getText().equals("")) {
                JOptionPane.showMessageDialog(rootPane, "Choose your design.","Design", JOptionPane.ERROR_MESSAGE);
           }   
            else if (txtDownpayment.getText().equals("")) {
                jLabel8.setText("Downpayment is required");
     
           }  
            else {
                JOptionPane.showMessageDialog(null, "Order Succesful.");
                model.addRow(new Object [] {txtName.getText(), txtAddress.getText(), txtContacts.getText(), txtEmail.getText()} ); 
                this.dispose();
            }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: adding data in table but the table is in another frame

    Add a method (a "setter" or "mutator" method) to the other class that contains the table to accept the data and place it in the table appropriately. Then send the data to the table:

    tableClass.setDataInTable( data );

    Modify the signature of the method I've suggested as needed to specify where in the table the data should be placed.

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: adding data in table but the table is in another frame

    i dont really get it sir

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: adding data in table but the table is in another frame

    If you don't get getters/setters (mutators/accessors) then I recommend you spend more time practicing writing classes and their interfaces to other classes. Write multiple classes that simply share data among their instances (start simple). You might research those terms, find examples, and also review encapsulation.

    Good luck!

Similar Threads

  1. adding numbers in table
    By brianskiee in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 11th, 2014, 08:02 AM
  2. How to Delete selected table data from DB???? HELP
    By lanepulcini in forum JDBC & Databases
    Replies: 0
    Last Post: February 21st, 2012, 07:07 PM
  3. Retrieve data from other table
    By kichkich in forum JDBC & Databases
    Replies: 2
    Last Post: June 23rd, 2011, 07:51 AM
  4. Replies: 2
    Last Post: June 15th, 2011, 03:49 PM
  5. Replies: 1
    Last Post: June 11th, 2011, 05:39 AM