JF_view_error.java
上传用户:whbcdz
上传日期:2008-08-04
资源大小:7683k
文件大小:4k
源码类别:

JavaScript

开发平台:

Java

  1. package appjxc.view;
  2. import java.awt.BorderLayout;
  3. import javax.swing.JFrame;
  4. import javax.swing.JTextPane;
  5. import java.awt.Toolkit;
  6. import java.awt.Dimension;
  7. import javax.swing.BorderFactory;
  8. import javax.swing.border.BevelBorder;
  9. import java.awt.Color;
  10. import javax.swing.border.Border;
  11. import javax.swing.border.TitledBorder;
  12. import javax.swing.JPanel;
  13. import javax.swing.JButton;
  14. import java.awt.FlowLayout;
  15. import javax.swing.JLabel;
  16. import java.awt.event.ActionEvent;
  17. import java.awt.event.ActionListener;
  18. import javax.swing.JScrollPane;
  19. public class JF_view_error extends JFrame {
  20.     BorderLayout borderLayout1 = new BorderLayout();
  21.     JTextPane jTextPane1 = new JTextPane();
  22.     String errorInfo = null;
  23.     Border border1 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
  24.             Color.red, Color.red, Color.magenta, Color.magenta);
  25.     Border border2 = new TitledBorder(border1, "操作数据库错误信息");
  26.     JPanel jPanel1 = new JPanel();
  27.     JButton jButton1 = new JButton();
  28.     FlowLayout flowLayout1 = new FlowLayout();
  29.     JLabel jLabel1 = new JLabel();
  30.     JScrollPane jScrollPane1 = new JScrollPane();
  31.     JButton jButton2 = new JButton();
  32.     public JF_view_error(String error) {
  33.         this.errorInfo = error;
  34.         try {
  35.             jbInit();
  36.         } catch (Exception exception) {
  37.             exception.printStackTrace();
  38.         }
  39.     }
  40.     private void jbInit() throws Exception {
  41.         getContentPane().setLayout(borderLayout1);
  42.         jTextPane1.setBorder(border2);
  43.         jTextPane1.setText(this.errorInfo);
  44.         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  45.         this.setTitle("系统提示");
  46.         jButton1.setText("关闭");
  47.         jButton1.addActionListener(new JF_view_error_jButton1_actionAdapter(this));
  48.         jPanel1.setLayout(flowLayout1);
  49.         flowLayout1.setAlignment(FlowLayout.RIGHT);
  50.         jButton2.setText("终止程序");
  51.         jButton2.addActionListener(new JF_view_error_jButton2_actionAdapter(this));
  52.         this.getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
  53.         jPanel1.add(jButton2);
  54.         jPanel1.add(jButton1);
  55.         this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
  56.         this.getContentPane().add(jLabel1, java.awt.BorderLayout.NORTH);
  57.         jScrollPane1.getViewport().add(jTextPane1);
  58.         this.setSize(350,250);
  59.         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  60.         Dimension frameSize = this.getSize();
  61.         if (frameSize.height > screenSize.height) {
  62.             frameSize.height = screenSize.height;
  63.         }
  64.         if (frameSize.width > screenSize.width) {
  65.             frameSize.width = screenSize.width;
  66.         }
  67.         this.setLocation((screenSize.width - frameSize.width) / 2,
  68.                           (screenSize.height - frameSize.height) / 2);
  69.         this.setVisible(true);
  70.     }
  71.     public static void main(String args[]){
  72.         JF_view_error error = new JF_view_error("哈哈,哈你来了");
  73.     }
  74.     public void jButton1_actionPerformed(ActionEvent e) {
  75.         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  76.         this.setVisible(false);
  77.     }
  78.     public void jButton2_actionPerformed(ActionEvent e) {
  79.         System.exit(0);
  80.     }
  81. }
  82. class JF_view_error_jButton2_actionAdapter implements ActionListener {
  83.     private JF_view_error adaptee;
  84.     JF_view_error_jButton2_actionAdapter(JF_view_error adaptee) {
  85.         this.adaptee = adaptee;
  86.     }
  87.     public void actionPerformed(ActionEvent e) {
  88.         adaptee.jButton2_actionPerformed(e);
  89.     }
  90. }
  91. class JF_view_error_jButton1_actionAdapter implements ActionListener {
  92.     private JF_view_error adaptee;
  93.     JF_view_error_jButton1_actionAdapter(JF_view_error adaptee) {
  94.         this.adaptee = adaptee;
  95.     }
  96.     public void actionPerformed(ActionEvent e) {
  97.         adaptee.jButton1_actionPerformed(e);
  98.     }
  99. }