Frame1_AboutBox.java~2~
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:3k
源码类别:

Java编程

开发平台:

Java

  1. package uml_gaokai;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import javax.swing.*;
  5. import javax.swing.border.*;
  6. /**
  7.  * <p>Title: </p>
  8.  * <p>Description: </p>
  9.  * <p>Copyright: Copyright (c) 2003</p>
  10.  * <p>Company: </p>
  11.  * @author unascribed
  12.  * @version 1.0
  13.  */
  14. public class Frame1_AboutBox extends JDialog implements ActionListener {
  15.   private JPanel panel1 = new JPanel();
  16.   private JPanel panel2 = new JPanel();
  17.   private JPanel insetsPanel1 = new JPanel();
  18.   private JPanel insetsPanel2 = new JPanel();
  19.   private JPanel insetsPanel3 = new JPanel();
  20.   private JButton button1 = new JButton();
  21.   private JLabel imageLabel = new JLabel();
  22.   private JLabel label1 = new JLabel();
  23.   private JLabel label2 = new JLabel();
  24.   private JLabel label3 = new JLabel();
  25.   private JLabel label4 = new JLabel();
  26.   private BorderLayout borderLayout1 = new BorderLayout();
  27.   private BorderLayout borderLayout2 = new BorderLayout();
  28.   private FlowLayout flowLayout1 = new FlowLayout();
  29.   private GridLayout gridLayout1 = new GridLayout();
  30.   private String product = "";
  31.   private String version = "1.0";
  32.   private String copyright = "Copyright (c) 2003";
  33.   private String comments = "";
  34.   public Frame1_AboutBox(Frame parent) {
  35.     super(parent);
  36.     enableEvents(AWTEvent.WINDOW_EVENT_MASK);
  37.     try {
  38.       jbInit();
  39.     }
  40.     catch(Exception e) {
  41.       e.printStackTrace();
  42.     }
  43.   }
  44.   //Component initialization
  45.   private void jbInit() throws Exception  {
  46.     //imageLabel.setIcon(new ImageIcon(Frame1_AboutBox.class.getResource("[Your Image]")));
  47.     this.setTitle("About");
  48.     panel1.setLayout(borderLayout1);
  49.     panel2.setLayout(borderLayout2);
  50.     insetsPanel1.setLayout(flowLayout1);
  51.     insetsPanel2.setLayout(flowLayout1);
  52.     insetsPanel2.setBorder(BorderFactory.createEmptyBorder(10, 100, 10, 10));
  53.     gridLayout1.setRows(4);
  54.     gridLayout1.setColumns(1);
  55.     label1.setText(product);
  56.     label2.setText(version);
  57.     label3.setText(copyright);
  58.     label4.setText(comments);
  59.     insetsPanel3.setLayout(gridLayout1);
  60.     insetsPanel3.setBorder(BorderFactory.createEmptyBorder(10, 600, 10, 10));
  61.     button1.setText("Ok");
  62.     button1.addActionListener(this);
  63.     insetsPanel2.add(imageLabel, null);
  64.     panel2.add(insetsPanel2, BorderLayout.WEST);
  65.     this.getContentPane().add(panel1, null);
  66.     insetsPanel3.add(label1, null);
  67.     insetsPanel3.add(label2, null);
  68.     insetsPanel3.add(label3, null);
  69.     insetsPanel3.add(label4, null);
  70.     panel2.add(insetsPanel3, BorderLayout.CENTER);
  71.     insetsPanel1.add(button1, null);
  72.     panel1.add(insetsPanel1, BorderLayout.SOUTH);
  73.     panel1.add(panel2, BorderLayout.NORTH);
  74.     setResizable(true);
  75.   }
  76.   //Overridden so we can exit when window is closed
  77.   protected void processWindowEvent(WindowEvent e) {
  78.     if (e.getID() == WindowEvent.WINDOW_CLOSING) {
  79.       cancel();
  80.     }
  81.     super.processWindowEvent(e);
  82.   }
  83.   //Close the dialog
  84.   void cancel() {
  85.     dispose();
  86.   }
  87.   //Close the dialog on a button event
  88.   public void actionPerformed(ActionEvent e) {
  89.     if (e.getSource() == button1) {
  90.       cancel();
  91.     }
  92.   }
  93. }