1 23 24 31 32 package com.sun.enterprise.security; 33 import javax.swing.*; 34 import java.awt.*; 35 import java.awt.event.*; 36 37 public class GUIErrorDialog extends javax.swing.JDialog { 38 String message; 39 40 public GUIErrorDialog (String message){ 41 super (new JFrame (), true); 42 this.message = message; 43 initComponents (); 44 pack (); 45 } 46 49 private void initComponents() { 50 okButton = new javax.swing.JButton (); 51 errorLbl = new javax.swing.JLabel (); 52 okButton.setAlignmentX (CENTER_ALIGNMENT); 53 errorLbl.setAlignmentX (CENTER_ALIGNMENT); 54 getContentPane().setLayout (new javax.swing.BoxLayout (getContentPane (),BoxLayout.Y_AXIS)); 55 addWindowListener(new java.awt.event.WindowAdapter () { 56 public void windowClosing(java.awt.event.WindowEvent evt) { 57 closeDialog(evt); 58 } 59 } 60 ); 61 62 okButton.setLabel("OK"); 63 okButton.setActionCommand("okButton"); 64 okButton.setText("OK"); 65 okButton.addActionListener (new ActionListener (){ 66 public void actionPerformed (ActionEvent e){ 67 dispose (); 68 } 69 }); 70 super.addWindowListener (new WindowAdapter (){ 71 public void windowClosing (WindowEvent we){ 72 dispose (); 73 } 74 }); 75 errorLbl.setText("Error : "+message); 76 getContentPane().add (errorLbl); 77 getContentPane().add (okButton); 78 } 79 80 81 private void closeDialog(java.awt.event.WindowEvent evt) { 82 setVisible (false); 83 dispose (); 84 } 85 86 private javax.swing.JButton okButton; 88 private javax.swing.JLabel errorLbl; 89 91 } 92 | Popular Tags |