home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 July / Chip_1998-07_cd.bin / zkuste / JBuilder / BDK / Win / bdk_sep97.exe / _SETUP.1 / OrangeButtonWriter.java < prev    next >
Encoding:
Java Source  |  1997-09-10  |  948 b   |  38 lines

  1.  
  2. package sunw.demo.buttons;
  3.  
  4. /**
  5.  * This class is used by the makefiles to create a serialized bean, the
  6.  * OrangeButton, as part of the buttons.jar file.
  7.  */
  8.  
  9. public class OrangeButtonWriter {
  10.  
  11.     public static void main(String argv[]) {
  12.  
  13.     try {
  14.         String fname = argv[0];
  15.  
  16.         // Allocate an ExplicitButton and make it orange.
  17.         ClassLoader cl = OrangeButtonWriter.class.getClassLoader();
  18.         ExplicitButton button = (ExplicitButton)
  19.             java.beans.Beans.instantiate(cl, "sunw.demo.buttons.ExplicitButton");
  20.         button.setBackground(java.awt.Color.orange);
  21.  
  22.         // Now write it out as a serialzied object.
  23.         java.io.FileOutputStream f = new java.io.FileOutputStream(fname);
  24.         java.io.ObjectOutput s = new java.io.ObjectOutputStream(f);
  25.         s.writeObject(button);
  26.         s.close();
  27.  
  28.         System.exit(0);
  29.  
  30.     } catch (Exception ex) {
  31.         System.err.println("OrangeButton write failed: " + ex);
  32.         ex.printStackTrace();
  33.     }
  34.     
  35.     }
  36.  
  37. }
  38.