/*
* ...\HelloSwingNetBeans\HelloSwingNetBeans\src\helloswingnetbeans\Main.java
*
* Created on September 3, 2005, 4:05 PM
* using netbeans 4.1 IDE
*
* Compare this source file with the HelloSwing.java file used in lecture
* and written with a text editor (not IDE).
*
* Note:
*
* - The use of the method initComponents() to hold all UI code written
* by the netbean's interface builder. Do not edit this method body.
*
- There are no import directories, so the IDE uses full path
* package names. For example: javax.swing.JFrame Versus JFrame.
*
- The default naming of variables, jButton1.
*
- The extra method exitForm(...).
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
package helloswingnetbeans;
/**
*
* @author Mike Barnes
*/
public class Main extends java.awt.Frame {
private boolean toggle = true;
/** Creates new form appFrame */
public Main() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jButton1.setText("Hello 585");
jButton1.setPreferredSize(new java.awt.Dimension(300, 100));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
add(jButton1, java.awt.BorderLayout.CENTER);
pack();
}
// //GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if (toggle)
jButton1.setText("Press me again");
else
jButton1.setText("Hello CS 585 !");
toggle = !toggle;
}//GEN-LAST:event_jButton1ActionPerformed
/** 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[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Main().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
// End of variables declaration//GEN-END:variables
}