LabelTextBeansDemopublic class LabelTextBeansDemo extends JFrame Demo of LabelText JavaBean |
Fields Summary |
---|
private JPanel | jPanel1 | private JButton | jButton1 | private JButton | jButton2 | private JPanel | jPanel2 | private LabelText | bean1 | private LabelText | bean2 |
Constructors Summary |
---|
public LabelTextBeansDemo()Initializes the Form
initComponents ();
pack ();
|
Methods Summary |
---|
private void | exitForm(java.awt.event.WindowEvent evt)Exit the Application//GEN-FIRST:event_exitForm
System.exit (0);
| private void | 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 FormEditor.//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");
| 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);
| private void | jButton2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton2ActionPerformed
System.exit(0);
| public static void | main(java.lang.String[] args)
new LabelTextBeansDemo ().show ();
|
|