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

    Default GUI with RMI Connection.

    Hi all,

    I have written StudentImpl, StudentInterface, StudentServer, StudentClient and StudentGui Classes I have the rmiregistery working but what i need to do is get the student Information which is a name and print it onto the text fields on the GUI.

    Basically what i have is these 5 class whic create 3 students
    Tom Low Street Web 2
    Mary High Street Game 2
    John Middle Street Web 2

    and this info is already defined in the StudentServer.java
    and then is changed to

    Tom Lower Street Web 2
    Mary Higher Street Game 3
    John Middle Street Web 3

    in the StudentClient.java.

    I also have a gui that has 9 text fields each to be populated with a Student (Name, Address, Group) and i have this GUI working i just have no idea how to populate the fields from the client.

    I can post code but thier is a fair amount of it :)

    This is what i have to do with the GUI.
    Create a GUI based RMI client which reads and displays the data from the remote objects. The GUI should use a 4X3 Gridlayout with JTextFields.

    Thanks for the assistance in advance.
    Last edited by Irish Rayray; 02-19-2013 at 05:35 PM.

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

    Default Re: GUI with RMI Connection.

    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:

    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. USB Connection
    By OddOne in forum New To Java
    Replies: 3
    Last Post: 06-01-2012, 01:40 AM
  2. Java.net.socket connection :connection closed
    By veeru541 in forum Advanced Java
    Replies: 2
    Last Post: 06-27-2010, 02:14 AM
  3. FTP connection
    By java2010 in forum New To Java
    Replies: 3
    Last Post: 04-19-2010, 09:46 AM
  4. Replies: 7
    Last Post: 10-20-2009, 10:34 AM
  5. no connection
    By even in forum JDBC
    Replies: 15
    Last Post: 01-02-2008, 01:50 PM

Posting Permissions

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