1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
/*
* TestFrame.java
*
* Created on October 2, 2003, 10:48 AM
*/
package data;
/**
*
* @author eh103527
*/
public class TestFrame extends javax.swing.JFrame {
/** Creates new form TestFrame */
public TestFrame() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
jPanel1 = new javax.swing.JPanel();
messageL = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
helloB = new javax.swing.JButton();
closeB = new javax.swing.JButton();
setTitle(java.util.ResourceBundle.getBundle("data/resources/properties").getString("Test_Frame"));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jPanel1.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), "Message panel:"));
messageL.setFont(new java.awt.Font("Dialog", 0, 18));
messageL.setText(" ");
jPanel1.add(messageL);
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 20, 5));
helloB.setText(java.util.ResourceBundle.getBundle("data/resources/properties").getString("hello_button"));
helloB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
helloBActionPerformed(evt);
}
});
jPanel2.add(helloB);
closeB.setText("Close");
closeB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
closeBActionPerformed(evt);
}
});
jPanel2.add(closeB);
getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH);
pack();
}//GEN-END:initComponents
private void closeBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeBActionPerformed
// Add your handling code here:
new Thread() {
public void run() {
messageL.setText(" ");
messageL.setForeground(java.awt.Color.RED);
messageL.setText("Bye bye!!");
try {
sleep(2000);
} catch (Exception ex) {
}
exitForm(null);
}
}.start();
}//GEN-LAST:event_closeBActionPerformed
private void helloBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helloBActionPerformed
// Add your handling code here:
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
messageL.setText("Hello world!!");
}
});
}//GEN-LAST:event_helloBActionPerformed
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new TestFrame().show();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton closeB;
private javax.swing.JButton helloB;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel messageL;
// End of variables declaration//GEN-END:variables
}
|