home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-08-25 | 2.9 KB | 122 lines |
- // This snippet creates a new dialog box
- // with buttons on the side.
- // <File=StandardDialog2.java>
-
- //Title:
- //Version:
- //Copyright:
- //Author:
- //Company:
- //Description:
-
- //<PACKAGE>
-
- import java.awt.*;
- import java.awt.event.*;
- import borland.jbcl.layout.*;
- import borland.jbcl.control.*;
-
- public class StandardDialog2 extends Dialog {
- Panel panel1 = new Panel();
- XYLayout xYLayout1 = new XYLayout();
- BevelPanel bevelPanel1 = new BevelPanel();
- Button button1 = new Button();
- Button button2 = new Button();
-
- public StandardDialog2(Frame frame, String title, boolean modal) {
- super(frame, title, modal);
- try {
- jbInit();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- add(panel1);
- pack();
- }
-
- public StandardDialog2(Frame frame, String title) {
- this(frame, title, false);
- }
-
- public StandardDialog2(Frame frame) {
- this(frame, "", false);
- }
-
- public void jbInit() throws Exception {
- xYLayout1.setWidth(403);
- xYLayout1.setHeight(216);
- button1.setLabel("OK");
- button1.addActionListener(new StandardDialog2_button1_actionAdapter(this));
- button2.setLabel("Cancel");
- button2.addActionListener(new StandardDialog2_button2_actionAdapter(this));
- this.addWindowListener(new StandardDialog2_this_windowAdapter(this));
- panel1.setLayout(xYLayout1);
- panel1.add(bevelPanel1, new XYConstraints(9, 10, 298, 191));
- panel1.add(button1, new XYConstraints(314, 12, 74, 25));
- panel1.add(button2, new XYConstraints(313, 43, 74, 25));
- }
-
- //<Exclude>
- // Test case
- public static void main(String[] argv) {
- DecoratedFrame frame = new DecoratedFrame();
- frame.show();
- StandardDialog2 sd = new StandardDialog2(frame, "Test", true);
- sd.show();
- //Get any results here
- System.exit(0);
- }
-
- //</Exclude>
- // OK
- void button1_actionPerformed(ActionEvent e) {
- dispose();
- }
-
- // Cancel
- void button2_actionPerformed(ActionEvent e) {
- dispose();
- }
-
- void this_windowClosing(WindowEvent e) {
- dispose();
- }
- }
-
- class StandardDialog2_button1_actionAdapter implements ActionListener{
- StandardDialog2 adaptee;
-
- StandardDialog2_button1_actionAdapter(StandardDialog2 adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(ActionEvent e) {
- adaptee.button1_actionPerformed(e);
- }
- }
-
- class StandardDialog2_button2_actionAdapter implements ActionListener{
- StandardDialog2 adaptee;
-
- StandardDialog2_button2_actionAdapter(StandardDialog2 adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(ActionEvent e) {
- adaptee.button2_actionPerformed(e);
- }
- }
-
- class StandardDialog2_this_windowAdapter extends WindowAdapter {
- StandardDialog2 adaptee;
-
- StandardDialog2_this_windowAdapter(StandardDialog2 adaptee) {
- this.adaptee = adaptee;
- }
-
- public void windowClosing(WindowEvent e) {
- adaptee.this_windowClosing(e);
- }
- }
-