Developing Java Beans is then sized and shown.

Developing Java Beans is then sized and shown. When the buttons are clicked, a message is printed to the console window indicating which button was pressed. The code for the application is shown here: import java.awt.*; import java.io.*; public class Example8{ protected Frame fr; public void init(String cmd) { fr = new Frame(”Example8″); if (cmd.equals(”save”)) { ListeningPanel p = new ListeningPanel(); p.initialize(); fr.add(p); fr.setVisible(true); fr.reshape(100,100,300,100); fr.repaint(); try { FileOutputStream f = new FileOutputStream(”Example8.tmp”); ObjectOutput s = new ObjectOutputStream(f); s.writeObject(p); s.flush(); } catch (Exception e) { System.out.println(e); } } else if (cmd.equals(”restore”)) { try { FileInputStream f = new FileInputStream(”Example8.tmp”); ObjectInput s = new ObjectInputStream(f); ListeningPanel p = (ListeningPanel)s.readObject(); fr.add(p); fr.setVisible(true); fr.reshape(100,100,300,100); fr.repaint(); } catch (Exception e) { System.out.println(e); } } } public static void main(String[] args) { Example8 a = new Example8(); a.init(args[0]); } } page 89

Comments are closed.