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

  1. // This snippet creates a new dialog box
  2. // with buttons on the bottom.
  3. // <File=StandardDialog1.java>
  4.  
  5. //Title:
  6. //Version:
  7. //Copyright:
  8. //Author:
  9. //Company:
  10. //Description:
  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 StandardDialog1 extends Dialog {
  20.   Panel panel1 = new Panel();
  21.   XYLayout xYLayout1 = new XYLayout();
  22.   BevelPanel bevelPanel1 = new BevelPanel();
  23.   Button button1 = new Button();
  24.   Button button2 = new Button();
  25.  
  26.   public StandardDialog1(Frame frame, String title, boolean modal) {
  27.     super(frame, title, modal);
  28.     try {
  29.       jbInit();
  30.     }
  31.     catch (Exception e) {
  32.       e.printStackTrace();
  33.     }
  34.     add(panel1);
  35.     pack();
  36.   }
  37.  
  38.   public StandardDialog1(Frame frame, String title) {
  39.     this(frame, title, false);
  40.   }
  41.  
  42.   public StandardDialog1(Frame frame) {
  43.     this(frame, "", false);
  44.   }
  45.  
  46.   public void jbInit() throws Exception {
  47.     xYLayout1.setWidth(320);
  48.     xYLayout1.setHeight(243);
  49.     button1.setLabel("OK");
  50.     button1.addActionListener(new StandardDialog1_button1_actionAdapter(this));
  51.     button2.setLabel("Cancel");
  52.     button2.addActionListener(new StandardDialog1_button2_actionAdapter(this));
  53.     this.addWindowListener(new StandardDialog1_this_windowAdapter(this));
  54.     panel1.setLayout(xYLayout1);
  55.     panel1.add(bevelPanel1, new XYConstraints(9, 10, 298, 191));
  56.     panel1.add(button1, new XYConstraints(67, 211, 74, 25));
  57.     panel1.add(button2, new XYConstraints(163, 211, 77, 25));
  58.   }
  59.  
  60. //<Exclude>
  61.   // Test case
  62.   public static void main(String[] argv) {
  63.     DecoratedFrame frame = new DecoratedFrame();
  64.     frame.show();
  65.     StandardDialog1 sd = new StandardDialog1(frame, "Test", true);
  66.     sd.show();
  67.     //Get any results here
  68.     System.exit(0);
  69.   }
  70.  
  71. //</Exclude>
  72.   // OK
  73.   void button1_actionPerformed(ActionEvent e) {
  74.     dispose();
  75.   }
  76.  
  77.   // Cancel
  78.   void button2_actionPerformed(ActionEvent e) {
  79.     dispose();
  80.   }
  81.   
  82.   void this_windowClosing(WindowEvent e) {
  83.     dispose();
  84.   }
  85. }
  86.  
  87. class StandardDialog1_button1_actionAdapter implements ActionListener {
  88.   StandardDialog1 adaptee;
  89.  
  90.   StandardDialog1_button1_actionAdapter(StandardDialog1 adaptee) {
  91.     this.adaptee = adaptee;
  92.   }
  93.  
  94.   public void actionPerformed(ActionEvent e) {
  95.     adaptee.button1_actionPerformed(e);
  96.   }
  97. }
  98.  
  99. class StandardDialog1_button2_actionAdapter implements ActionListener {
  100.   StandardDialog1 adaptee;
  101.  
  102.   StandardDialog1_button2_actionAdapter(StandardDialog1 adaptee) {
  103.     this.adaptee = adaptee;
  104.   }
  105.  
  106.   public void actionPerformed(ActionEvent e) {
  107.     adaptee.button2_actionPerformed(e);
  108.   }
  109. }
  110.  
  111. class StandardDialog1_this_windowAdapter extends WindowAdapter {
  112.   StandardDialog1 adaptee;
  113.  
  114.   StandardDialog1_this_windowAdapter(StandardDialog1 adaptee) {
  115.     this.adaptee = adaptee;
  116.   }
  117.  
  118.   public void windowClosing(WindowEvent e) {
  119.     adaptee.this_windowClosing(e);
  120.   }
  121. }
  122.