Results 1 to 5 of 5
  1. #1
    blutao is offline Member
    Join Date
    Jun 2010
    Posts
    9
    Rep Power
    0

    Default JApplet addressbook to store on Oracle

    Well.. I took crash course Java. First time ever and course description was that there was no need to prior java experience. 5 weeks to speak. I have struggled the project which is due tomorrow. I can not get it done. Hopefully, last resort I can get some help here.

    I am required to build a swing applet (japplet) that serves as a addressbook connecting to oracle and saving info. I am allowed to use the following class file and no modification can be done to this file whatsoever. DataObject file can not be modified. I am also given another file as an example ( which more likely need to be modified) that connects the database and uses DataObject file to communicate with the server. that file is client.java. I created my addressbook java file which is also included. In addition I need to make sure there is authentication to the database server as well. I include both client and addresbook GUI that I coded. There is also a server application that is given to me which accepts clients at a port. more likely this app needs no modification.I have no clue on how to put it all together to make this applet work. Can anyone please give me a hand?
    Thank you



    import java.io.*;
    import java.util.*;

    public class DataObject implements Serializable{

    protected String message;

    DataObject(){
    message = "";
    }

    public String getMessage(){
    return message;
    }

    public void setMessage(String inMessage){
    message = inMessage;
    }
    }

    Client file:
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;


    public class Client extends JApplet
    {

    private JButton bt1;
    private JTextArea myText1;
    private JPanel panel1;

    public void init(){
    Client client = new Client();
    }

    public Client(){
    initComp();

    }

    public void initComp()
    {
    Container container = getContentPane();
    container.setLayout(new FlowLayout());

    panel1 = new JPanel();

    bt1 = new JButton("Click Me!");
    panel1.add(bt1);

    myText1 = new JTextArea("");
    panel1.add(myText1);

    container.add(panel1, BorderLayout.NORTH);


    bt1.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent event)
    {
    System.out.println("HELLO WORLD");
    SendToServer();
    }
    });

    setSize(400, 200);
    setVisible(true);

    }
    Last edited by blutao; 12-11-2010 at 05:01 AM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,617
    Rep Power
    25

    Default

    the project which is due tomorrow
    You've left it a little too long.
    Your assignment is so complicated there is no way you'll get all the help you need by tomorrow.

    We'll try to help you fix problems, but not too many here write student assignments for them.

    If you have any specific questions about how to do something, please ask.
    Did you get doc with the DataObject class on how to use it and what it does?

    BTW Please [ code] tags when posting code to preserve the formatting. One of the icons above the text input box will add them.
    Last edited by Norm; 06-28-2010 at 03:00 AM.

  3. #3
    blutao is offline Member
    Join Date
    Jun 2010
    Posts
    9
    Rep Power
    0

    Default

    I guess you are correct. I thought I can study couple of days, understand it and get it done. Not having much of experience is really tough. Back to the project:
    Client. java file was a simple command app( main) that was given by the instructor along with DataObject. I converted the client.java app to an applet. when you look at the code, client.java connects to server which I am including below. all the instructor did was to demonstrate that client.java connects to server( setting localhost and server port on his laptop) using DataObject ( input, output streams). I did the test myself after converting client app to an applet and running the server. It connects fine, but currently what it does is just to send " generic " messages as it is on the codes. One requirement is that we can not change DataObject file. So obviously, my GUI will take inputs ( user name, phone email etc) making a connection to the database and saving it using the file DataObject( so Client.java needs to be coded accordingly). I wish I know any better or have a better understanding on how to put these all together. with the server below might better help to understand. Thank you again. I appreciate. Again these were just generic files given to us during the class as an example.

    [

    import java.io.*;
    import java.net.*;

    public class ThreadedDataObjectServer
    { public static void main(String[] args )
    {

    try
    { ServerSocket s = new ServerSocket(3169);

    for (;;)
    { Socket incoming = s.accept( );
    new ThreadedDataObjectHandler(incoming).start();

    }
    }
    catch (Exception e)
    { System.out.println(e);
    }
    }
    }

    class ThreadedDataObjectHandler extends Thread
    { public ThreadedDataObjectHandler(Socket i)
    {
    incoming = i;
    }

    public void run()
    { try
    { ObjectInputStream in =
    new ObjectInputStream(incoming.getInputStream());

    ObjectOutputStream out =
    new ObjectOutputStream(incoming.getOutputStream());

    myObject = (DataObject)in.readObject();

    System.out.println("Message read: " + myObject.getMessage());

    myObject.setMessage("Got it!");

    System.out.println("Message written: " + myObject.getMessage());

    out.writeObject(myObject);

    in.close();

    out.close();


    incoming.close();

    }
    catch (Exception e)
    { System.out.println(e);
    }
    }

    DataObject myObject = null;
    private Socket incoming;

    }

    ]

  4. #4
    blutao is offline Member
    Join Date
    Jun 2010
    Posts
    9
    Rep Power
    0

    Default

    Norm,
    Here is the project description. Hope this can make you understand better.
    Thanks
    BTW. Saving the addressbook as a file on the server also accepted.







    You are to implement an online address book system that allows you store and retrieve information about other individuals and groups. Minimally, your system should be implemented to comply with the five following rules:

    1) You MUST use the provided DataObject class for all communication between your client applet and your server. You are NOT ALLOWED to change the DataObject class in any way.

    2) I gave you the skeleton for a basic client-server system. You must convert it and add whatever is necessary to allow your online system to work on your AFS account. The client must be an applet embedded in a web page – only one applet allowed. DO NOT pop up new applet in a frame.

    3) You must implement persistence. That means you must save some information on the server. Store information in either: 1) files on the server or 2) in a database.

    4) Your system should have at least two levels of access: 1) personal/private, and 2) group/world.

    5) If you completely adhere to all of the above rules, you will have earned 80% of the total possible points for the project. The remaining 20 points will be based on the overall appearance and operation of the system. The user interface should be attractive and intuitive. The system should function and appear substantially as a professional system (and not a hacked-together student project).

    6) I will award extra credit for the following features:

    a. Use Swing for the graphical user interface.
    b. Use a database rather than files for storing information on the server.
    c. Use advanced Swing widgets such as JTree and JTable

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,617
    Rep Power
    25

    Default

    Do you have any specific problems or questions about your assignment?

Similar Threads

  1. JApplet on MAC
    By ld_pvl in forum Java Applets
    Replies: 0
    Last Post: 08-23-2009, 02:40 PM
  2. JFrame to JApplet or JApplet to JApplet
    By ramesh.8189 in forum AWT / Swing
    Replies: 13
    Last Post: 02-08-2009, 07:14 AM
  3. Replies: 0
    Last Post: 08-27-2008, 10:27 AM
  4. help with converting to JApplet
    By Simmy in forum AWT / Swing
    Replies: 2
    Last Post: 08-09-2007, 09:45 AM
  5. JApplet and html
    By paty in forum Java Applets
    Replies: 1
    Last Post: 08-02-2007, 06:41 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
  •