Results 1 to 3 of 3
  1. #1
    dvd_gonzales is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Question i need help with a class and swing

    what im doing is a application for a company that deals with customers. and order , using a database.

    my problem is that i create an class object for the customer main frame ( in witch the frame gets information from the DB ) thath works find . also i press a btn in the customer main frame that opens the order frame and it sends some information to that frame. from that frame i create an order in witch the user puts the order for the specific customer. (thath also work fined )

    the problem is when i want to go back to the main customer frame to create o do somethink else with with the same customer.

    if i create a new object of the customer main frame it will be give me another person. ( i can re load the information form the database but i belive is a waist of time) what i want to do is to be able to hide the customer main frame , and open the order frame and when im done with the order frame . to set the customer main frame visible. i dont know hot to call the function in the customer main frame to set visible from the order frame with out starting another object.


    i hope you can help me and understand what i want to do.

    sorry for my english im just lerning.

    im including sample code ( just the functions that i need help and the classes)

    and im including some pictures to give you a graffic idea of what im trying to do.

    Java Code:
     
    
       public   class Customer_main_frm  extends JFrame {
    
    
    		.
    		.
    		.
    		.
    		.
    		.
    
    
           public void get_values_to_order(){
    
    
    	   // get the values to pass to the order frm from cust db frame
    
    
    
               String customer_Id = cust.get_customer_id();
               String name = cust.get_name();
               String last_name = cust.get_last_name();
               String Company = cust.get_company();
               String Cell_phone = cust.get_Cell_Phone();
               String work_phone = cust.get_workphone();
               String email = cust.get_email();
    
    
    
    
    
    	  // sends values to the order frame
               
              order.get_customer_values_for_order(customer_Id, name, last_name,
    						 Company, Cell_phone, work_phone, email);
    
    
    
    
    
    	  // makes the order frame visible
    
              order.setVisible(true);
    
    
    
    	  // hides the customer main frame
    
              this.setVisible(false);
              
              
    
    
    
    
      } 
    
    
    
           public void setvisible_frm(){
    
    	
    	  // set the customer main frame visible
    
               setVisible(true);
           }
    
    		.
    		.
    		.
    		.
    		.
    
    
    
    } // end of class
    
    
    
    -----------------------------------------------
    
    
    public class Order_frm extends JFrame {
    
    
    		.
    		.
    		.
    		.
    		.
    
    
    
    
    
    
          public void get_customer_values_for_order(String customer_id , String name ,
                String last_name , String company , String cell_phone , String work_phone , String e_mail){
    
           
    
    
           Customer_Id_txtf.setText(customer_id);
           Name_txtf.setText(name);
           Last_Name_txtf.setText(last_name);
           Company_txtf.setText(company);
           Cell_Phone_txtf.setText(cell_phone);
           Work_Phone_txtf.setText(work_phone);
           Email_txtf.setText(e_mail);
    
    
           
           
    
        }
    
    
    	// this is a button listener. after working with the frame 
    	// the user will press the save button and it will save the information int the database
    	// and in this frame ( order frm ) needs to close the frame and re open the frame
    	// of ( customer main ) with the same object and class.
     
    
        private void Save_btnActionPerformed(java.awt.event.ActionEvent evt) {
            
        // from this btn listener it will run a function on the customer frm that will make the
        // frame visible and also it will save the information input here in the database.
            
    
        
            
        }
    
    
    
    		.
    		.
    		.
    		.
    		.
    
    
    } // end of class

    order main frame
    Attached Thumbnails Attached Thumbnails i need help with a class and swing-order-frame.jpg   i need help with a class and swing-main-customer-frame.jpg  

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    If you call setVisible(false) on a frame, it hides itself. If you call setVisible(true), it appears again.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Please don't cross-post the same question in different fora without letting people know. We have already discussed this subject including a recommendation for using JDialog in the sun fora.
    Last edited by Fubarable; 10-25-2009 at 01:13 PM.

Similar Threads

  1. Replies: 7
    Last Post: 05-06-2009, 01:42 PM
  2. Replies: 8
    Last Post: 03-21-2009, 10:34 AM
  3. Java Swing class capturing output to the console
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-12-2008, 12:24 PM
  4. Replies: 5
    Last Post: 01-03-2008, 08:54 AM
  5. map javax.swing.text.Element to javax.swing.text.View
    By elizabeth in forum New To Java
    Replies: 1
    Last Post: 07-30-2007, 08:02 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •