|
What this is
Other links
The source code/* * 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("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:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 12))); 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("Hello"); 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 } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.