/* * HiGUIBuilder.java * * Created on February 19, 2007, 12:49 PM */ /** * * @author aharris */ public class HiGUIBuilder extends javax.swing.JFrame { /** Creates new form HiGUIBuilder */ public HiGUIBuilder() { 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() { lblOutput = new javax.swing.JLabel(); txtInput = new javax.swing.JTextField(); clickMe = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); lblOutput.setFont(new java.awt.Font("Engravers MT", 0, 18)); lblOutput.setText("Please type your name"); txtInput.setFont(new java.awt.Font("Tahoma", 0, 18)); txtInput.setHorizontalAlignment(javax.swing.JTextField.CENTER); clickMe.setText("Click Me"); clickMe.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clickMeActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap(80, Short.MAX_VALUE) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(org.jdesktop.layout.GroupLayout.TRAILING, txtInput) .add(org.jdesktop.layout.GroupLayout.TRAILING, lblOutput, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .add(74, 74, 74)) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(clickMe) .add(192, 192, 192)))) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(49, 49, 49) .add(lblOutput) .add(31, 31, 31) .add(txtInput, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(51, 51, 51) .add(clickMe) .addContainerGap(97, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents private void clickMeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clickMeActionPerformed String user = txtInput.getText(); lblOutput.setText("Hi there, "+ user + "!"); }//GEN-LAST:event_clickMeActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new HiGUIBuilder().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton clickMe; private javax.swing.JLabel lblOutput; private javax.swing.JTextField txtInput; // End of variables declaration//GEN-END:variables }