001: /*
002: * TestFrame.java
003: *
004: * Created on October 2, 2003, 10:48 AM
005: */
006:
007: package data;
008:
009: /**
010: *
011: * @author eh103527
012: */
013: public class TestFrame extends javax.swing.JFrame {
014:
015: /** Creates new form TestFrame */
016: public TestFrame() {
017: initComponents();
018: }
019:
020: /** This method is called from within the constructor to
021: * initialize the form.
022: * WARNING: Do NOT modify this code. The content of this method is
023: * always regenerated by the Form Editor.
024: */
025: private void initComponents() {//GEN-BEGIN:initComponents
026: jPanel1 = new javax.swing.JPanel();
027: messageL = new javax.swing.JLabel();
028: jPanel2 = new javax.swing.JPanel();
029: helloB = new javax.swing.JButton();
030: closeB = new javax.swing.JButton();
031:
032: setTitle("Test Frame");
033: addWindowListener(new java.awt.event.WindowAdapter() {
034: public void windowClosing(java.awt.event.WindowEvent evt) {
035: exitForm(evt);
036: }
037: });
038:
039: jPanel1.setBorder(new javax.swing.border.TitledBorder(
040: new javax.swing.border.EtchedBorder(),
041: "Message panel:",
042: javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
043: javax.swing.border.TitledBorder.DEFAULT_POSITION,
044: new java.awt.Font("Dialog", 1, 12)));
045: messageL.setFont(new java.awt.Font("Dialog", 0, 18));
046: messageL.setText(" ");
047: jPanel1.add(messageL);
048:
049: getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
050:
051: jPanel2.setLayout(new java.awt.FlowLayout(
052: java.awt.FlowLayout.CENTER, 20, 5));
053:
054: helloB.setText("Hello");
055: helloB.addActionListener(new java.awt.event.ActionListener() {
056: public void actionPerformed(java.awt.event.ActionEvent evt) {
057: helloBActionPerformed(evt);
058: }
059: });
060:
061: jPanel2.add(helloB);
062:
063: closeB.setText("Close");
064: closeB.addActionListener(new java.awt.event.ActionListener() {
065: public void actionPerformed(java.awt.event.ActionEvent evt) {
066: closeBActionPerformed(evt);
067: }
068: });
069:
070: jPanel2.add(closeB);
071:
072: getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH);
073:
074: pack();
075: }//GEN-END:initComponents
076:
077: private void closeBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeBActionPerformed
078: // Add your handling code here:
079: new Thread() {
080: public void run() {
081: messageL.setText(" ");
082: messageL.setForeground(java.awt.Color.RED);
083: messageL.setText("Bye bye!!");
084: try {
085: sleep(2000);
086: } catch (Exception ex) {
087: }
088: exitForm(null);
089: }
090: }.start();
091: }//GEN-LAST:event_closeBActionPerformed
092:
093: private void helloBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helloBActionPerformed
094: // Add your handling code here:
095: javax.swing.SwingUtilities.invokeLater(new Runnable() {
096: public void run() {
097: messageL.setText("Hello world!!");
098: }
099: });
100: }//GEN-LAST:event_helloBActionPerformed
101:
102: /** Exit the Application */
103: private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
104: System.exit(0);
105: }//GEN-LAST:event_exitForm
106:
107: /**
108: * @param args the command line arguments
109: */
110: public static void main(String args[]) {
111: new TestFrame().show();
112: }
113:
114: // Variables declaration - do not modify//GEN-BEGIN:variables
115: private javax.swing.JButton closeB;
116: private javax.swing.JButton helloB;
117: private javax.swing.JPanel jPanel1;
118: private javax.swing.JPanel jPanel2;
119: private javax.swing.JLabel messageL;
120: // End of variables declaration//GEN-END:variables
121:
122: }
|