FileDocCategorySizeDatePackage
LabelTextBeansDemo.javaAPI DocExample3281Sat Jan 27 21:38:42 GMT 2001None

LabelTextBeansDemo.java

import javax.swing.*;

/**
 * Demo of LabelText JavaBean
 * @author  Ian Darwin, ian@darwinsys.com
 * @version $Id: LabelTextBeansDemo.java,v 1.1 2001/01/28 02:38:43 ian Exp $
 */
public class LabelTextBeansDemo extends javax.swing.JFrame {

  /** Initializes the Form */
  public LabelTextBeansDemo() {
    initComponents ();
    pack ();
  }

  /** 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 FormEditor.
   */
  private void initComponents () {//GEN-BEGIN:initComponents
    addWindowListener (new java.awt.event.WindowAdapter () {
        public void windowClosing (java.awt.event.WindowEvent evt) {
          exitForm (evt);
        }
      }
    );
    getContentPane ().setLayout (new java.awt.BorderLayout ());

    jPanel1 = new javax.swing.JPanel ();
    jPanel1.setLayout (new java.awt.FlowLayout ());

      jButton1 = new javax.swing.JButton ();
      jButton1.setText ("Display");
      jButton1.addActionListener (new java.awt.event.ActionListener () {
          public void actionPerformed (java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed (evt);
          }
        }
      );
      jPanel1.add (jButton1);

      jButton2 = new javax.swing.JButton ();
      jButton2.setText ("Exit");
      jButton2.addActionListener (new java.awt.event.ActionListener () {
          public void actionPerformed (java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed (evt);
          }
        }
      );
      jPanel1.add (jButton2);

    getContentPane ().add (jPanel1, "South");

    jPanel2 = new javax.swing.JPanel ();
    jPanel2.setLayout (new javax.swing.BoxLayout (jPanel2, 1));

      bean1 = new LabelText ();
      bean1.setLabel ("Name:");
      jPanel2.add (bean1);

      bean2 = new LabelText ();
      bean2.setLabel ("Address:");
      jPanel2.add (bean2);

    getContentPane ().add (jPanel2, "Center");

  }//GEN-END:initComponents

  private void jButton1ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    String name = bean1.getText();
    String addr = bean2.getText();
    JOptionPane.showMessageDialog(this,
      "Name = " + name + "\n" +
      "Addr = " + addr,
      "Info",
      JOptionPane.INFORMATION_MESSAGE);
  }//GEN-LAST:event_jButton1ActionPerformed

  private void jButton2ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    System.exit(0);
  }//GEN-LAST:event_jButton2ActionPerformed

  /** Exit the Application */
  private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
    System.exit (0);
  }//GEN-LAST:event_exitForm


// Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JPanel jPanel1;
  private javax.swing.JButton jButton1;
  private javax.swing.JButton jButton2;
  private javax.swing.JPanel jPanel2;
  private LabelText bean1;
  private LabelText bean2;
// End of variables declaration//GEN-END:variables


  public static void main(java.lang.String[] args) {
    new LabelTextBeansDemo ().show ();
  }

}