Results 1 to 2 of 2
  1. #1
    Irish Rayray is offline Member
    Join Date
    Apr 2012
    Posts
    21
    Rep Power
    0

    Default GUI JAVA been populated through RMI Server and Client

    Hi All,

    I'm currently having a lot of trouble in getting my GUI to work properly.

    To run these you have to run them through the CMD.
    One window is to run the command "rmic StudentImpl" and then "rmiregistry"
    The next window you run "java StudentServer"
    Then the Last Window is "java StudentClient" and then "java StudentGui"
    Below are pictures of the StudentClient and StudentGui been run through the CMD and then a picture of how i need to GUI to look.
    Client and Gui.bmp
    Lab_8.1_GUI.bmp

    I can get the GUI to open but don't no how to add the data from the Student Client to be displayed in the GUI without just hard coding the data.
    I tried using an action listener but i don't want to be clicking any button i just want the Info to go straight into the text field to inherit the correct information from the Client.
    I have deleted the Action Listener since i don't this is relevant here

    This is my Student GUI code so far
    Java Code:
    import java.awt.event.*;
    
    import javax.swing.*;
    import java.awt.GridLayout;
    
    public class StudentGui extends JFrame
    {
    	private JTextField NameLabel= new JTextField("");
    	private JTextField AddressLabel= new JTextField("");
    	private JTextField GroupLabel= new JTextField("");
    	private JTextField FirstName= new JTextField("");
    	private JTextField SecondName= new JTextField("");
    	private JTextField ThirdName= new JTextField("");
    	private JTextField FirstAddress= new JTextField("");
    	private JTextField SecondAddress= new JTextField("");
    	private JTextField ThirdAddress= new JTextField("");
    	private JTextField FirstGroup= new JTextField("");
    	private JTextField SecondGroup= new JTextField("");
    	private JTextField ThirdGroup= new JTextField("");
    	
    	StudentGui(String s){
    		super(s);
    		
    			getContentPane().setLayout(new GridLayout(4,3));
    			getContentPane().add(NameLabel);
    			getContentPane().add(AddressLabel);
    			getContentPane().add(GroupLabel);
    			getContentPane().add(FirstName);
    			getContentPane().add(FirstAddress);
    			getContentPane().add(FirstGroup);
    			getContentPane().add(SecondName);
    			getContentPane().add(SecondAddress);
    			getContentPane().add(SecondGroup);
    			getContentPane().add(ThirdName);
    			getContentPane().add(ThirdAddress);
    			getContentPane().add(ThirdGroup);
    			
    			setSize(350,150);
    		        setVisible(true);
    	}
    	 public static void main(String[] args){
    		new StudentGui("RMI GUI Client");
    	 }
    }
    This is the Client Code
    Java Code:
    import java.rmi.*;
    
    public class StudentClient
    {
        public static void main(String args[]){
            String url = "rmi:///";
    
            try{
                StudentInterface aTom=(StudentInterface)Naming.lookup(url+"Tom");
                StudentInterface aMary=(StudentInterface)Naming.lookup(url+"Mary");
                StudentInterface aJohn=(StudentInterface)Naming.lookup(url+"John");
    
                System.out.println("Name	Address		Class Group");
            	System.out.println(aTom.getName()+"	"+aTom.getAddress()+"	"+aTom.getGroup());
            	System.out.println(aMary.getName()+"	"+aMary.getAddress()+"	"+aMary.getGroup());
            	System.out.println(aJohn.getName()+"	"+aJohn.getAddress()+"	"+aJohn.getGroup());
                
                System.out.println("\n" + "Changed too:" + "\n" );
    
                aTom.setAddress("Lower Street");
                aMary.setAddress("Higher Street");
                aMary.setGroup("Game 3");
                aJohn.setGroup("Web 3");
                
                System.out.println("Name	Address		Class Group");
            	System.out.println(aTom.getName()+"	"+aTom.getAddress()+"	"+aTom.getGroup());
            	System.out.println(aMary.getName()+"	"+aMary.getAddress()+"	"+aMary.getGroup());
            	System.out.println(aJohn.getName()+"	"+aJohn.getAddress()+"	"+aJohn.getGroup());
    
            }
            catch(Exception e){
                e.printStackTrace();
            }
        }
    }
    I have been trying to figure this out for the past while and have had no luck its prob something easy i just can not see it.

    Thank You.

  2. #2
    Irish Rayray is offline Member
    Join Date
    Apr 2012
    Posts
    21
    Rep Power
    0

    Default Re: GUI JAVA been populated through RMI Server and Client

    Hi all,

    Just in case anyone ever does anything like this this is how i figured it out in the end was quite easy :)


    Java Code:
      
    import java.awt.event.*;
    
    import javax.swing.*;
    import java.awt.GridLayout;
    import java.rmi.Naming;
    
    public class StudentGui extends JFrame
    {
    	private JTextField NameLabel= new JTextField("Name");
    	private JTextField AddressLabel= new JTextField("Address");
    	private JTextField GroupLabel= new JTextField("Group");
    	private JTextField FirstName= new JTextField("");
    	private JTextField SecondName= new JTextField("");
    	private JTextField ThirdName= new JTextField("");
    	private JTextField FirstAddress= new JTextField("");
    	private JTextField SecondAddress= new JTextField("");
    	private JTextField ThirdAddress= new JTextField("");
    	private JTextField FirstGroup= new JTextField("");
    	private JTextField SecondGroup= new JTextField("");
    	private JTextField ThirdGroup= new JTextField("");
    	
    	String url = "rmi:///";
    	
    	StudentGui(String s){
    		super(s);
    		
    			getContentPane().setLayout(new GridLayout(4,3));
    			getContentPane().add(NameLabel);
    			getContentPane().add(AddressLabel);
    			getContentPane().add(GroupLabel);
    			getContentPane().add(FirstName);
    			getContentPane().add(FirstAddress);
    			getContentPane().add(FirstGroup);
    			getContentPane().add(SecondName);
    			getContentPane().add(SecondAddress);
    			getContentPane().add(SecondGroup);
    			getContentPane().add(ThirdName);
    			getContentPane().add(ThirdAddress);
    			getContentPane().add(ThirdGroup);
    			
    			setSize(350,150);
    		    setVisible(true);	 
    		    
    		    try{
    				StudentInterface aTom=(StudentInterface)Naming.lookup(url+"Tom");
    				FirstName.setText(aTom.getName());
    				FirstAddress.setText(aTom.getAddress());
    				FirstGroup.setText(aTom.getGroup());
    				StudentInterface aMary=(StudentInterface)Naming.lookup(url+"Mary");
    				SecondName.setText(aMary.getName());
    				SecondAddress.setText(aMary.getAddress());
    				SecondGroup.setText(aMary.getGroup());
    	            StudentInterface aJohn=(StudentInterface)Naming.lookup(url+"John");
    	            ThirdName.setText(aJohn.getName());
    	            ThirdAddress.setText(aJohn.getAddress());
    	            ThirdGroup.setText(aJohn.getGroup());
    			}catch(Exception a){
    	            a.printStackTrace();
    	        }
    	}
    	  public static void main(String[] args){
    		 new StudentGui("RMI GUI Client");
    	  }
    }

Similar Threads

  1. Replies: 1
    Last Post: 08-12-2011, 06:55 AM
  2. java client-server jmf
    By grayhat555 in forum Networking
    Replies: 0
    Last Post: 03-16-2011, 03:02 AM
  3. Java Server/C Client
    By FallenBlade in forum Networking
    Replies: 13
    Last Post: 03-11-2011, 12:22 AM
  4. Replies: 2
    Last Post: 09-24-2010, 12:31 PM
  5. java server and c client ?????????
    By biebo in forum Networking
    Replies: 7
    Last Post: 07-24-2010, 05:35 AM

Posting Permissions

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