home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-08-25 | 2.7 KB | 112 lines |
- // This snippet creates a new about box.
- // <File=AboutBox.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 AboutBox extends Dialog {
- Panel panel1 = new Panel();
- XYLayout xYLayout1 = new XYLayout();
- ImageControl imageControl1 = new ImageControl();
- Label label1 = new Label();
- Label label2 = new Label();
- Label label3 = new Label();
- Label label4 = new Label();
- Button button1 = new Button();
-
- public AboutBox(Frame frame, String title, boolean modal) {
- super(frame, title, modal);
- try {
- jbInit();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- add(panel1);
- pack();
- }
-
- public AboutBox(Frame frame, String title) {
- this(frame, title, false);
- }
-
- public AboutBox(Frame frame) {
- this(frame, "", false);
- }
-
- public void jbInit() throws Exception {
- xYLayout1.setWidth(266);
- xYLayout1.setHeight(192);
- label1.setText("Product Name");
- label2.setText("Version ...");
- label3.setText("Copyright ...");
- label4.setText("Comments ...");
- button1.setActionCommand("");
- button1.setLabel("OK");
- button1.addActionListener(new AboutBox_button1_actionAdapter(this));
- this.addWindowListener(new AboutBox_this_windowAdapter(this));
- panel1.setLayout(xYLayout1);
- panel1.add(imageControl1, new XYConstraints(12, 14, 98, 84));
- panel1.add(label1, new XYConstraints(121, 16, 118, 21));
- panel1.add(label2, new XYConstraints(121, 45, 118, 21));
- panel1.add(label3, new XYConstraints(121, 73, 118, 21));
- panel1.add(label4, new XYConstraints(10, 103, 321, 24));
- panel1.add(button1, new XYConstraints(83, 147, 98, 32));
- }
-
- //Close the dialog
- void button1_actionPerformed(ActionEvent e) {
- dispose();
- }
-
- //<exclude>
- // Test case
- public static void main(String[] argv) {
- DecoratedFrame frame = new DecoratedFrame();
- frame.show();
- new AboutBox(frame,"Test",true).show();
- System.exit(0);
- }
-
- //</exclude>
- void this_windowClosing(WindowEvent e) {
- dispose();
- }
- }
-
- class AboutBox_button1_actionAdapter implements ActionListener {
- AboutBox adaptee;
-
- AboutBox_button1_actionAdapter(AboutBox adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(ActionEvent e) {
- adaptee.button1_actionPerformed(e);
- }
- }
-
- class AboutBox_this_windowAdapter extends WindowAdapter {
- AboutBox adaptee;
-
- AboutBox_this_windowAdapter(AboutBox adaptee) {
- this.adaptee = adaptee;
- }
-
- public void windowClosing(WindowEvent e) {
- adaptee.this_windowClosing(e);
- }
- }
-