[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

...ahem. JTable problem in ozone...



hi, Ozonies.  Anyone tested ozone on Swing components?
I can get buttons, layouts of buttons to retrieve all right, but
not more complicated stuff, like JTable.  Here are my troubles with
ozone's retrieval of  JTable (throws a NullPointerException in the
RemoteDatabase VM; also a freeze in the client application),
and I am doing this on NT with ozone 0.3.1 and 0.3.2 under
Java 2 1.3beta (because I need awt.Robot):

I have written code that gets the JTable serialized okay:

    FileOutputStream f = new FileOutputStream(file);
    GZIPOutputStream gzf = new GZIPOutputStream(f);
    ObjectOutputStream out = new ObjectOutputStream(
                                                                 gzf);
    out.writeObject((JComponent)myTable);

...because this code gets it back; I can modify it, put it back, etc.:

    FileInputStream f = new FileInputStream(file);
    GZIPInputStream gzf = new GZIPInputStream(f);
    ObjectInputStream in = new ObjectInputStream(gzf);
    JComponent deserialized = (JComponent)in.readObject();


A for my ozone db object interface, it's even simpler than Car:

public interface SwingPanel extends OzoneRemote {

    // two methods to store/retrieve the SwingPanel
    public void store(JComponent j); /*update*/
    public JComponent retrieve();

...and this is its implementation:

public class SwingPanelImpl extends OzoneObject implements SwingPanel {

    JComponent _dbobject;

    // a constructor without arguments
    public SwingPanelImpl() 
    {
    }

    // Dbobject interface methods:

    public JComponent retrieve()
    {
        return _dbobject;
    }

    public void store(JComponent j)
    {
        _dbobject = j;
    }

}

...meanwhile, the storing code (in an ActionListener):

    SwingPanel dbobject = 
          (SwingPanel)db.objectForName(stringPassword);
    dbobject = (SwingPanel)db.createObject(
                                   SwingPanelImpl.class.getName(),
                                   0, 
                                   stringPassword);
    dbobject.store((JComponent)myTable);

...and the retrieving code (in a different ActionListener):

      SwingPanel dbobject = 
               (SwingPanel)db.objectForName(stringPassword)
      System.out.println("For name: " + stringPassword +
                                    ", found db object: " +
                                    dbobject);
     ---the client's output: 
For name: 12jan2000a1, found db object: OzoneObjekt, ID:2
     ---the ozone server's output:
warning: InvokeServer: java.lang.NullPointerException
InvokeServer: connection closed (user: marek)
     ---client application freezes, program never gets to the next line:
      displayPaneInFrame (dbobject.retrieve(),
                                        "object retrieved from db");

...and finally, the trouble-making table:

       myTable = (new SimpleTableDemo()).table;
       JFrame tw = new JFrame("table for db demo");
       tw.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {}
       });
       
       JScrollPane tsp = new JScrollPane(myTable);
       tsp.doLayout();
       tw.getContentPane().add(tsp);
       tw.setLocation(200,800);
       tw.setSize(new Dimension(510,100));
       tw.setVisible(true);

Any ideas?  I want to store Swing components in ozone,
and when Sun releases the fixed serializable ImageIcon, images as well...

Thanks for your indulgence, und Guter Nachmittag von Chicago! 
(please blame my German squarely on babelfish.altavista.com)

                -- Marek, Northwestern University School of Education