ObjectInputStream problems

Hi
I'm getting slightly desperate after 3 days stuck with the same problem.
I'm writing a small client server application that contains a chat room. when I use a printwriter combined with a BufferedReader on the sockets everything works perfectly.
However, I need to send objects to keep a state for some additinbal functionality, and when I change the printwriter/BufferedReader to a ObjectOutputStream/ObjectInputStream I keep getting a StreamCorruptedException on the client.
It goes like this. As long as I keep sending objects from the server, the client receives them well, but as soon as the server stop sending (waiting for som GUI interaction) I get the exception. As I understand it, the program is supposed to wait at the in.readUTF(); line and then continue when it receives data, but it doesn't wait. It just throws an exception as soon as it stops receiving data.
I don't think it has anything to do with the read method. Apparently it is the ObjectInputStream complaing when receiving no data.
Does anyone have an explanition for this?

I'm not sure exactly how you're "changing the printwriter/BufferedReader to a ObjectOutputStream/ObjectInputStream", but the problem is probably that you're sending binary data (ObjectOutputStream) into a text stream (PrintWriter). If you need to send both binary and text data, then I think you will have to set up two sets of streams.

Similar Messages

  • ObjectInputStream problem.

    Hello!
    I have a problem with ObjectInputStream.
    My Servlet code is:
    public class MyServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
    ObjectInputStream inputFromApplet = new ObjectInputStream(request.getInputStream());
    When I call it, I get "The page cannot be displayed".
    But when I write
    InputStreamReader inputFromApplet = new InputStreamReader(request.getInputStream());
    instead, the page is displayed(showing nothing, of cause).
    It doesn't matter whether I call the servlet from applet or from browser. Anyway, here is a part of my Applet code:
    URL DownloadFileServlet = new URL( servletGET );
    URLConnection servletConnection = DownloadFileServlet.openConnection();
    // inform the connection that we will send output and accept input
    servletConnection.setDoInput(false);
    servletConnection.setDoOutput(true);
    // Don't use a cached version of URL connection.
    servletConnection.setUseCaches (false);
    servletConnection.setDefaultUseCaches (false);
    servletConnection.setRequestProperty
    ("Content-type", "application/octet-stream");
    ObjectOutputStream outputToServlet =
    new ObjectOutputStream(servletConnection.getOutputStream());
    String str = "abc";
    outputToServlet.writeObject(str);
    outputToServlet.flush();
    outputToServlet.close();
    Please help me.
    Thank you in advanse.

    Already posted in another forum.

  • Socket ObjectOutputStream or ObjectInputStream problem?

    Hi all!
    I have a problem with sockets and ObjectInputStreams objects: The first time I write into the ObjectOutputStream, the other side (ObjectInputStream) receives the object, the second time the ObjectInputStream doesnt receive it and the third time I've got an exception in the ObjectOutputStream -->
    java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    The objects Im working with are mouse events and here is my code :
    // using a Thread to send packets from a queue 
        public void run(){
             Package pck;
             while(connected){
                 pck = queue.pop();
                 if (pck!=null){
                     sendpck(pck, socketList);
    public void sendpck(Package pck , LinkedList<Socket> list){
            ObjectOutputStream oos = null;
            for(Socket sock: list){
                try {
                    oos = new ObjectOutputStream(sock.getOutputStream()); // 1st time sends, 2nd seems to send, 3rd Exception
                    oos.writeObject(pck);
                    oos.flush();
                } catch (IOException ex) {
                    ex.printStackTrace();
        }The other side code for listening:
    public void prepareListener(Socket socketClient){
            try {
                ois = new ObjectInputStream(socketClient.getInputStream());
            } catch (IOException e) {
                connected = false;
        public void run() {
            while(connected){
                try {
                    Package pack = (Package)ois.readObject();  // recieves only once,
                        // execute Mouse event
                } catch (IOException e) {
                    this.connected=false;
                } catch (ClassNotFoundException e) {
                    this.connected=false;
        }I have doubts because the prepareListener method is called from an static method and I dont know if that could be a problem:
        public static void connectService(Socket clientSocket){
            ClientThread listenerClient = new ClientThread();
            listenerClient.prepareListener(clientSocket);
            if (listenerClient.isConnected()){
                Thread myThread = new Thread(listenerClient);
                myThread.start();
        }I hope I was clear..... please I need your help....
    Thanks in advance
    Edited by: Pogasu on May 10, 2009 8:13 PM

    Thanks for answering!
    You were right, i was ignoring an exception on the client side: java.io.StreamCorruptedException: invalid type code: AC.
    I create one ObjectOutputStream for each socket from my socketlist each time i want to send and for listening doesnt the thread starts with an InputStream. As I Understand, my problem is that the InputStream has a connection only with one OutputStream and the next time i want to write something I create another OutputStream that isnt the original one. Am I right? What I should have is a list of created OutputStreams instead of sockets?

  • A problem with ObjectInputStream

    I am a coding newbe and I recently tried to write a very simple app - an engine to send and recive objects through the net. This is what i get:
    //Serwer class:
    import java.net.*;
    import java.io.*;
    public class Serwer {
    public Serwer() {
    try {
    ServerSocket serw = new ServerSocket(23);
    System.out.println("Server up and running");
    while (true) {
    Socket soc = serw.accept();
    Obsluga obs = new Obsluga(soc);
    obs.start();
    catch (Exception e) {
    System.out.println(e);
    public static void main(String[] args)
    Serwer serwer = new Serwer();
    class Obsluga extends Thread {
    private Socket soc;
    public Obsluga(Socket soc) {
    this.soc = soc;
    public void run() {
    try {
    System.out.println("Connected from: " + soc.getInetAddress());
    ObjectOutputStream out = new ObjectOutputStream(
    new BufferedOutputStream(soc.getOutputStream()));
    //ObjectInputStream in = new ObjectInputStream(
    //new BufferedInputStream(soc.getInputStream()));
    //Here's the problem
    int i = 1;
    while(i<100) {
    Ob obiekt = new Ob(i,"text");
    out.writeObject(obiekt);
    i++;
    out.close();
    catch (IOException ex) {
    ex.printStackTrace();
    class Ob implements Serializable {
    private int number;
    private String text;
    public Ob(int number, String text) {
    this.number = number;
    this.text = text;
    public Ob() {
    public int getNumber() {
    return number;
    public String getText() {
    return text;
    public void setNumber(int i) {
    number = i;
    public void setText(String s) {
    text = s;
    //Client class:
    import java.io.*;
    import java.net.Socket;
    public class Klient {
    public Klient() {
    public static void main(String[] args) {
    ObslugaKlienta obsK = new ObslugaKlienta();
    obsK.run();
    class ObslugaKlienta extends Thread {
    public ObslugaKlienta() {
    public void run() {
    Ob obiektIn = new Ob();
    try {
    Socket socket = new Socket("localhost", 23);
    ObjectInputStream in = new ObjectInputStream(
    new BufferedInputStream(socket.getInputStream()));
    ObjectOutputStream out = new ObjectOutputStream(
    new BufferedOutputStream(socket.getOutputStream()));
    while (true) {
    obiektIn = (Ob) in.readObject();
    System.out.println(obiektIn.getNumber());
    catch(Exception e) {
    System.out.println(e);
    class Ob implements Serializable {
    private int number;
    private String text;
    public Ob(int number, String text) {
    this.number = number;
    this.text = text;
    public Ob() {
    public int getNumber() {
    return number;
    public String getText() {
    return text;
    public void setNumber(int i) {
    number = i;
    public void setText(String s) {
    text = s;
    The server class simply creates 100 Objects Ob and sends them to waiting Client, which prints the field number from it. And this works.
    The problem is, in my Serwer class, if I try to start new InputStreamReader, to receive Objects Ob from Client, the app stops working. Even if I am not using it anywhere. (u have to uncomment the declaration to see it - where "here is the problem" statment is)
    I think I am missing some theory about sockets. Can anyone clear me with it? And give me a working solution, what should I correct in my code to have both client and server able to exchange Objects?
    Im using jdk 1.6, and running both apps from a single machine.
    Thank you in advance.

    Thank you for the reply.
    I reworked my app: I moved sending and receiving to different Threads, but still I can not manage to get output i wanted to. I get the SocketClosed Exception.
    Server:
    package pakiet;
    import pakiet.Send;
    import pakiet.Receive;
    import java.net.*;
    import java.io.*;
    public class Serwer {
    public Serwer() {
    try {
    ServerSocket serw = new ServerSocket(23);
    System.out.println("Server up and running");
    while (true) {
    Socket soc = serw.accept();
    Obsluga obs = new Obsluga(soc);
    obs.start();
    catch (Exception e) {
    System.out.println(e);
    public static void main(String[] args)
    Serwer serwer = new Serwer();
    class Obsluga extends Thread {
    private Socket soc;
    public Obsluga(Socket soc) {
    this.soc = soc;
    public void run() {
    System.out.println("Connection from: " + soc.getInetAddress());
    new Receive(soc).start();
    new Send(soc).start();
    Client:
    package pakiet;
    import pakiet.Send;
    import pakiet.Receive;
    import java.io.*;
    import java.net.Socket;
    public class Klient {
    public Klient() {}
    public static void main(String[] args) {
    ObslugaKlienta obsK = new ObslugaKlienta();
    obsK.start();
    class ObslugaKlienta extends Thread {
    public ObslugaKlienta() {}
    public void run() {
    try {
    Socket socket = new Socket("localhost", 23);
    new Receive(socket).start();
    new Send(socket).start();
    catch(Exception e) {
    System.out.println(e);
    Send:
    package pakiet;
    import java.io.BufferedOutputStream;
    import java.io.ObjectOutputStream;
    import java.net.Socket;
    class Send extends Thread {
    Socket socket;
    public Send(Socket socket) {
    this.socket = socket;
    public void run() {
    try {
    System.out.println("Thread Send activated");
    ObjectOutputStream out = new ObjectOutputStream(
    new BufferedOutputStream(socket.getOutputStream()));
    int i = 1;
    while(i<10) {
    Ob obiekt = new Ob(i,"tekst");
    out.writeObject(obiekt);
    sleep(100);
    i++;
    catch(Exception e) {
    System.out.println(e);
    Receive:
    package pakiet;
    import java.io.BufferedInputStream;
    import java.io.ObjectInputStream;
    import java.net.Socket;
    class Receive extends Thread {
    Socket socket;
    public Receive(Socket socket) {
    this.socket = socket;
    public void run() {
    try {
    System.out.println("Thread Receive activated");
    ObjectInputStream in = new ObjectInputStream(
    new BufferedInputStream(socket.getInputStream()));
    int i = 1;
    while(i<10) {
    Ob obiekt = (Ob) in.readObject();
    System.out.println(obiekt.getNumber());
    sleep(500);
    i++;
    catch(Exception e) {
    System.out.println(e);
    My goal is to receive Ob numbers simultaneously in both server and client output window. Now i got massage in both client and sever that Thread Send and Receive is activated, but nothing happends afterwards.
    I know its a lot of code, so I bolded the parts I consider most important.

  • Problem with reading objects through ObjectInputStream

    HI
    Actually i have a problem of reading the objects from ObjectInputStream and getting StreamCorruptedException when i try to read as there is no limit to find the end of file i think iam getting the exception any suggestions please to overcome this problem..

    Of course I can, I have included two classes.
    MyMap that I shall store values in and then save to disk.
    Test Map that I stores one value in MyMap and then
    serialize to disk and the I do the reverse and se if my value is still there. Check out for yourself and please dont hestate to ask if you have trouble using it.
    import java.util.HashMap;
    import java.io.Serializable;
    * This class must implement Serializable to be stored in disk
    * with write(Object)
    public class MyMap implements Serializable
      private HashMap map = new HashMap();
      public void put(Serializable key, Serializable value)
        map.put(key,value);
      public Object get(Object key)
        return map.get(key);
    // Second class
    import java.io.*;
    public class TestMap
      public TestMap()
        try
          showHowToUseSerialize();
        catch(Throwable ignored)
          ignored.printStackTrace();
      private void showHowToUseSerialize()throws Throwable
        // First store anything to the class MyMap
        MyMap myMap = new MyMap();
        //  When yuo use put on it it only accept Serializable
        //  se how in the class
        myMap.put("key1","This is the first object in MyMap");
        // Then serialize it to disk.
        serialize(myMap);
        // Now you try to retreive from the file and see if you
        // can get the value key1 stored inside it.
        Object object = deserialize();
        // Cast it to the kind of object you have stored there.
        MyMap mapFromDisk = (MyMap)object;
        // See if key1 is really there.
        String value = (String)mapFromDisk.get("key1");
        // Print it out just be sure...
        System.out.println("key1 stored in MyMap in disk is: "+value);
      private Object deserialize()throws Throwable
        File f = new File("C:\\temp\\mymap.ser");
        if(!f.exists())
        { // Check that there really is such serialized file.
          throw new FileNotFoundException("Didnt find the serialized file: "+f);
        FileInputStream in = new FileInputStream(f);
        ObjectInputStream objIn = new ObjectInputStream(in);
        // Read in the object from the file.
        return objIn.readObject();
      private void serialize(Object myMap) throws Throwable
        File f = new File("C:\\temp\\mymap.ser");
        if(!f.exists())
          f.createNewFile();
        FileOutputStream out = new FileOutputStream(f);
        ObjectOutputStream objOut = new ObjectOutputStream(out);
        objOut.writeObject(myMap);
        objOut.close();
      public static void main(String[] args)
        new TestMap();
    }

  • Problem with fetching Map object from ObjectInputStream

    Hi, please can you help me with the following...I've never seen this before (with my limited experience of JDK1.5)
    ObjectInputStream is = new ObjectInputStream(new FileInputStream(store));
    Map<Integer, Report> readObject = (Map<Integer, Report>) is.readObject();This code gives me a warning...
    Type safety: The cast from Object to Map<Integer,Report> is actually checking against the erased type Map
    How can I get rid of this warning?

         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream( baos );
         List<String> list = new LinkedList<String>();
         list.add( "one" );
         list.add( "two" );
         oos.writeObject( list );
         oos.flush(); oos.close();
         ObjectInputStream ois = new ObjectInputStream
             ( new ByteArrayInputStream( baos.toByteArray() ) );
         List<String> list2 = (List<String>)ois.readObject();Give me 1 compile time error (Test.java:109: warning: [unchecked] unchecked cast), and no runtime errors.
    Removing the <String> from "list" add some more [uncheked], but still runs fine (no runtime warning). Adding a none-String only causes a problem when I try to "get" it. (class cast).
    When do you get this warning?

  • Problem to calling readObject(java.io.ObjectInputStream) using reflection

    Hi,
    I am facing the following problem
    I have an Employee class its overridden the following below methods
    private void readObject(java.io.ObjectInputStream inStream) {
         inStream.defaultReadObject();
    I am trying to call this method using reflection.
    my code is like this
         Class fis= Class.forName("java.io.FileInputStream");
         Constructor fcons = fis.getConstructor(new Class[]{String.class});
         Object fisObj = fcons.newInstance(new Object[]{"C:\\NewEmployee.ser"});
         Class ois= Class.forName("java.io.ObjectInputStream");     
         Constructor ocons = ois.getDeclaredConstructor(new Class[]{InputStream.class});
         Object oisObj = ocons.newInstance(new Object[] {fisObj});
         Method readObj = aClass.getDeclaredMethod("readObject", new Class[]{ois});
         readObj.setAccessible(true);
         Object mapObj = readObj.invoke(employeeObj,new Object[]{oisObj});
    The above code is call the readObject method, but it is failing while executing inStream.defaultReadObject() statement
    I am getting the following exception
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at HackEmployee.reflect(HackEmployee.java:49)
    at HackEmployee.main(HackEmployee.java:131)
    Caused by: java.io.NotActiveException: not in call to readObject
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:474)
    at Employee.readObject(Employee.java:77)
    ... 6 more
    can anybody help me?
    ~ murali

    Hi,
    Here is the simple example.
    public class Employee implements Serializable {
    static final long serialVersionUID = 1L;
    static final int _VERSION = 2;
    private int eno;
    private String empName;
         private String paaword;
         private void readObject(java.io.ObjectInputStream inStream)
    throws IOException, ClassNotFoundException {
         int version = 0;
         BufferedInputStream bis = new BufferedInputStream(inStream);
         bis.mark(256);
         DataInputStream dis = new DataInputStream(bis);
         try {
              version = dis.readInt();
              Debug.println(Debug.INFO, _TAG, "Loading version=" + version);
         } catch(Exception e) {
              dis.reset();
         switch(version) {
              case 0:
              case 1:
                   inStream.defaultReadObject();
                   migrateDefaultEmployeeToEncryptionPassword();
                   break;
              case _VERSION:
                   inStream.defaultReadObject();
                   break;
              default:
                   throw new IOException("Unknown Version :" + version);
         private void writeObject(ObjectOutputStream aOutputStream)
    throws IOException {
         aOutputStream.writeInt(_VERSION);
         aOutputStream.defaultWriteObject();
    Now I am writing a tool that need to read data and print all the field and values in a file.
    So I am trying the same with reflecton by calling readObject(ObjectInputStream inStream).
    But here I am facing the problem, it is geving java.lang.reflect.InvocationTargetException while calling migrateDefaultEmployeeToEncryptionPassword(.
    Hope you got my exact scenerio.
    Thanks for your replay
    ~ Murali

  • ObjectOutputStream/ObjectInputStream/Socket Problem

    I make request on a server with socket connection.
    I want to use one socket open connection.
    So, I don't close the socket.
    This is like that :
    public void serverConnection()
    try
    DataOutputStream out = new DataOutputStream(s.getOutputStream());
    ObjectOutputStream objectOutStream = new ObjectOutputStream(out);
    objectOutStream.writeObject(configConnection);
    DataInputStream in = new DataInputStream(s.getInputStream());               
    ObjectInputStream objectInStream = new ObjectInputStream(in);
    arrayBlocks = (BFTransactionBlock[]) objectInStream.readObject();
    } catch (Exception e)
    valid = false;
    System.out.println("Error " + e);
    When I use this funtion more then one time with the same socket, the prorgam wait an the instruction :
    ObjectInputStream objectInStream = new ObjectInputStream(in);
    I use objectInStream.close() ...
    But it create an other problem : i lost the socket connection.
    What's the solution ?

    You don't need a new input stream for the same socket. You just need to read the data off of the original socket.
    DataInputStream in = new DataInputStream(s.getInputStream());
    ObjectInputStream objectInStream = new ObjectInputStream(in);The above code is fine. You need to loop through the code below until you are done with the socket. Then you close the socket. If you close the stream, you will close the underlying socket.
    arrayBlocks = (BFTransactionBlock[]) objectInStream.readObject();

  • ObjectInputStream JXTA problem

    I'm trying to read an object from an ObjectInputStream (created from a JxtaSocket) like this:
    Object obj = ois.readObject();
    If the object is a String Object everything works just fine!
    If the object for example is an ImageIcon, Integer or a custom object that is serializable I get a:
    java.io.StreamCorruptedException
         at java.io.ObjectInputStream.readObject()
    what is wrong ?

    and this is the client related stuff ,
    the problem accures in the out.writeObject(t) ,
    i have an SocketException , and it says :
    "socket write error ".
    what can it be ?
    public void init(){
         t=new Merkava();//temp , for checking
         System.out.println("Client: initializing");
         try{
           addr=InetAddress.getByName("localhost");
        }catch(IOException e){System.out.println("Client: unable to recieve address");}
         try{
             s=new Socket(addr,Server.PORT);
        }catch(IOException e){System.out.println("Client: unable to create socket");}
         try{
             out=new ObjectOutputStream((s.getOutputStream()));
        }catch(IOException e){System.out.println("Client: unable to create outputstream");}
         try{
          recv=new RecieveData(s);
        }catch(IOException e){System.out.println("Client: unable to create inputstream");}
       System.out.println("Client: initializing finished");
       public void start(){
         try{
           out.writeObject(t); //registers the tank in the server
         //  System.out.println("Client: registerd tank");
    //THE PROBLEM ACCURES HERE!!!!!!    
    }catch(IOException e){
               System.out.println("Client: unable to send data");}
             if(runner==null){
             runner=new Thread(this);
             runner.start();
       }

  • ObjectInputStream - ObjectOutputStream, socket problem

    Hello,
    I'm tring to send and receive some object between a client and a server application.
    When the client application send an object the server is stock.
    This is a part of the server code:
    try
    inObj = new ObjectInputStream(client.getInputStream()); /// here the server program is stock
         mes1 = (Message) inObj.readObject();
         System.out.println(mes1);
         out.println("end");
    catch (ClassNotFoundException e)
    e.printStackTrace();
    catch(IOException e)
         e.printStackTrace();
    The client code:
    try
         in=new BufferedReader(new InputStreamReader(soclu.getInputStream()));
         out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(soclu.getOutputStream())),true);
         outObj = new ObjectOutputStream(soclu.getOutputStream());
         out.print("Info");
         //          out.flush();
         outObj.writeObject(m1);
         outObj.flush();
         raspuns = in.readLine();
         System.out.println(raspuns);
         System.out.println("Closing the communication!");
         out.print("end");
         out.close();
         in.close();
         outObj.close();
         soclu.close();
    catch(IOException e)
         System.out.println("Problems Tx/Rx");
         e.printStackTrace();
    The class Message implements Serializable
    if there is somebody hwo cold help me I appreciate that.
    Thnak you,
    aclaudia1

    You should not be opening both a PrintWriter and an ObjectOutputStream on the same socket. You should use a single stream to do all the output on the socket.

  • Problem in loading Objects using ObjectInputStream

    Hello,
    This method load data from the secondary memory/
    public void load() throws Exception
    //File dataFile = new File(".\\center.dat");
    //if (dataFile.exists())
    ObjectInputStream in = null;
    in = new ObjectInputStream(new
    FileInputStream("center.dat"));
    System.out.println("Open file for reading");
    if(in == null)
    System.out.println("File does not open correctly");
    //Load courses
    courses = (CourseList)in.readObject();
    System.out.println("Successfully read courses of the system");
    //Load Modules
    modules = (ModuleList)in.readObject();
    System.out.println("Successfully read modules of the system");
    //Load Batches
    batches = (BatchList)in.readObject();
    System.out.println("Successfully read batches of the system");
    //Load Candidates
    candidates = (CandidateList)in.readObject();
    System.out.println("Successfully read candidates of the system");
    in.close();
    System.out.println("Close objects file");
    As i print the message of the exception it print Code excepting
    I get this exception when i call readObject method and i had checked Object of ObjectInputStream i.e. in is not null.
    Please help me

    1) Stick to your thread: http://forum.java.sun.com/thread.jspa?threadID=651247
    2) What's the stack trace?

  • Problem with Pushlet (and/or Thread Competition?)

    Hi all,
    Once again, I'm in over my head and have approximately four hours to dig myself out.
    I have a client-server application. One the client side is an Applet that runs Java 3D and has a JavaPushletClient / JavaPushletClientListener pair (from Pushlet Framework). All of the code is executed on either the AWT Event DIspatching Thread, the Java 3D InputDeviceScheduler thread, and the JavaPushletClient thread (none of the code on the latter is mine, it's part of the Pushlet Framework).
    On the ServerSide, I have subclasses Pushet and Postlet of the Pushlet Framework.
    I have one client sending information to the Server (via HTTP Get Request). This is occuring on the Java 3D InputDeviceScheduling thread. It sends information to the server roughly every 35 ms (This was not predetermined - it cannot be. This was measured). The Server is recieving these messages and sending them to the Publisher at the same rate (every 35 ms, again by measuring). When the information is published to other clients, it appears that the pushlet client waits 200 ms, reacts to all of the messages (roughly 6 in 200 ms) that have accumulated at once, and waits another 200 ms.
    This system is intended to display real time information at a rate of no worse than 50 ms (this is for animation purposes, roughly 20 fps).
    I can't figure out where this problem is coming from, or why. I have read through the Pushlet source code, and it indicates that everything should really be continuous.
    Here's what I think MIGHT be happening:
    the PushletClientLoop is sort of like this:
    while (true) {
              message = objectInputStream.readObject();
              theListener.event(message);
    }I wondered if it was possible that when it attempts to read an object, it blocks because one is not available, and transfers processing to another thread, and does not recieve processing time for another 200 ms.
    If that is the case, (given that all the other code is scheduled by Java 3D and the AWT Event Dispatching thread), how can I make sure that this JavaPushletClient thread gets processing time at least every 50 ms.
    OR, I could be way off. This problem could be caused by something else altogether. Any ideas?
    At any rate, I really need help here. This is my final day on this project, and the presedent of our company wants to see the results next Tuesday. AND, (because my company is part of the Canadian Gov't), it's possible that the Prime Minister of Canada will be present for the Demo Tuesday. So I really need this to work. Lots of Dukes up for grabs on this one!
    - Adam

    Here's what I think MIGHT be happening: ......
    I wondered if it was possible that when it attempts to read an object, it
    blocks because one is not available, and transfers processing to another
    thread, and does not recieve processing time for another 200 ms.yes, objectInputStream.readObject(); will block the thread until there is:
    a) an object to read or
    b) the stream is closed and an exception is thrown.
    The JavaPushletClient doesn't run in the event dispatch thread. It runs in it's own thread. I'm sure of that, I've used it before. Unless you are doing something wrong, but I'm not sure how, cuz you just use the JavaPushletClient class and have your own listener class. That doesn't mean it's no the event dispatch thread, though.
    Pushlets send probe messages frequently, although every 35 ms, I dont' know if it's that frequent (if that's what you mean).
    You could update the priority of the thread in the JavaPushletClient. But exact scheduling of threads in Java is tricky. I'm not sure there's a way to guaranty what you want. Up the priority, and see what happens.
    It's very well possible that other threads are doing stuff for 200 ms and not giving up control. Likely I'd say. Although if it's consistently 200 ms, that sounds weird.
    It maybe doesn't matter, though, that it runs every 50 ms, cuz you're UI display isn't likely to be that responsive anyway.

  • Problem to get Mission Control 3.0.1 running with JBoss 4.2.2GA

    Hello,
    I'm using JRockit R27.04 to run JBoss 4.2.2GA with the following VM parameters:
    -Xmanagement:ssl=false,authenticate=false,port=7091,autodiscovery=true -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl -Djboss.platform.mbeanserver
    It's working fine but when I try to use any feature of Mission Control (console, memleak, JRA, ...) pointing to JBoss, I get a ClassNotFoundException:
    Could not open Memory Leak Detector for (1.6) org.jboss.Main (4460).
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
         java.lang.ClassNotFoundException: org.apache.xerces.dom.DeferredElementImpl (no security manager: RMI class loader disabled)
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
         java.lang.ClassNotFoundException: org.apache.xerces.dom.DeferredElementImpl (no security manager: RMI class loader disabled)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:178)
         at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
         at javax.management.remote.rmi.RMIConnectionImpl_Stub.getMBeanInfo(Unknown Source)
         at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getMBeanInfo(RMIConnector.java:1037)
         at com.jrockit.console.rjmx.RJMXConnection.getMBeanInfos(RJMXConnection.java:279)
         at com.jrockit.console.rjmx.RJMXConnection.getMBeanInfos(RJMXConnection.java:314)
         at com.jrockit.console.rjmx.RJMXConnectorModel.initializeAttributeInfos(RJMXConnectorModel.java:294)
         at com.jrockit.console.rjmx.RJMXConnectorModel.<init>(RJMXConnectorModel.java:99)
         at com.jrockit.console.rjmx.RJMXConnectorModel.<init>(RJMXConnectorModel.java:113)
         at com.jrockit.mc.memleak.ui.RjmxMemleakEditorInput.connect(Unknown Source)
         at com.jrockit.mc.memleak.ui.actions.StartMemleak$1.preConnect(Unknown Source)
         at com.jrockit.mc.browser.utils.PreConnectJob.run(PreConnectJob.java:73)
         at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
    Caused by: java.lang.ClassNotFoundException: org.apache.xerces.dom.DeferredElementImpl (no security manager: RMI class loader disabled)
         at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:375)
         at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
         at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
         at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
         at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
         at java.util.HashMap.readObject(HashMap.java:1157)
         at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.access$300(ObjectInputStream.java:188)
         at java.io.ObjectInputStream$GetFieldImpl.readFields(ObjectInputStream.java:2107)
         at java.io.ObjectInputStream.readFields(ObjectInputStream.java:519)
         at javax.management.modelmbean.DescriptorSupport.readObject(DescriptorSupport.java:1270)
         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
         at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
         at javax.management.modelmbean.ModelMBeanAttributeInfo.readObject(ModelMBeanAttributeInfo.java:524)
         at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
         at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
         at javax.management.MBeanInfo.readObject(MBeanInfo.java:669)
         at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
         at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:155)
         ... 12 more
    If I put xerces in jrockit classpath (putting the jar in jrockit-R27.4.0-jdk1.6.0_02\jre\lib\ext dir) just to workaround ClassNotFoundException and test again I get a new error:
    Could not open Memory Leak Detector for (1.6) org.jboss.Main (4460).
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
         java.io.IOException: unknown protocol: resource
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
         java.io.IOException: unknown protocol: resource
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:173)
         at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
         at javax.management.remote.rmi.RMIConnectionImpl_Stub.getMBeanInfo(Unknown Source)
         at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getMBeanInfo(RMIConnector.java:1037)
         at com.jrockit.console.rjmx.RJMXConnection.getMBeanInfos(RJMXConnection.java:279)
         at com.jrockit.console.rjmx.RJMXConnection.getMBeanInfos(RJMXConnection.java:314)
         at com.jrockit.console.rjmx.RJMXConnectorModel.initializeAttributeInfos(RJMXConnectorModel.java:294)
         at com.jrockit.console.rjmx.RJMXConnectorModel.<init>(RJMXConnectorModel.java:99)
         at com.jrockit.console.rjmx.RJMXConnectorModel.<init>(RJMXConnectorModel.java:113)
         at com.jrockit.mc.memleak.ui.RjmxMemleakEditorInput.connect(Unknown Source)
         at com.jrockit.mc.memleak.ui.actions.StartMemleak$1.preConnect(Unknown Source)
         at com.jrockit.mc.browser.utils.PreConnectJob.run(PreConnectJob.java:73)
         at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
    Caused by: java.io.IOException: unknown protocol: resource
         at java.net.URL.readObject(URL.java:1219)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
         at java.util.HashMap.readObject(HashMap.java:1157)
         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.access$300(ObjectInputStream.java:188)
         at java.io.ObjectInputStream$GetFieldImpl.readFields(ObjectInputStream.java:2107)
         at java.io.ObjectInputStream.readFields(ObjectInputStream.java:519)
         at javax.management.modelmbean.DescriptorSupport.readObject(DescriptorSupport.java:1270)
         at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
         at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
         at javax.management.modelmbean.ModelMBeanAttributeInfo.readObject(ModelMBeanAttributeInfo.java:524)
         at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
         at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
         at javax.management.MBeanInfo.readObject(MBeanInfo.java:669)
         at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
         at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:155)
         ... 12 more
    Can anyone help me?
    Thank's,
    Anderson Souza
    Java/JEE Architect - Brasil

    It was a good attempt, but I'm still getting the same exceptions.
    I tried to create a new service file, and it was successful deployed:
    <?xml version="1.0"?>
    <server>
    <mbean code="bea.jrockit.management.JRockitConsole" name="bea.jrockit.management:type=JRockitConsole">
    </mbean>     
    </server>
    After it I opened JBoss JMX Console and I saw the following mbeans published:
    bea.jrockit.management
    type=Compilation
    type=DiagnosticCommand
    type=GarbageCollector
    type=JRA
    type=JRockitConsole
    type=Log
    type=MemLeak
    type=Memory
    type=PerfCounters
    type=Profiler
    type=Runtime
    So, it appears that all jkrockit MBeans are published, but the problem persist.
    Any other suggestion?
    Thanks,
    Anderson Souza

  • Problem with writing and reading using serialization

    I am having a problem with writing and reading an object that has another object in it. The purpose of the class is to write a order that has multiple items in it. And there will be several orders. This is for an IB project, where one of the requirements is to utilize a hierarchical composite data structure. That is, it is "one that contains more than one element and at least one of the elements is a composite data structure. Examples are, an array or linked list of records, a record that has one field that is another record, or an array". The code is shown below:
    The error produced is
    java.lang.NullPointerException
         at SamsonRubberIndustries.CustomerOrderDetails.createCustOrdDetailsScreen(CustomerOrderDetails.java:150)
         at SamsonRubberIndustries.CustomerOrderDetails$1.run(CustomerOrderDetails.java:78)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    public class CustOrdObject implements Serializable {
         public int CustID;
         public int CustOrderID;
         public Object OrderDate;
         public InnerCustOrdObject[] innerCustOrdObj;
         public float GrandTotal;
         public int MaxItems;
         public CustOrdObject() {}
         public CustOrdObject(InnerCustOrdObject[] innerCustOrdObj,
    int CustID, int CustOrderID, Object OrderDate,
    float GrandTotal, int innerarrlength, int innerarrpos, int MaxItems) {
              this.CustID = CustID;
              this.CustOrderID = CustOrderID;
              this.OrderDate = OrderDate;
              this.GrandTotal = GrandTotal;          
              this.MaxItems = MaxItems;
              this.innerCustOrdObj = new InnerCustOrdObject[MaxItems];
         public InnerCustOrdObject[] getInnerCustOrdObj() {
              return innerCustOrdObj;
         public void setInnerCustOrdObj(InnerCustOrdObject[] innerCustOrdObj) {
              this.innerCustOrdObj = innerCustOrdObj;
         public int getCustID() {
              return CustID;
         public void setCustID(int custID) {
              CustID = custID;
         public int getCustOrderID() {
              return CustOrderID;
         public void setCustOrderID(int custOrderID) {
              CustOrderID = custOrderID;
         public Object getOrderDate() {
              return OrderDate;
         public void setOrderDate(Object orderDate) {
              OrderDate = orderDate;
         public void setGrandTotal(float grandTotal) {
              GrandTotal = grandTotal;
         public float getGrandTotal() {
              return GrandTotal;
         public int getMaxItems() {
              return MaxItems;
         public void setMaxItems(int maxItems) {
              MaxItems = maxItems;
    public class InnerCustOrdObject implements Serializable{
         public int ItemNumber;
         public float UnitPrice;
         public int QuantityRequired;
         public float TotalPrice;
         public InnerCustOrdObject() {}
         public InnerCustOrdObject(int ItemNumber, float
    UnitPrice, int QuantityRequired, float TotalPrice){
              this.ItemNumber = ItemNumber;
              this.UnitPrice = UnitPrice;
              this.QuantityRequired = QuantityRequired;
              this.TotalPrice = TotalPrice;
         public int getItemNumber() {
              return ItemNumber;
         public void setItemNumber(int itemNumber) {
              ItemNumber = itemNumber;
         public int getQuantityRequired() {
              return QuantityRequired;
         public void setQuantityRequired(int quantityRequired) {
              QuantityRequired = quantityRequired;
         public float getTotalPrice() {
              return TotalPrice;
         public void setTotalPrice(float totalPrice) {
              TotalPrice = totalPrice;
         public float getUnitPrice() {
              return UnitPrice;
         public void setUnitPrice(float unitPrice) {
              UnitPrice = unitPrice;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import javax.swing.*;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.DefaultTableModel;
    public class CustomerOrderDetails extends CommonFeatures{
         //TODO
         private static int MAX_ORDERS = 200;
         private static int MAX_ORDERITEMS = 100;
         private static int MaxRecord;
         private static int CurrentRecord = 1;
         private static int currentItem;
         private static int MaxItems;
         private static boolean FileExists, recFileExists;
         private static CustOrdObject[] orderDetails = new CustOrdObject[MAX_ORDERS];
         private static InnerCustOrdObject[] innerCustOrdObj = new InnerCustOrdObject[MAX_ORDERITEMS];     
         private static File OrderDetailsFile = new File("CustOrdDetails.dat");
         private static File OrdRecordNumStore = new File("OrdRecordNumStore.txt");
         private static PrintWriter writeFile;
         private static BufferedReader readFile;
         private static ObjectOutputStream objOut;
         private static ObjectInputStream objIn;
         //Set format for date
         SimpleDateFormat simpleDF = new SimpleDateFormat("dd MM yyyy");
         //--<BEGINNING>--Declaring Interface Variables------------------------------------------//
         private JPanel innertoppanel, innercenterpanel, innerbottompanel, innerrightpanel, innerleftpanel;
         private JLabel CustIDLbl, CustOrderIDLbl, OrderedDateLbl, GrandTotLbl, ItemNumberLbl,UnitPriceLbl, QuantityReqLbl, TotPriceLbl;
         private JTextField CustIDTxt, CustOrderIDTxt, OrderedDateTxt, GrandTotTxt, ItemNumberTxt, UnitPriceTxt, QuantityReqTxt, TotPriceTxt;
         private JButton addrecordbtn, savebtn, externalprevbtn, externalnextbtn, internalprevbtn, internalnextbtn, gotorecordbtn, additemreqbtn;
         //--<END>--Declaring Interface Variables------------------------------------------------//
         public static void main(String[] args) {
              final CustomerOrderDetails COD = new CustomerOrderDetails();
              java.awt.EventQueue.invokeLater(new Runnable() {
                   public void run() {
                        try {
                             UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                             COD.createCustOrdDetailsScreen();
                        } catch (Exception eb) {
                             eb.printStackTrace();
         //--<BEGINNING>--Creating CustomerOrderDetails Screen---------------------------------------//
         public JFrame createCustOrdDetailsScreen() {
              createDefaultFrame();
              mainframe.setSize(800,500);
              createContainerPanel();
              containerpanel.add(createCustOrdDetailsTitle(), BorderLayout.NORTH);
              containerpanel.add(createCustOrdDetailsMainPanel(), BorderLayout.CENTER);
              //containerpanel.add(createCustOrdDetailsLeftNavButtons(), BorderLayout.WEST);
              //containerpanel.add(createCustOrdDetailsRightNavButtons(), BorderLayout.EAST);
              containerpanel.add(createCustOrdDetailsButtons(), BorderLayout.SOUTH);
              mainframe.setContentPane(containerpanel);
              mainframe.setLocationRelativeTo(null);
              mainframe.setVisible(true);
              //--<BEGINNING>--Checks to see whether CRecordNumberStore file exists-------------------------------//
              if (OrdRecordNumStore.exists() == true) {
                   recFileExists = true;
              }else {
                   recFileExists = false;
              if (recFileExists == true) {
                   MaxRecord = readRecordNumber();
                   CurrentRecord = MaxRecord;
                   //readOrder();
                   //readInnerOrderRecord(CurrentRecord);
                   System.out.println("Current Record " +CurrentRecord);
                   System.out.println("Max Record " +MaxRecord);
              }else{
                   MaxRecord = 1;
                   writeRecordNumber(MaxRecord);
                   CustOrderIDTxt.setText(""+MaxRecord);
                   System.out.println("Current Record " +CurrentRecord);
                   System.out.println("Max Record " +MaxRecord);
              //--<END>--Checks to see whether CRecordNumberStore file exists--------------------------------------//
              if(readOrder() != null){
                   orderDetails = (CustOrdObject[]) readOrder();
                 innerCustOrdObj = orderDetails[CurrentRecord].getInnerCustOrdObj();
                   MaxItems = orderDetails[CurrentRecord].getMaxItems();
                   if(CurrentRecord > 1 && CurrentRecord < MaxRecord){
                        externalnextbtn.setEnabled(true);
                        externalprevbtn.setEnabled(true);
                   if(CurrentRecord >= MaxRecord){
                        externalnextbtn.setEnabled(false);
                   getFieldText(CurrentRecord-1);
              }else{
                   orderDetails[CurrentRecord] = new CustOrdObject();
                   currentItem = 1;
              return mainframe;
         //--<END>--Creating CustomerOrderDetails Screen---------------------------------------------//
         public JPanel createCustOrdDetailsTitle(){
              createTitlePanel();
              titlepanel.setBackground(TxtfontColor);
              label.setText("- Customer Order Details -");
              labelpanel.setBackground(TxtfontColor);
              label.setForeground(Color.white);
              createbuttonpanel();
              buttonpanel.setBackground(TxtfontColor) ;
              buttonpanel.add(createReturnToMainMenuButton());
              titlepanel.add(labelpanel, BorderLayout.WEST);
              titlepanel.add(buttonpanel, BorderLayout.EAST);
              return titlepanel;
         public JPanel createCustOrdDetailsMainPanel(){
              createmainpanel();
              mainpanel.setBackground(TxtfontColor);
              mainpanel.setLayout(new BorderLayout());          
              mainpanel.setBorder(BorderFactory.createTitledBorder(""));
              mainpanel.add(createInnerTopPanel(), BorderLayout.NORTH);
              mainpanel.add(createInnerCenterPanel(), BorderLayout.CENTER);
              mainpanel.add(createInnerBottomPanel(), BorderLayout.SOUTH);
              mainpanel.add(createInnerRightPanel(), BorderLayout.EAST);
              mainpanel.add(createInnerLeftPanel(), BorderLayout.WEST);
              return mainpanel;
         public JPanel createInnerTopPanel(){
              innertoppanel = new JPanel(new GridBagLayout());
              innertoppanel.setBackground(TxtfontColor);
              GridBagConstraints GBC = new GridBagConstraints();
              GBC.fill = GridBagConstraints.HORIZONTAL;
              //Setting Font Type and Size
              Font font = new Font("Arial", Font.BOLD, 11);
              CustIDLbl = new JLabel("Customer ID");
              CustIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              CustIDLbl.setFont(font);
              CustIDLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 1;
              innertoppanel.add(CustIDLbl, GBC);     
              CustIDTxt = new JTextField(20);
              CustIDTxt.setEditable(true);
              GBC.gridx = 2;
              GBC.gridy = 1;
              innertoppanel.add(CustIDTxt, GBC);
              GBC.gridx = 3;
              GBC.gridy = 1;
              innertoppanel.add(Box.createHorizontalStrut(220), GBC);
              OrderedDateLbl = new JLabel("Order Date");
              OrderedDateLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              OrderedDateLbl.setFont(font);
              OrderedDateLbl.setForeground(LblfontColor);
              GBC.gridx = 4;
              GBC.gridy = 1;
              innertoppanel.add(OrderedDateLbl, GBC);     
              //Get today's date
              Date todaydate = new Date();
              OrderedDateTxt = new JTextField(simpleDF.format(todaydate), 20);
              OrderedDateTxt.setHorizontalAlignment(JTextField.CENTER);
              OrderedDateTxt.setEditable(false);
              GBC.gridx = 5;
              GBC.gridy = 1;
              innertoppanel.add(OrderedDateTxt, GBC);
              CustOrderIDLbl = new JLabel("Customer Order ID");
              CustOrderIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              CustOrderIDLbl.setFont(font);
              CustOrderIDLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 2;
              innertoppanel.add(CustOrderIDLbl, GBC);
              CustOrderIDTxt = new JTextField(20);
              CustOrderIDTxt.setEditable(false);
              GBC.gridx = 2;
              GBC.gridy = 2;
              innertoppanel.add(CustOrderIDTxt, GBC);
              return innertoppanel;
         public JPanel createInnerCenterPanel(){
              innercenterpanel = new JPanel(new GridBagLayout());
              innercenterpanel.setBackground(TxtfontColor);
              innercenterpanel.setBorder(BorderFactory.createLoweredBevelBorder());
              GridBagConstraints GBC = new GridBagConstraints();
              GBC.fill = GridBagConstraints.HORIZONTAL;
              //Setting Font Type and Size
              Font font = new Font("Arial", Font.BOLD, 11);
              ItemNumberLbl = new JLabel("Item Number");
              ItemNumberLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              ItemNumberLbl.setFont(font);
              ItemNumberLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 1;
              innercenterpanel.add(ItemNumberLbl, GBC);     
              ItemNumberTxt = new JTextField(20);
              GBC.gridx = 2;
              GBC.gridy = 1;
              innercenterpanel.add(ItemNumberTxt, GBC);
              UnitPriceLbl = new JLabel("Unit Price");
              UnitPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              UnitPriceLbl.setFont(font);
              UnitPriceLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 2;
              innercenterpanel.add(UnitPriceLbl, GBC);     
              UnitPriceTxt = new JTextField(20);
              //UnitPriceTxt.setEditable(false);
              GBC.gridx = 2;
              GBC.gridy = 2;
              innercenterpanel.add(UnitPriceTxt, GBC);
              QuantityReqLbl = new JLabel("Quantity Required");
              QuantityReqLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              QuantityReqLbl.setFont(font);
              QuantityReqLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 3;
              innercenterpanel.add(QuantityReqLbl, GBC);     
              QuantityReqTxt = new JTextField(20);
              //QuantityReqTxt.setEditable(false);
              GBC.gridx = 2;
              GBC.gridy = 3;
              innercenterpanel.add(QuantityReqTxt, GBC);
              TotPriceLbl = new JLabel("Total Price");
              TotPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              TotPriceLbl.setFont(font);
              TotPriceLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 4;
              innercenterpanel.add(TotPriceLbl, GBC);     
              TotPriceTxt = new JTextField(20);
              //TotPriceTxt.setEditable(false);
              GBC.gridx = 2;
              GBC.gridy = 4;
              innercenterpanel.add(TotPriceTxt, GBC);
              return innercenterpanel;
         public JPanel createInnerBottomPanel(){
              innerbottompanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
              innerbottompanel.setBackground(TxtfontColor);
              //Setting Font Type and Size
              Font font = new Font("Arial", Font.BOLD, 11);
              GrandTotLbl = new JLabel("Grand Total");
              GrandTotLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              GrandTotLbl.setFont(font);
              GrandTotLbl.setForeground(LblfontColor);
              innerbottompanel.add(GrandTotLbl);
              innerbottompanel.add(Box.createHorizontalStrut(30));
              GrandTotTxt = new JTextField(20);
              innerbottompanel.add(GrandTotTxt);
              return innerbottompanel;
         public JPanel createInnerRightPanel(){
              innerrightpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              innerrightpanel.setBackground(TxtfontColor);
              innerrightpanel.setLayout(new BoxLayout(navrightpanel, BoxLayout.Y_AXIS));
              innerrightpanel.setBorder(BorderFactory.createLoweredBevelBorder());
              innerrightpanel.setLayout(new GridBagLayout());          
              GridBagConstraints GBC = new GridBagConstraints();
              GBC.fill = GridBagConstraints.HORIZONTAL;
              internalnextbtn = new JButton(createNextButtonIcon());
              GBC.gridx = 1;
              GBC.gridy = 1;
              internalnextbtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        //getInnerFieldText(currentItem);
                        internalprevbtn.setEnabled(true);
                        if(currentItem < MaxItems){
                             ++CurrentRecord;
                             //readOrder();
                             //readInnerOrderRecord(CurrentRecord);
                             setInnerFieldText(currentItem);
                             System.out.println(CurrentRecord);//Checking RECORD_NUM
                        if(currentItem == MaxItems){
                             internalnextbtn.setEnabled(false);
              innerrightpanel.add(internalnextbtn, GBC);
              return innerrightpanel;
         public JPanel createInnerLeftPanel(){
              innerleftpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              innerleftpanel.setBackground(TxtfontColor);
              innerleftpanel.setBorder(BorderFactory.createLoweredBevelBorder());
              innerleftpanel.setForeground(Color.BLACK);
              innerleftpanel.setLayout(new GridBagLayout());          
              GridBagConstraints GBC = new GridBagConstraints();
              GBC.fill = GridBagConstraints.HORIZONTAL;
              internalprevbtn = new JButton(createPreviousButtonIcon());
              GBC.gridx = 1;
              GBC.gridy = 1;
              internalprevbtn.addActionListener(new ActionListener(){
                   public void  actionPerformed(ActionEvent evt){
                        //getInnerFieldText(currentItem);
                        internalnextbtn.setEnabled(true);
                        if(currentItem == 1){
                             internalprevbtn.setEnabled(false);
                        if(currentItem > 0){
                             --currentItem;
                             //readOrder();
                             setInnerFieldText(currentItem);
              innerleftpanel.add(internalprevbtn, GBC);
              return innerleftpanel;
         public JPanel createCustOrdDetailsButtons(){
              createbuttonpanel();
              buttonpanel.setBackground(TxtfontColor);
              externalprevbtn = new JButton(createPreviousButtonIcon());
              externalprevbtn.addActionListener(new ActionListener(){
                   public void  actionPerformed(ActionEvent evt){
                        getFieldText(CurrentRecord);
                        externalnextbtn.setEnabled(true);
                        if(CurrentRecord == 1){
                             externalprevbtn.setEnabled(false);
                        if(CurrentRecord > 0){
                             --CurrentRecord;
                             setFieldText(CurrentRecord);
                             System.out.println(CurrentRecord);//Checking RECORD_NUM
              buttonpanel.add(externalprevbtn);
              addrecordbtn = new JButton("Add Record", createAddButtonIcon());
              addrecordbtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        try{
                             MaxRecord = readRecordNumber();
                             MaxRecord++;
                             writeRecordNumber(MaxRecord);
                             //--<BEGINNING>--Clear Fields-------------------------------------------------------//
                             CustIDTxt.setText("");
                             CustOrderIDTxt.setText(""+MaxRecord);
                             //Get today's date
                             Date todaydate = new Date();
                             OrderedDateTxt.setText(""+simpleDF.format(todaydate));
                             ItemNumberTxt.setText("");
                             UnitPriceTxt.setText("");
                             QuantityReqTxt.setText("");
                             TotPriceTxt.setText("");
                             GrandTotTxt.setText("");
                             //--<END>--Clear Fields-------------------------------------------------------------//
                             externalnextbtn.setEnabled(false);
                             externalprevbtn.setEnabled(true);
                             System.out.println(MaxRecord);
                        } catch(Exception ec){ec.printStackTrace();}
              buttonpanel.add(addrecordbtn);
              savebtn = new JButton("Save Data", createSaveButtonIcon());
              savebtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        setFieldText(CurrentRecord);
                        writeOrder();
                        writeRecordNumber(MaxRecord);
                        System.out.println(CurrentRecord);
                        System.out.println(MaxRecord);
              buttonpanel.add(savebtn);
              java.net.URL imageURL_AddRowIcon = CommonFeatures.class.getResource("Icons/edit_add.png");
              ImageIcon AddRowIcon = new ImageIcon(imageURL_AddRowIcon);
              additemreqbtn = new JButton("Add Item", AddRowIcon);
              additemreqbtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        try{
                             //--<BEGINNING>--Clear Fields-------------------------------------------------------//
                             ItemNumberTxt.setText("");
                             UnitPriceTxt.setText("");
                             QuantityReqTxt.setText("");
                             TotPriceTxt.setText("");
                             //--<END>--Clear Fields-------------------------------------------------------------//
                             //CurrentRecord = MaxRecord;
                             currentItem++;
                             setInnerFieldText(currentItem);
                             internalnextbtn.setEnabled(false);
                             internalprevbtn.setEnabled(true);
                             System.out.println(MaxRecord);
                        } catch(Exception ec){ec.printStackTrace();}
              buttonpanel.add(additemreqbtn);
              externalnextbtn = new JButton(createNextButtonIcon());
              externalnextbtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        getFieldText(CurrentRecord);
                        externalprevbtn.setEnabled(true);
                        if(CurrentRecord < MaxRecord){
                             ++CurrentRecord;
                             setFieldText(CurrentRecord);
                             System.out.println(CurrentRecord);//Checking RECORD_NUM
                        if(CurrentRecord == MaxRecord){
                             externalnextbtn.setEnabled(false);
              buttonpanel.add(externalnextbtn);
              return buttonpanel;
         //TODO
         public void setFieldText(int orderID){//TODO
              orderDetails[orderID].setCustID(Integer.parseInt(CustIDTxt.getText()));
              orderDetails[orderID].setCustOrderID(Integer.parseInt(CustOrderIDTxt.getText()));
              orderDetails[orderID].setOrderDate(OrderedDateTxt.getText());
              orderDetails[orderID].setInnerCustOrdObj(innerCustOrdObj);
              orderDetails[orderID].setMaxItems(MaxItems);
              setInnerFieldText(currentItem);
              orderDetails[orderID].setGrandTotal(Float.parseFloat(GrandTotTxt.getText()));
         public void setInnerFieldText(int currentItem){//TODO
              innerCustOrdObj[currentItem] = new InnerCustOrdObject();
              innerCustOrdObj[currentItem].setItemNumber(Integer.parseInt(ItemNumberTxt.getText()));
              innerCustOrdObj[currentItem].setUnitPrice(Float.parseFloat(UnitPriceTxt.getText()));
              innerCustOrdObj[currentItem].setQuantityRequired(Integer.parseInt(QuantityReqTxt.getText()));
              innerCustOrdObj[currentItem].setTotalPrice(Float.parseFloat(TotPriceTxt.getText()));
         public void getFieldText(int orderID){
              CustIDTxt.setText(Integer.toString(orderDetails[orderID].getCustID()));
              CustOrderIDTxt.setText(Integer.toString(orderDetails[orderID].getCustOrderID()));
              OrderedDateTxt.setText(""+orderDetails[orderID].getOrderDate());          
              currentItem = orderDetails[orderID].getMaxItems();
              System.err.println("currentItem" + currentItem);
              getInnerFieldText(currentItem);
              GrandTotTxt.setText(Float.toString(orderDetails[orderID].getGrandTotal()));
         public void getInnerFieldText(int currentItem){
              ItemNumberTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getItemNumber()));
              UnitPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getUnitPrice()));
              QuantityReqTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getQuantityRequired()));
              TotPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getTotalPrice()));
         public void writeOrder(){//TODO
              try {
                   objOut = new ObjectOutputStream(new FileOutputStream(OrderDetailsFile));
                   objOut.writeObject(orderDetails);
                   System.out.println("WORKING!");
                   objOut.flush();
                   objOut.close();
              } catch (IOException e) {
                   e.printStackTrace();
         public Object readOrder(){
              Object temporaryObj;
              try{
                   objIn = new ObjectInputStream(new FileInputStream(OrderDetailsFile));
                   temporaryObj = objIn.readObject();               
                   CustOrdObject[] blah = (CustOrdObject[]) temporaryObj;
                   System.out.println("Outer: "+blah[1].getCustID());
                   InnerCustOrdObject[] whee = blah[1].getInnerCustOrdObj();
                   System.out.println("Inner: "+whee[1].getItemNumber());
                   objIn.close();
                   System.out.println("Read Worky!");
                   return temporaryObj;
              }catch(Exception e){
                   e.printStackTrace();
                   System.out.println("Read No Worky!");
                   return null;
         public void writeRecordNumber(int MaxRecord){
              try{
                   objOut = new ObjectOutputStream(new FileOutputStream(OrdRecordNumStore));
                   objOut.writeObject(MaxRecord);
                   System.out.println("WORKING!");
                   objOut.flush();
                   objOut.close();
              }catch(Exception e){e.printStackTrace();}
         public int readRecordNumber() {
              try {
                   objIn = new ObjectInputStream(new FileInputStream(OrdRecordNumStore));
                   int temporaryObj = Integer.parseInt(objIn.readObject().toString());
                   objIn.close();
                   System.out.println("Read Number Worky!");
                   return temporaryObj;
              } catch (Exception e) {
                   e.printStackTrace();
                   System.out.println("Read Number No Worky!");
                   return -1;
    }Message was edited by:
    Kilik07
    Message was edited by:
    Kilik07

    ok i got reading to work to a certain extent... but the prob is i cnt seem to save my innerCustOrdObj proprly...when ever i look for a record using the gotorecordbtn, the outerobject, which is the orderDetails, seems to change but the innerCustOrdObj remains the same... heres the new code..
    public class CustomerOrderDetails extends CommonFeatures{
         //TODO
         private static int MAX_ORDERS = 200;
         private static int MAX_ORDERITEMS = 100;
         private static int MaxRecord;
         private static int CurrentRecord = 1;
         private static int currentItem;
         private static int MaxItems = 1;
         private static boolean FileExists, recFileExists;
         private static boolean RecordExists;
         private static CustOrdObject[] orderDetails = new CustOrdObject[MAX_ORDERS];
         private static InnerCustOrdObject[] innerCustOrdObj = new InnerCustOrdObject[MAX_ORDERITEMS];     
         private static File OrderDetailsFile = new File("CustOrdDetails.ser");
         private static File OrdRecordNumStore = new File("OrdRecordNumStore.txt");
         private static PrintWriter writeFile;
         private static BufferedReader readFile;
         private static ObjectOutputStream objOut;
         private static ObjectInputStream objIn;
         //Set format for date
         SimpleDateFormat simpleDF = new SimpleDateFormat("dd MM yyyy");
         //--<BEGINNING>--Declaring Interface Variables------------------------------------------//
         private JPanel innertoppanel, innercenterpanel, innerbottompanel, innerrightpanel, innerleftpanel;
         private JLabel CustIDLbl, CustOrderIDLbl, OrderedDateLbl, GrandTotLbl, ItemNumberLbl,UnitPriceLbl, QuantityReqLbl, TotPriceLbl;
         private JTextField CustIDTxt, CustOrderIDTxt, OrderedDateTxt, GrandTotTxt, ItemNumberTxt, UnitPriceTxt, QuantityReqTxt, TotPriceTxt;
         private JButton addrecordbtn, savebtn, externalprevbtn, externalnextbtn, internalprevbtn, internalnextbtn, gotorecordbtn, additemreqbtn;
         //--<END>--Declaring Interface Variables------------------------------------------------//
         public static void main(String[] args) {
              final CustomerOrderDetails COD = new CustomerOrderDetails();
              java.awt.EventQueue.invokeLater(new Runnable() {
                   public void run() {
                        try {
                             UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                             COD.createCustOrdDetailsScreen();
                        } catch (Exception eb) {
                             eb.printStackTrace();
         //--<BEGINNING>--Creating CustomerOrderDetails Screen---------------------------------------//
         public JFrame createCustOrdDetailsScreen() {
              createDefaultFrame();
              mainframe.setSize(800,500);
              createContainerPanel();
              containerpanel.add(createCustOrdDetailsTitle(), BorderLayout.NORTH);
              containerpanel.add(createCustOrdDetailsMainPanel(), BorderLayout.CENTER);
              //containerpanel.add(createCustOrdDetailsLeftNavButtons(), BorderLayout.WEST);
              //containerpanel.add(createCustOrdDetailsRightNavButtons(), BorderLayout.EAST);
              containerpanel.add(createCustOrdDetailsButtons(), BorderLayout.SOUTH);
              mainframe.setContentPane(containerpanel);
              mainframe.setLocationRelativeTo(null);
              mainframe.setVisible(true);
              //--<BEGINNING>--Checks to see whether CRecordNumberStore file exists-------------------------------//
              if (OrdRecordNumStore.exists() == true) {
                   recFileExists = true;
              }else {
                   recFileExists = false;
              if (recFileExists == true) {
                   MaxRecord = readRecordNumber();
                   CurrentRecord = MaxRecord;
                   //readOrder();
                   //readInnerOrderRecord(CurrentRecord);
                   System.out.println("Current Record " +CurrentRecord);
                   System.out.println("Max Record " +MaxRecord);
              }else{
                   MaxRecord = 1;
                   writeRecordNumber(MaxRecord);
                   CustOrderIDTxt.setText(""+MaxRecord);
                   System.out.println("Current Record " +CurrentRecord);
                   System.out.println("Max Record " +MaxRecord);
              //--<END>--Checks to see whether CRecordNumberStore file exists--------------------------------------//
              if(readOrder() != null){
                   orderDetails = (CustOrdObject[]) readOrder();
                   //CurrentRecord--;
                   //System.out.println("Current Rec Here"+CurrentRecord);
                   if(orderDetails[CurrentRecord] == null){
                        System.err.println("CustomerOrderObj 1 is null !!");
                   }else{
                        System.err.println("CustomerOrderObj 1 is  not null !!");
                   if(orderDetails[CurrentRecord].getInnerCustOrdObj() == null){
                        System.err.println("InnerCustomerOrderObj is null !!");
                   }else{
                        System.err.println("InnerCustomerOrderObj is  not null !!");
                   innerCustOrdObj = orderDetails[CurrentRecord].getInnerCustOrdObj();
                   MaxItems = orderDetails[CurrentRecord].getMaxItems();
                   if(CurrentRecord > 1 && CurrentRecord < MaxRecord){
                        externalnextbtn.setEnabled(true);
                        externalprevbtn.setEnabled(true);
                   if(CurrentRecord >= MaxRecord){
                        externalnextbtn.setEnabled(false);
                   getFieldText(CurrentRecord);
                   getInnerFieldText(MaxItems);
              }else{
                   orderDetails[CurrentRecord] = new CustOrdObject();
                   currentItem = 1;
              return mainframe;
         //--<END>--Creating CustomerOrderDetails Screen---------------------------------------------//
         public JPanel createCustOrdDetailsTitle(){
              createTitlePanel();
              titlepanel.setBackground(TxtfontColor);
              label.setText("- Customer Order Details -");
              labelpanel.setBackground(TxtfontColor);
              label.setForeground(Color.white);
              createbuttonpanel();
              buttonpanel.setBackground(TxtfontColor) ;
              buttonpanel.add(createReturnToMainMenuButton());
              titlepanel.add(labelpanel, BorderLayout.WEST);
              titlepanel.add(buttonpanel, BorderLayout.EAST);
              return titlepanel;
         public JPanel createCustOrdDetailsMainPanel(){
              createmainpanel();
              mainpanel.setBackground(TxtfontColor);
              mainpanel.setLayout(new BorderLayout());          
              mainpanel.setBorder(BorderFactory.createTitledBorder(""));
              mainpanel.add(createInnerTopPanel(), BorderLayout.NORTH);
              mainpanel.add(createInnerCenterPanel(), BorderLayout.CENTER);
              mainpanel.add(createInnerBottomPanel(), BorderLayout.SOUTH);
              mainpanel.add(createInnerRightPanel(), BorderLayout.EAST);
              mainpanel.add(createInnerLeftPanel(), BorderLayout.WEST);
              return mainpanel;
         public JPanel createInnerTopPanel(){
              innertoppanel = new JPanel(new GridBagLayout());
              innertoppanel.setBackground(TxtfontColor);
              GridBagConstraints GBC = new GridBagConstraints();
              GBC.fill = GridBagConstraints.HORIZONTAL;
              //Setting Font Type and Size
              Font font = new Font("Arial", Font.BOLD, 11);
              CustIDLbl = new JLabel("Customer ID");
              CustIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              CustIDLbl.setFont(font);
              CustIDLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 1;
              innertoppanel.add(CustIDLbl, GBC);     
              CustIDTxt = new JTextField(20);
              CustIDTxt.setEditable(true);
              GBC.gridx = 2;
              GBC.gridy = 1;
              innertoppanel.add(CustIDTxt, GBC);
              GBC.gridx = 3;
              GBC.gridy = 1;
              innertoppanel.add(Box.createHorizontalStrut(220), GBC);
              OrderedDateLbl = new JLabel("Order Date");
              OrderedDateLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              OrderedDateLbl.setFont(font);
              OrderedDateLbl.setForeground(LblfontColor);
              GBC.gridx = 4;
              GBC.gridy = 1;
              innertoppanel.add(OrderedDateLbl, GBC);     
              //Get today's date
              Date todaydate = new Date();
              OrderedDateTxt = new JTextField(simpleDF.format(todaydate), 20);
              OrderedDateTxt.setHorizontalAlignment(JTextField.CENTER);
              OrderedDateTxt.setEditable(false);
              GBC.gridx = 5;
              GBC.gridy = 1;
              innertoppanel.add(OrderedDateTxt, GBC);
              CustOrderIDLbl = new JLabel("Customer Order ID");
              CustOrderIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              CustOrderIDLbl.setFont(font);
              CustOrderIDLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 2;
              innertoppanel.add(CustOrderIDLbl, GBC);
              CustOrderIDTxt = new JTextField(20);
              //CustOrderIDTxt.setEditable(false);
              GBC.gridx = 2;
              GBC.gridy = 2;
              innertoppanel.add(CustOrderIDTxt, GBC);
              return innertoppanel;
         public JPanel createInnerCenterPanel(){
              innercenterpanel = new JPanel(new GridBagLayout());
              innercenterpanel.setBackground(TxtfontColor);
              innercenterpanel.setBorder(BorderFactory.createLoweredBevelBorder());
              GridBagConstraints GBC = new GridBagConstraints();
              GBC.fill = GridBagConstraints.HORIZONTAL;
              //Setting Font Type and Size
              Font font = new Font("Arial", Font.BOLD, 11);
              ItemNumberLbl = new JLabel("Item Number");
              ItemNumberLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              ItemNumberLbl.setFont(font);
              ItemNumberLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 1;
              innercenterpanel.add(ItemNumberLbl, GBC);     
              ItemNumberTxt = new JTextField(20);
              GBC.gridx = 2;
              GBC.gridy = 1;
              innercenterpanel.add(ItemNumberTxt, GBC);
              UnitPriceLbl = new JLabel("Unit Price");
              UnitPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              UnitPriceLbl.setFont(font);
              UnitPriceLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 2;
              innercenterpanel.add(UnitPriceLbl, GBC);     
              UnitPriceTxt = new JTextField(20);
              //UnitPriceTxt.setEditable(false);
              GBC.gridx = 2;
              GBC.gridy = 2;
              innercenterpanel.add(UnitPriceTxt, GBC);
              QuantityReqLbl = new JLabel("Quantity Required");
              QuantityReqLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              QuantityReqLbl.setFont(font);
              QuantityReqLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 3;
              innercenterpanel.add(QuantityReqLbl, GBC);     
              QuantityReqTxt = new JTextField(20);
              //QuantityReqTxt.setEditable(false);
              GBC.gridx = 2;
              GBC.gridy = 3;
              innercenterpanel.add(QuantityReqTxt, GBC);
              TotPriceLbl = new JLabel("Total Price");
              TotPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              TotPriceLbl.setFont(font);
              TotPriceLbl.setForeground(LblfontColor);
              GBC.gridx = 1;
              GBC.gridy = 4;
              innercenterpanel.add(TotPriceLbl, GBC);     
              TotPriceTxt = new JTextField(20);
              TotPriceTxt.setEditable(false);
              TotPriceTxt.addFocusListener(new FocusAdapter(){
                   public void focusGained(FocusEvent evt){
                        TotPriceTxt.setText(""+Integer.parseInt(UnitPriceTxt.getText())*Integer.parseInt(QuantityReqTxt.getText()));
              GBC.gridx = 2;
              GBC.gridy = 4;
              innercenterpanel.add(TotPriceTxt, GBC);
              return innercenterpanel;
         public JPanel createInnerBottomPanel(){
              innerbottompanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
              innerbottompanel.setBackground(TxtfontColor);
              //Setting Font Type and Size
              Font font = new Font("Arial", Font.BOLD, 11);
              GrandTotLbl = new JLabel("Grand Total");
              GrandTotLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              GrandTotLbl.setFont(font);
              GrandTotLbl.setForeground(LblfontColor);
              innerbottompanel.add(GrandTotLbl);
              innerbottompanel.add(Box.createHorizontalStrut(30));
              GrandTotTxt = new JTextField(20);
              innerbottompanel.add(GrandTotTxt);
              return innerbottompanel;
         public JPanel createInnerRightPanel(){
              innerrightpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              innerrightpanel.setBackground(TxtfontColor);
              innerrightpanel.setLayout(new BoxLayout(navrightpanel, BoxLayout.Y_AXIS));
              innerrightpanel.setBorder(BorderFactory.createLoweredBevelBorder());
              innerrightpanel.setLayout(new GridBagLayout());          
              GridBagConstraints GBC = new GridBagConstraints();
              GBC.fill = GridBagConstraints.HORIZONTAL;
              internalnextbtn = new JButton(createNextButtonIcon());
              GBC.gridx = 1;
              GBC.gridy = 1;
              internalnextbtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        getInnerFieldText(currentItem);
                        internalprevbtn.setEnabled(true);
                        if(currentItem < MaxItems){
                             ++currentItem;
                             orderDetails[CurrentRecord].getInnerCustOrdObj();
                             setInnerFieldText(currentItem);
                             System.out.println("Current Item" + currentItem);
                        if(currentItem == MaxItems){
                             internalnextbtn.setEnabled(false);
              innerrightpanel.add(internalnextbtn, GBC);
              return innerrightpanel;
         public JPanel createInnerLeftPanel(){
              innerleftpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              innerleftpanel.setBackground(TxtfontColor);
              innerleftpanel.setBorder(BorderFactory.createLoweredBevelBorder());
              innerleftpanel.setForeground(Color.BLACK);
              innerleftpanel.setLayout(new GridBagLayout());          
              GridBagConstraints GBC = new GridBagConstraints();
              GBC.fill = GridBagConstraints.HORIZONTAL;
              internalprevbtn = new JButton(createPreviousButtonIcon());
              GBC.gridx = 1;
              GBC.gridy = 1;
              internalprevbtn.addActionListener(new ActionListener(){
                   public void  actionPerformed(ActionEvent evt){
                        getInnerFieldText(currentItem);
                        internalnextbtn.setEnabled(true);
                        if(currentItem == 1){
                             internalprevbtn.setEnabled(false);
                        if(currentItem > 0){
                             --currentItem;
                             orderDetails[CurrentRecord].getInnerCustOrdObj();
                             setInnerFieldText(currentItem);
                             System.out.println("Current Item" + currentItem);
              innerleftpanel.add(internalprevbtn, GBC);
              return innerleftpanel;
         public JPanel createCustOrdDetailsButtons(){
              createbuttonpanel();
              buttonpanel.setBackground(TxtfontColor);
              externalprevbtn = new JButton(createPreviousButtonIcon());
              externalprevbtn.addActionListener(new ActionListener(){
                   public void  actionPerformed(ActionEvent evt){
                        getFieldText(CurrentRecord);
                        externalnextbtn.setEnabled(true);
                        if(CurrentRecord == 1){
                             externalprevbtn.setEnabled(false);
                        if(CurrentRecord > 0){
                             --CurrentRecord;
                             setFieldText(CurrentRecord);
                             System.out.println("Current Record " + CurrentRecord);//Checking RECORD_NUM
              buttonpanel.add(externalprevbtn);
              addrecordbtn = new JButton("Add Record", createAddButtonIcon());
              addrecordbtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        try{
                             MaxRecord = readRecordNumber();
                             MaxRecord++;
                             CurrentRecord = MaxRecord;
                             orderDetails[CurrentRecord] = new CustOrdObject();
                             writeRecordNumber(MaxRecord);
                             MaxItems = 1;
                             innerCustOrdObj[MaxItems] = new InnerCustOrdObject();
                             //--<BEGINNING>--Clear Fields-------------------------------------------------------//
                             CustIDTxt.setText("");
                             CustOrderIDTxt.setText(""+MaxRecord);
                             //Get today's date
                             Date todaydate = new Date();
                             OrderedDateTxt.setText(""+simpleDF.format(todaydate));
                             ItemNumberTxt.setText("");
                             UnitPriceTxt.setText("");
                             QuantityReqTxt.setText("");
                             TotPriceTxt.setText("");
                             GrandTotTxt.setText("");
                             //--<END>--Clear Fields-------------------------------------------------------------//
                             externalnextbtn.setEnabled(false);
                             externalprevbtn.setEnabled(true);
                             System.out.println(MaxRecord);
                        } catch(Exception ec){ec.printStackTrace();}
              buttonpanel.add(addrecordbtn);
              savebtn = new JButton("Save Data", createSaveButtonIcon());
              savebtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        setFieldText(CurrentRecord);
                        setInnerFieldText(MaxItems);
                        writeOrder();
                        writeRecordNumber(MaxRecord);
                        System.out.println(CurrentRecord);
                        System.out.println(MaxRecord);
              buttonpanel.add(savebtn);
              java.net.URL imageURL_AddRowIcon = CommonFeatures.class.getResource("Icons/edit_add.png");
              ImageIcon AddRowIcon = new ImageIcon(imageURL_AddRowIcon);
              additemreqbtn = new JButton("Add Item", AddRowIcon);
              additemreqbtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        try{
                             //--<BEGINNING>--Clear Fields-------------------------------------------------------//
                             ItemNumberTxt.setText("");
                             UnitPriceTxt.setText("");
                             QuantityReqTxt.setText("");
                             TotPriceTxt.setText("");
                             //--<END>--Clear Fields-------------------------------------------------------------//
                             //CurrentRecord = MaxRecord;
                             MaxItems++;
                             innerCustOrdObj[MaxItems] = new InnerCustOrdObject();
                             System.out.println("Max Items "+MaxItems);
                             currentItem = MaxItems;
                             orderDetails[CurrentRecord].setMaxItems(MaxItems);
                             ///setInnerFieldText(currentItem);
                             internalnextbtn.setEnabled(false);
                             internalprevbtn.setEnabled(true);
                        } catch(Exception ec){ec.printStackTrace();}
              buttonpanel.add(additemreqbtn);
              externalnextbtn = new JButton(createNextButtonIcon());
              externalnextbtn.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        getFieldText(CurrentRecord);
                        externalprevbtn.setEnabled(true);
                        if(CurrentRecord < MaxRecord){
                             ++CurrentRecord;
                             setFieldText(CurrentRecord);
                             System.out.println(CurrentRecord);//Checking RECORD_NUM
                        if(CurrentRecord == MaxRecord){
                             externalnextbtn.setEnabled(false);
              buttonpanel.add(externalnextbtn);
              gotorecordbtn = new JButton("Go To Record", createGotoButtonIcon());
              gotorecordbtn.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt){
                         * The text from the GotorecordTxt textfield will be taken and assigned
                         * to a temporary integer variable called Find. 
                        int Find = Integer.parseInt(CustOrderIDTxt.getText());
                        for(int j=1; j <= MaxRecord; j++){
                              * Using a for loop, each record can be read using the readCustRecord
                              * method.
                             getFieldText(j);
                              * An if condition is utilized to check whether the temporary stored variable, Find,
                              * matches a field in a record. If this record is found, then using the RecordExists
                              * which was declared at the top, either a true or false statement can be assigned
                              * If the record exists, then a true statement will be assigned, if not a false
                              * statement will be assigned.
                             if(orderDetails[j].getCustOrderID() == Find){
                                  RecordExists = true;
                                  break;
                             }else{
                                  RecordExists = false;
                        if(RecordExists == false){
                              * If the RecordExists is assigned a false statement, then a message will be
                              * displayed to show that the record does not exist.
                             JOptionPane.showMessageDialog(null, "Record Does Not Exist!", "Error Message", JOptionPane.ERROR_MESSAGE, createErrorIcon());
                        }else{
                             getFieldText(Find);
              buttonpanel.add(gotorecordbtn);
              return buttonpanel;
         //TODO
         public void setFieldText(int orderID){//TODO
              orderDetails[orderID].setCustID(Integer.parseInt(CustIDTxt.getText()));
              orderDetails[orderID].setCustOrderID(Integer.parseInt(CustOrderIDTxt.getText()));
              orderDetails[orderID].setOrderDate(OrderedDateTxt.getText());
              orderDetails[orderID].setInnerCustOrdObj(innerCustOrdObj);
              orderDetails[orderID].setMaxItems(MaxItems);
              setInnerFieldText(currentItem);
              orderDetails[orderID].setGrandTotal(Float.parseFloat(GrandTotTxt.getText()));
         public void setInnerFieldText(int currentItem){//TODO
              innerCustOrdObj[currentItem] = new InnerCustOrdObject();
              innerCustOrdObj[currentItem].setMaxItems(MaxItems);
              innerCustOrdObj[currentItem].setItemNumber(Integer.parseInt(ItemNumberTxt.getText()));
              innerCustOrdObj[currentItem].setUnitPrice(Float.parseFloat(UnitPriceTxt.getText()));
              innerCustOrdObj[currentItem].setQuantityRequired(Integer.parseInt(QuantityReqTxt.getText()));
              innerCustOrdObj[currentItem].setTotalPrice(Float.parseFloat(TotPriceTxt.getText()));
         public void getFieldText(int orderID){
              CustIDTxt.setText(Integer.toString(orderDetails[orderID].getCustID()));
              CustOrderIDTxt.setText(Integer.toString(orderDetails[orderID].getCustOrderID()));
              OrderedDateTxt.setText(""+orderDetails[orderID].getOrderDate());          
              currentItem = orderDetails[orderID].getMaxItems();
              orderDetails[orderID].getInnerCustOrdObj();
              System.err.println("currentItem" + currentItem);
              //getInnerFieldText(currentItem);
              GrandTotTxt.setText(Float.toString(orderDetails[orderID].getGrandTotal()));
         public void getInnerFieldText(int currentItem){
              ItemNumberTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getItemNumber()));
              UnitPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getUnitPrice()));
              QuantityReqTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getQuantityRequired()));
              TotPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getTotalPrice()));
         public void writeOrder(){//TODO
              try {
                   objOut = new ObjectOutputStream(new FileOutputStream(OrderDetailsFile));
                   objOut.writeObject(orderDetails);
                   System.out.println("WORKING!");
                   objOut.flush();
                   objOut.close();
              } catch (IOException e) {
                   e.printStackTrace();
         public Object readOrder(){
              Object temporaryObj;
              try{
                   objIn = new ObjectInputStream(new FileInputStream(OrderDetailsFile));
                   temporaryObj = objIn.readObject();               
                   CustOrdObject[] blah = (CustOrdObject[]) temporaryObj;
                   /*               System.out.println("Outer: "+blah[1].getCustID());
                   InnerCustOrdObject[] whee = blah[1].getInnerCustOrdObj();
                   System.out.println("Inner: "+whee[1].getItemNumber());*/
                   objIn.close();
                   System.out.println("Read Worky!");
                   return temporaryObj;
              }catch(Exception e){
                   e.printStackTrace();
                   System.out.println("Read No Worky!");
                   return null;
         public void writeRecordNumber(int MaxRecord){
              try{
                   objOut = new ObjectOutputStream(new FileOutputStream(OrdRecordNumStore));
                   objOut.writeObject(MaxRecord);
                   System.out.println("WORKING!");
                   objOut.flush();
                   objOut.close();
              }catch(Exception e){e.printStackTrace();}
         public int readRecordNumber() {
              try {
                   objIn = new ObjectInputStream(new FileInputStream(OrdRecordNumStore));
                   int temporaryObj = Integer.parseInt(objIn.readObject().toString());
                   objIn.close();
                   System.out.println("Read Number Worky!");
                   return temporaryObj;
              } catch (Exception e) {
                   e.printStackTrace();
                   System.out.println("Read Number No Worky!");
                   return -1;
    }Message was edited by:
    Kilik07

  • Problem with socket and object writing

    Hi,
    I programm this client/server app, the client has a point (graphic ) , the server has a point and when the mouse is moving it moves the point and the new position is send via the socket.
    The probleme is that i don't receive the good thing.
    When i display the coord of the point before sending it's good , but when receiving from the socket the coords are always the same ...
    i don't understand .
    Well , try and tell me ...
    Thx.

    oups, the program can be usefull ...
    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    public class server_JFrame extends javax.swing.JFrame implements MouseListener,MouseMotionListener{
    point p1,p2;
    server s;
    public server_JFrame()
    this.setSize(600,400);
    addMouseListener(this);
    addMouseMotionListener(this);
    p2=new point(50,50,new Color(0,0,255));
    p1=new point(200,200,new Color(255,0,0));
    s = new server(p2,this);
    public void paint(Graphics g)
    super.paint(g);
    g.setColor(p1.get_color());
    g.fillOval(p1.get_x(), p1.get_y(),10,10);
    g.setColor(p2.get_color());
    g.fillOval(p2.get_x(), p2.get_y(),10,10);
    public void mouseClicked(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}
    public void mouseDragged(MouseEvent e) {}
    public void mouseMoved(MouseEvent e)
    p1.set_x(e.getX());
    p1.set_y(e.getY());
    s.write_point(p1);
    repaint();
    public static void main(String args[])
         server_JFrame sjf = new server_JFrame();
    sjf.setDefaultCloseOperation(EXIT_ON_CLOSE);
         sjf.setTitle("server");
    sjf.show();
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    public class server {
    point p_;
    Container c_;
    ObjectInputStream Istream_;
    ObjectOutputStream Ostream_;
    public server(point p,Container c)
    p_=p;
    c_=c;
    try
    ServerSocket server = new java.net.ServerSocket(80);
    System.out.println("attente d'un client");
    java.net.Socket client = server.accept();
    System.out.println("client accept�");
    Istream_ = new ObjectInputStream(client.getInputStream());
    Ostream_ = new ObjectOutputStream(client.getOutputStream());
    ThreadRead tr = new ThreadRead(Istream_,p_,c_);
    catch (Exception exception) { exception.printStackTrace(); }
    public void write_point(point p)
    try
    System.out.print("x="+p.get_x());
    System.out.println(" y="+p.get_y());
    Ostream_.flush();
    Ostream_.writeObject(p);
    Ostream_.flush();
    catch (Exception exception) {exception.printStackTrace();}
    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    public class client_JFrame extends javax.swing.JFrame implements MouseListener,MouseMotionListener{
    point p1,p2;
    client c;
    public client_JFrame()
    this.setSize(600,400);
    addMouseListener(this);
    addMouseMotionListener(this);
    p1=new point(50,50,new Color(0,0,255));
    p2=new point(200,200,new Color(255,0,0));
    c = new client(p2,this);
    public void paint(Graphics g)
    super.paint(g);
    g.setColor(p1.get_color());
    g.fillOval(p1.get_x(), p1.get_y(),10,10);
    g.setColor(p2.get_color());
    g.fillOval(p2.get_x(), p2.get_y(),10,10);
    public void mouseClicked(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}
    public void mouseDragged(MouseEvent e) {}
    public void mouseMoved(MouseEvent e)
    p1.set_x(e.getX());
    p1.set_y(e.getY());
    c.write_point(p1);
    repaint();
    public static void main(String args[])
         client_JFrame cjf = new client_JFrame();
    cjf.setDefaultCloseOperation(EXIT_ON_CLOSE);
         cjf.setTitle("client");
    cjf.show();
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    public class client {
    point p_;
    Container c_;
    ObjectInputStream Istream_;
    ObjectOutputStream Ostream_;
    public client(point p,Container c)
    p_=p;
    c_=c;
    try
    ipJDialog ipjd = new ipJDialog();
    String ip = ipjd.getvalue();
    Socket socket = new Socket(ip,80);
    System.out.println("connection avec serveur reussi");
    Ostream_ = new ObjectOutputStream(socket.getOutputStream());
    Istream_ = new ObjectInputStream(socket.getInputStream());
    ThreadRead tr = new ThreadRead(Istream_,p_,c_);
    catch (Exception exception) {*exception.printStackTrace();*/System.out.println("connection avec serveur echou�");}
    public void write_point(point p)
    try
    System.out.print("x="+p.get_x());
    System.out.println(" y="+p.get_y());
    Ostream_.flush();
    Ostream_.writeObject(p);
    Ostream_.flush();
    catch (Exception exception) {exception.printStackTrace();}
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    public class client {
    point p_;
    Container c_;
    ObjectInputStream Istream_;
    ObjectOutputStream Ostream_;
    public client(point p,Container c)
    p_=p;
    c_=c;
    try
    ipJDialog ipjd = new ipJDialog();
    String ip = ipjd.getvalue();
    Socket socket = new Socket(ip,80);
    System.out.println("connection avec serveur reussi");
    Ostream_ = new ObjectOutputStream(socket.getOutputStream());
    Istream_ = new ObjectInputStream(socket.getInputStream());
    ThreadRead tr = new ThreadRead(Istream_,p_,c_);
    catch (Exception exception) {*exception.printStackTrace();*/System.out.println("connection avec serveur echou�");}
    public void write_point(point p)
    try
    System.out.print("x="+p.get_x());
    System.out.println(" y="+p.get_y());
    Ostream_.flush();
    Ostream_.writeObject(p);
    Ostream_.flush();
    catch (Exception exception) {exception.printStackTrace();}
    import java.io.Serializable;
    import java.awt.*;
    public class point implements Serializable{
    private int x_;
    private int y_;
    private Color c_;
    public point(int x, int y, Color c) {
    x_=x;
    y_=y;
    c_=c;
    public int get_x() { return x_ ; }
    public int get_y() { return y_ ; }
    public void set_x(int x) { x_=x ; }
    public void set_y(int y) { y_=y ; }
    public Color get_color() { return c_ ; }
    }

Maybe you are looking for

  • No longer receive emails, all email icons gone!

    Hi all, how are you? I noticed 4 days ago that I stopped receiving emails from the 4 accounts I had set up on my Blackberry Torch 9800 (one official, 2 yahoo, 1 gmail). I could see the icons and send test emails but I wouldn't receive them on my phon

  • The best way to import photos from Picasa to iPhoto

    Hi, Many of my friends share their pictures online using picasa. Sometimes, I'd like to copy these pictures to keep a backup offline. As a software, I use iPhoto; not picasa. What is the best way to import pictures from picasa to iPhoto? I first trie

  • How to change values in VBAP and VBUP tables?

    All, I have a sales order where I need to change the values in 2 fields. VBAP-ABGRU  and VBUP-UVP03 I have found the BAPI_SALESORDER_CHANGE but not sure it will let me change the VBUP field. Any suggestions would be nice. Thanks. Scott

  • How to set current row in calendar

    Hi All, I am implementing ADF calendar using ADF faces. When i click on any activity the current row selected is not being displayed. Instead it always points to the last row of the VO. How to i explicitly set the current row to the selected row.(thi

  • Adding new Hub Transport server in existing environment

    Hi everyone, Currently we have 5 exchange servers 2010 : 2 CAS Servers (Virtual) 2 MB and Hub Transport servers (Physical) 1 Edge server in DMZ. (Virtual) Now I have added 2 more servers with MB and Hub Tranport Roles (VIRTUAL) and want to configure