home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jruntime.z / AboutBox.java < prev    next >
Text File  |  1997-08-25  |  3KB  |  112 lines

  1. // This snippet creates a new about box.
  2. // <File=AboutBox.java>
  3.  
  4. //Title:
  5. //Version:
  6. //Copyright:
  7. //Author:
  8. //Company:
  9. //Description:
  10. //
  11.  
  12. //<PACKAGE>
  13.  
  14. import java.awt.*;
  15. import java.awt.event.*;
  16. import borland.jbcl.layout.*;
  17. import borland.jbcl.control.*;
  18.  
  19. public class AboutBox extends Dialog {
  20.   Panel panel1 = new Panel();
  21.   XYLayout xYLayout1 = new XYLayout();
  22.   ImageControl imageControl1 = new ImageControl();
  23.   Label label1 = new Label();
  24.   Label label2 = new Label();
  25.   Label label3 = new Label();
  26.   Label label4 = new Label();
  27.   Button button1 = new Button();
  28.  
  29.   public AboutBox(Frame frame, String title, boolean modal) {
  30.     super(frame, title, modal);
  31.     try {
  32.       jbInit();
  33.     }
  34.     catch (Exception e) {
  35.       e.printStackTrace();
  36.     }
  37.     add(panel1);
  38.     pack();
  39.   }
  40.  
  41.   public AboutBox(Frame frame, String title) {
  42.     this(frame, title, false);
  43.   }
  44.  
  45.   public AboutBox(Frame frame) {
  46.     this(frame, "", false);
  47.   }
  48.  
  49.   public void jbInit() throws Exception {
  50.     xYLayout1.setWidth(266);
  51.     xYLayout1.setHeight(192);
  52.     label1.setText("Product Name");
  53.     label2.setText("Version ...");
  54.     label3.setText("Copyright ...");
  55.     label4.setText("Comments ...");
  56.     button1.setActionCommand("");
  57.     button1.setLabel("OK");
  58.     button1.addActionListener(new AboutBox_button1_actionAdapter(this));
  59.     this.addWindowListener(new AboutBox_this_windowAdapter(this));
  60.     panel1.setLayout(xYLayout1);
  61.     panel1.add(imageControl1, new XYConstraints(12, 14, 98, 84));
  62.     panel1.add(label1, new XYConstraints(121, 16, 118, 21));
  63.     panel1.add(label2, new XYConstraints(121, 45, 118, 21));
  64.     panel1.add(label3, new XYConstraints(121, 73, 118, 21));
  65.     panel1.add(label4, new XYConstraints(10, 103, 321, 24));
  66.     panel1.add(button1, new XYConstraints(83, 147, 98, 32));
  67.   }
  68.  
  69.   //Close the dialog
  70.   void button1_actionPerformed(ActionEvent e) {
  71.      dispose();
  72.   }
  73.  
  74. //<exclude>
  75.   // Test case
  76.   public static void main(String[] argv) {
  77.     DecoratedFrame frame = new DecoratedFrame();
  78.     frame.show();
  79.     new AboutBox(frame,"Test",true).show();
  80.     System.exit(0);
  81.   }
  82.  
  83. //</exclude>
  84.   void this_windowClosing(WindowEvent e) {
  85.     dispose();
  86.   }
  87. }
  88.  
  89. class AboutBox_button1_actionAdapter implements ActionListener {
  90.   AboutBox adaptee;
  91.  
  92.   AboutBox_button1_actionAdapter(AboutBox adaptee) {
  93.     this.adaptee = adaptee;
  94.   }
  95.  
  96.   public void actionPerformed(ActionEvent e) {
  97.     adaptee.button1_actionPerformed(e);
  98.   }
  99. }
  100.  
  101. class AboutBox_this_windowAdapter extends WindowAdapter {
  102.   AboutBox adaptee;
  103.  
  104.   AboutBox_this_windowAdapter(AboutBox adaptee) {
  105.     this.adaptee = adaptee;
  106.   }
  107.  
  108.   public void windowClosing(WindowEvent e) {
  109.     adaptee.this_windowClosing(e);
  110.   }
  111. }
  112.