JTextField Problem

Hi
I have the following problem with JTextField:
I have a class which builds up an array of JTextFields.I have another class which takes the array and lays the JTextFields out on a JFrame. It also controls the size of the JTextFields. Sometimes the text is longer than the size of the TextField and by looking at it the user dose not know if there is more text. The problem is he cannot see that the text is truncated ie no ... at the end of the text.
I have to use JTextfields as it would take too much code change to use anything else.
Any one any suggestions
Thanks
B

Hi,
I hope having understood your problem.
I assume there that you know the string written in each textfield.
You can construct your textfields such as :
JTextField jT = new JTextField("MyKnownText");Then, you can do the following :
public class Test
    public static main(String[] args)
        // Your main
        TextField[] array = // ... Your array of textfields.
        setSameComponentSize(Arrays.asList(array));
     * Resize with the same maximum size all specified components.
     * @param sComponents The components to be resized
    public static void setSameComponentSize(List sComponents)
        // compute the maximum dimension
        // and get only components
        // The dimension to which resize all components.
        Dimension lMaxDim = new Dimension();
        // The dimension to compare.
        Dimension lCompSize;
        // The component to resize.
        JComponent lComp;
        for (Iterator lIter = sComponents.iterator(); lIter.hasNext();)
            lComp = (JComponent) lIter.next();
            if (lComp != null)
                lCompSize = lComp.getPreferredSize();
                if (lCompSize.width > lMaxDim.width)
                    lMaxDim.width = lCompSize.width;
                if (lCompSize.height > lMaxDim.height)
                    lMaxDim.height = lCompSize.height;
        // set the same size for all components
        for (Iterator lIter = sComponents.iterator(); lIter.hasNext();)
            lComp = (JComponent) lIter.next();
            if (lComp != null)
                lComp.setPreferredSize(lMaxDim);
                lComp.setMaximumSize(lMaxDim);
                lComp.setMinimumSize(lMaxDim);
}This code will set all the textfields to the same size that will be the maximum preferred size of the textfields.
I do not test it but I hope it will be helpful for you.
Stephane.

Similar Messages

  • JTable - JTextField (Problem in setClickCountToStart)

    Hi,
    I have a JTable and I am creating a text field using the following code...
    table.getColumn(columnNames[2]).setCellEditor(new DefaultCellEditor(new JTextField()));I am also using the following code so that I can start editing the field on single click.
    ( (DefaultCellEditor) table.getDefaultEditor(String.class)).setClickCountToStart(1); The problem is that it is not working (ie., i am not able to edit the field on single click, I am able to edit only on double click). Please help me.
    Thanks
    subbu

    I'm sure you've been asked for a SSCCE before. This question is no different. We can't tell what you are doing based on two lines of code.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
    http://homepage1.nifty.com/algafield/sscce.html
    Don't forget to use the "Code Formatting Tags", so the posted code retains its original formatting.
    http://forum.java.sun.com/help.jspa?sec=formatting

  • JTextField Problems

    Hello, I have got 6 JTextFields, where the user enters a value , I have a seventh JTextField where the value entered is multiplied in turn with the values entered in the previous six once a JButton is pressed. This then displays the result in an eight JTextField.
    Below is the code which I am having difficulties with.
    I want the output to be displayed in the last JTextField regardless of how many inputs. But i want to throw an exception if you try to enter in first field then skip to the third field.
    But my eception is being thrown even if only enter two inputs and then press the button which I want to be acceptable.
    private class ButtonHandler implements ActionListener {
    public void actionPerformed( ActionEvent e ) {
    DecimalFormat precision3 = new DecimalFormat( "0.00" );
    try
    stake1 = Integer.parseInt( stakeField.getText() );
    catch ( NumberFormatException nfe2 ) {
    JOptionPane.showMessageDialog( null, "You Havent entered a stake",
    "Error",
                                                                               JOptionPane.ERROR_MESSAGE );
    }// End Catch
    try {
    // First TextArea
    text1d = Integer.parseInt( text1.getText() );
    int result1 = text1d * stake1;
    field.setText( precision3.format( result1 ) );
    // Second TextArea
    if( text2.getText() == null )
    field.setText( precision3.format( result1 ) );
    text2d = Integer.parseInt( text2.getText() );     
    int result2 = text1d * text2d * stake1;
    field.setText( precision3.format( result2 ) );
    // Third TextArea
    if( text3.getText() == null )
    field.setText( precision3.format( result2 ) );
    text3d = Integer.parseInt( text3.getText() );     
    int result3 = text1d * text2d * text3d * stake1;
    field.setText( precision3.format( result3 ) );
    catch ( NumberFormatException nfe ) {
    JOptionPane.showMessageDialog( null, "You Havent entered an odd",
    "Error",
                                                                               JOptionPane.ERROR_MESSAGE );
    }

    if you try to enter in first field then skip to the third fieldIt's extremely difficult to force the user to enter fields in a specific order. And it's not a good user interface design either. When the button is clicked, just validate whatever data is in the fields at that time.
    Also, the message you display (You Havent entered a stake) could be misleading. It can also appear if the user has entered something that can't be parsed as an integer, for example 1.5.

  • Problem with focus and selecting text in jtextfield

    I have problem with jtexfield. I know that solution will be very simple but I can't figure it out.
    This is simplified version of situation:
    I have a jframe, jtextfield and jbutton. User can put numbers (0-10000) separated with commas to textfield and save those numbers by pressing jbutton.
    When jbutton is pressed I have a validator which checks that jtextfield contains only numbers and commas. If validator sees that there are invalid characters, a messagebox is launched which tells to user whats wrong.
    Now comes the tricky part.
    When user presses ok from messagebox, jtextfield should select the character which validator said was invalid so that user can replace it by pressing a number or comma.
    I have the invalid character, but how can you get the focus to jtextfield and select only the character which was invalid?
    I tried requestFocus(), but it selected whole text in jtextfield and after that command I couldn't set selected text. I tried with commands setSelectionStart(int), setSelectionEnd(int) and select(int,int).
    Then I tried to use Caret and select text with that. It selected the character I wanted, but the focus wasn't really there because it didn't have keyFocus (or something like that).
    Is there a simple way of doing this?

    textField.requestFocusInWindow();
    textField.select(...);The above should work, although read the API on the select(...) method for the newer recommended approach on how to do selection.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
    see http://homepage1.nifty.com/algafield/sscce.html,
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the "Code Formatting Tags",
    see http://forum.java.sun.com/help.jspa?sec=formatting,
    so the posted code retains its original formatting.

  • Problem with PropertyChangeListener and JTextField

    I'm having a problem with PropertyChangeListener and JTextField.
    I can not seem to get the propertychange event to fire.
    Anyone have any idea why the code below doesn't work?
    * NewJFrame.java
    * Created on May 15, 2005, 4:21 PM
    import java.beans.*;
    import javax.swing.*;
    * @author wolfgray
    public class NewJFrame extends javax.swing.JFrame
    implements PropertyChangeListener {
    /** Creates new form NewJFrame */
    public NewJFrame() {
    initComponents();
    jTextField1.addPropertyChangeListener( this );
    public void propertyChange(PropertyChangeEvent e) {
    System.out.println(e);
    /** 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() {
    jTextField1 = new javax.swing.JTextField();
    jScrollPane1 = new javax.swing.JScrollPane();
    jFormattedTextField1 = new javax.swing.JFormattedTextField();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jTextField1.setText("jTextField1");
    getContentPane().add(jTextField1, java.awt.BorderLayout.NORTH);
    jFormattedTextField1.setText("jFormattedTextField1");
    jScrollPane1.setViewportView(jFormattedTextField1);
    getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
    pack();
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new NewJFrame().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration
    }

    If you want to listen to changes in the textfield's contents you should use a DocumentListener and not a PropertyChangeListener:
    http://java.sun.com/docs/books/tutorial/uiswing/events/documentlistener.html
    And please use [co[/i]de]  tags when you are posting code (press the code button above the message window).

  • Memory problem with JTextFields

    Hello,
    I have a wierd problem with JTextField and the memory.
    I need to fill a JPanel with different Components (including JTextFields), then do some calculation, remove the Components and filling the JPanel again.
    When i so this too often my i get an OutOfMemory Exception. I narrowed to problem down and wrote a small sample program to demonstrate the problem.
    When i call the method doIT (where the Panel is repeatedly filled) from the main-function everything works fine, but when it is called as a result from the GUI-Button-Event the memory for the JTextFields is not freed (even the call of the Garbage collector changes nothing)
    When i only use JButtons to fill the Panel everything works fine.
    Has anyone an idea why this problem occurs and how i can work around it?
    [Edit] I tested it whith java 1.5.0_06, 1.5.0_11, 1.6.0_02
    Thanks
    Marc
    import java.awt.Frame;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.lang.management.ManagementFactory;
    import java.lang.management.MemoryUsage;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class MemoryTestDLG extends JDialog {
         public MemoryTestDLG(Frame owner) {
              // create Dialog with one Button that calls the testMethod
              super(owner);
              JButton b = new JButton("doIT ...");
              b.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        doIT();
                        setVisible(false);
              getContentPane().add(b);
              pack();
         public void doIT() {
              // Testmethod that fills a JPanel 20 times with Components and clears it
              // again
              JPanel p = new JPanel();
              long memUse1 = 0;
              long memUse2 = 0;
              long memUseTemp = 0;
              for (int count = 0; count < 20; count++) {
                   // Clear the panel
                   p.removeAll();
                   // Get memory usage before the task
                   Runtime.getRuntime().gc();
                   memUse1 = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()
                             .getUsed();
                   // Fill Panel with components
                   for (int i = 0; i < 200; i++) {
                        // The Buttons seem to be released without any problem
                        p.add(new JButton("test" + Math.random()));
                        // JTextFields are not released when used from the dialog.
                        p.add(new JTextField("test " + Math.random()));
                   // get memory usage after the task
                   Runtime.getRuntime().gc();
                   memUseTemp = memUse2;
                   memUse2 = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()
                             .getUsed();
                   // print Memory results
                   System.out.println("Memory Usage: " + f(memUse1) + "   ->"
                             + f(memUse2) + " [ Used:" + f(memUse2 - memUse1)
                             + " ] [ Freed: " + f(memUseTemp - memUse1) + "]");
         public String f(long m) // formats the output
              String s = "" + m;
              while (s.length() < 8)
                   s = " " + s;
              return s;
         public static void main(String[] args) {
              MemoryTestDLG d = new MemoryTestDLG(null);
              System.out
                        .println("------------------ Direct Call (all is OK) -------------------");
              d.doIT(); // Memory is freed with every call to JPanel.removeAll()
              System.out
                        .println("------------ Call from Dialog (memory is not freed) -------------");
              // The Memory keeps blocked
              d.setModal(true);
              d.setVisible(true);
              System.exit(0);
    }Message was edited by:
    marcvomorc

    Thank you for your answer,
    In this sample the programm does not run out of memory. But when you look at the output you see, that in the first run (direct call) the memory ist freed immediately when tha panel is cleared but in the second run (from the Button) the memory usage is getting bigger and bigger. Wenn you change the number of components to 2000 (4000)
    // Fill Panel with components
            for (int i = 0; i < 2000; i++) {
                // The Buttons seem to be released without any problem
    //... ...and use the default memory settings (69mb heap) the programm runns out of memory.
    I get the following output:
    ------------------ Direct Call (all is OK) -------------------
    Memory Usage:   445504   -> 8121016 [ Used: 7675512 ] [ Freed:  -445504]
    Memory Usage:   617352   -> 8114336 [ Used: 7496984 ] [ Freed:  7503664]
    Memory Usage:   810488   -> 8491768 [ Used: 7681280 ] [ Freed:  7303848]
    Memory Usage:   943704   -> 8114976 [ Used: 7171272 ] [ Freed:  7548064]
    Memory Usage:   836760   -> 8505072 [ Used: 7668312 ] [ Freed:  7278216]
    Memory Usage:   978352   -> 8114784 [ Used: 7136432 ] [ Freed:  7526720]
    Memory Usage:   835552   -> 8498288 [ Used: 7662736 ] [ Freed:  7279232]
    Memory Usage:   977096   -> 8114312 [ Used: 7137216 ] [ Freed:  7521192]
    Memory Usage:   835640   -> 8498376 [ Used: 7662736 ] [ Freed:  7278672]
    Memory Usage:   977296   -> 8115000 [ Used: 7137704 ] [ Freed:  7521080]
    Memory Usage:   835392   -> 8504872 [ Used: 7669480 ] [ Freed:  7279608]
    Memory Usage:   976968   -> 8115192 [ Used: 7138224 ] [ Freed:  7527904]
    Memory Usage:   836224   -> 8501624 [ Used: 7665400 ] [ Freed:  7278968]
    Memory Usage:   977840   -> 8115120 [ Used: 7137280 ] [ Freed:  7523784]
    Memory Usage:   835664   -> 8498256 [ Used: 7662592 ] [ Freed:  7279456]
    Memory Usage:   976856   -> 8114384 [ Used: 7137528 ] [ Freed:  7521400]
    Memory Usage:   835784   -> 8502848 [ Used: 7667064 ] [ Freed:  7278600]
    Memory Usage:   977360   -> 8114592 [ Used: 7137232 ] [ Freed:  7525488]
    Memory Usage:   835496   -> 8502720 [ Used: 7667224 ] [ Freed:  7279096]
    Memory Usage:   976440   -> 8115128 [ Used: 7138688 ] [ Freed:  7526280]
    ------------ Call from Dialog (memory is not freed) -------------
    Memory Usage:   866504   -> 8784320 [ Used: 7917816 ] [ Freed:  -866504]
    Memory Usage:  7480760   ->14631152 [ Used: 7150392 ] [ Freed:  1303560]
    Memory Usage: 14245264   ->22127104 [ Used: 7881840 ] [ Freed:   385888]
    Memory Usage: 19302896   ->27190744 [ Used: 7887848 ] [ Freed:  2824208]
    Memory Usage: 27190744   ->35073944 [ Used: 7883200 ] [ Freed:        0]
    Memory Usage: 31856624   ->39740176 [ Used: 7883552 ] [ Freed:  3217320]
    Memory Usage: 39740176   ->47623040 [ Used: 7882864 ] [ Freed:        0]
    Memory Usage: 44410480   ->52293864 [ Used: 7883384 ] [ Freed:  3212560]
    Memory Usage: 52293864   ->58569304 [ Used: 6275440 ] [ Freed:        0]
    Memory Usage: 58569304   ->64846400 [ Used: 6277096 ] [ Freed:        0]
    Exception occurred during event dispatching:
    java.lang.OutOfMemoryError: Java heap spacewhen I outcomment the adding of the JButtons the amount of freed memory is 0 in the second run. So my guess is, that there is a problem with freeing the memory for the JTextFields.
    Memory Usage:   447832   -> 6509960 [ Used: 6062128 ] [ Freed:  6332768]
    Memory Usage:   722776   -> 6785632 [ Used: 6062856 ] [ Freed:  5787184]
    ------------ Call from Dialog (memory is not freed) -------------
    Memory Usage:   468880   -> 6770240 [ Used: 6301360 ] [ Freed:  -468880]
    Memory Usage:  6770240   ->13016264 [ Used: 6246024 ] [ Freed:        0]
    Memory Usage: 13016264   ->19297080 [ Used: 6280816 ] [ Freed:        0]
    Memory Usage: 19297080   ->25570152 [ Used: 6273072 ] [ Freed:        0]
    Memory Usage: 25570152   ->31849160 [ Used: 6279008 ] [ Freed:        0]
    Memory Usage: 31849160   ->38124368 [ Used: 6275208 ] [ Freed:        0]
    Memory Usage: 38124368   ->44402072 [ Used: 6277704 ] [ Freed:        0]
    Memory Usage: 44402072   ->50677928 [ Used: 6275856 ] [ Freed:        0]
    Memory Usage: 50677928   ->56955880 [ Used: 6277952 ] [ Freed:        0]
    Memory Usage: 56955880   ->63232152 [ Used: 6276272 ] [ Freed:        0]
    Exception occurred during event dispatching:
    java.lang.OutOfMemoryError: Java heap spaceAdditionally the JPanel I am using is not displayed on the screen. It stays invisible the whole time, but i cannot work around that, because the calculation is depending on the values being in components on the JPanel)
    Marc

  • Problem in assigning Database Value to jTextfield (form doesn't show up)

    Hi,
    I'm trying to get an integer value from database, add 1 to it and assign it to a jTextfield in formInternalFrameOpened event, but this causes the form not to open.
    If I remove just this thing the rest of the form works fine.
    The open event has no problem it works fine, I have checked with jOptionDialog.
    heres the code
        private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {                                        
    // Get last driver ID, add 1 to it and assign it to driver ID JTextField
            Connection con = null;
            try
                MyDBConnection myDBConnection = new MyDBConnection();
                myDBConnection.init();
                con = myDBConnection.getMyConnection();
                Statement pullStmt = con.createStatement();
                ResultSet pullRs = pullStmt.executeQuery("SELECT key_driverId FROM drivers ORDER BY key_driverId DESC LIMIT 1");
                pullRs.first();
                driverId.setText(String.valueOf(pullRs.getInt("key_driverId")+1));
                pullRs.close();
                con.close();
            catch(SQLException e){}
        }   

    Thanks, here it is.... Remember, I'm trying to insert a value from database into jTextfield in formInternalFrameOpened event.
    * NewDriver.java
    * Created on August 9, 2007, 9:14 AM
    package LimoApp;
    import java.sql.*;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import javax.swing.JOptionPane;
    * @author  NKA
    public class NewDriver extends javax.swing.JInternalFrame {
        /** Creates new form NewDriver */
        public NewDriver() {
            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.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            driverId = new javax.swing.JTextField();
            firstName = new javax.swing.JTextField();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            lastName = new javax.swing.JTextField();
            jLabel5 = new javax.swing.JLabel();
            address = new javax.swing.JTextField();
            jLabel6 = new javax.swing.JLabel();
            city = new javax.swing.JTextField();
            jLabel7 = new javax.swing.JLabel();
            state = new javax.swing.JComboBox();
            jLabel8 = new javax.swing.JLabel();
            zipcode = new javax.swing.JTextField();
            jLabel9 = new javax.swing.JLabel();
            workPhone = new javax.swing.JTextField();
            jLabel10 = new javax.swing.JLabel();
            extention = new javax.swing.JTextField();
            jLabel11 = new javax.swing.JLabel();
            homePhone = new javax.swing.JTextField();
            jLabel12 = new javax.swing.JLabel();
            mobilePhone = new javax.swing.JTextField();
            jLabel13 = new javax.swing.JLabel();
            dispatchEmail = new javax.swing.JTextField();
            personalEmail = new javax.swing.JTextField();
            jPanel3 = new javax.swing.JPanel();
            licenseNumber = new javax.swing.JTextField();
            jLabel18 = new javax.swing.JLabel();
            socialSecurityNumber = new javax.swing.JTextField();
            jLabel19 = new javax.swing.JLabel();
            dateOfBirth = new javax.swing.JTextField();
            jLabel20 = new javax.swing.JLabel();
            hireDate = new javax.swing.JTextField();
            jLabel21 = new javax.swing.JLabel();
            vehicleAssigned = new javax.swing.JComboBox();
            jLabel22 = new javax.swing.JLabel();
            jPanel4 = new javax.swing.JPanel();
            payWaitingTime = new javax.swing.JCheckBox();
            payExtraStops = new javax.swing.JCheckBox();
            payEarlyLate = new javax.swing.JCheckBox();
            payTolls = new javax.swing.JCheckBox();
            payParking = new javax.swing.JCheckBox();
            payGasSurcharge = new javax.swing.JCheckBox();
            gratuity = new javax.swing.JTextField();
            jLabel14 = new javax.swing.JLabel();
            jLabel15 = new javax.swing.JLabel();
            commission = new javax.swing.JTextField();
            perHourRate = new javax.swing.JTextField();
            perMileRate = new javax.swing.JTextField();
            jLabel16 = new javax.swing.JLabel();
            jLabel17 = new javax.swing.JLabel();
            btNewDriverSave = new javax.swing.JButton();
            setClosable(true);
            setIconifiable(true);
            setTitle("New Driver");
            addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
                public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                    formInternalFrameOpened(evt);
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Driver", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(102, 0, 0)));
            driverId.setEditable(false);
            driverId.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            firstName.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    firstNameFocusLost(evt);
            jLabel1.setText("Dispatch Email");
            jLabel2.setText("Personal Email");
            jLabel3.setText("Driver ID");
            jLabel4.setText("First Name");
            lastName.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    lastNameFocusLost(evt);
            jLabel5.setText("Last Name");
            jLabel6.setText("Address");
            jLabel7.setText("City");
            state.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "AL", "VA" }));
            jLabel8.setText("State");
            zipcode.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    zipcodeFocusLost(evt);
            jLabel9.setText("Zipcode");
            workPhone.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    workPhoneFocusLost(evt);
            jLabel10.setText("Work Phone");
            extention.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    extentionFocusLost(evt);
            jLabel11.setText("Extention");
            homePhone.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    homePhoneFocusLost(evt);
            jLabel12.setText("Home Phone");
            mobilePhone.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    mobilePhoneFocusLost(evt);
            jLabel13.setText("Cell");
            dispatchEmail.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    dispatchEmailFocusLost(evt);
            personalEmail.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    personalEmailFocusLost(evt);
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(8, 8, 8)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel12)
                                .addComponent(jLabel10)
                                .addComponent(jLabel4)
                                .addComponent(jLabel3)
                                .addComponent(jLabel6)
                                .addComponent(jLabel7)))
                        .addComponent(jLabel1)
                        .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(firstName, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel5)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lastName))
                        .addComponent(address)
                        .addComponent(dispatchEmail)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(workPhone, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(city, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                                .addComponent(homePhone, javax.swing.GroupLayout.Alignment.LEADING))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel8)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(10, 10, 10)
                                            .addComponent(jLabel11)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(extention, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(state, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel9)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(zipcode))))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel13)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(mobilePhone, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addComponent(personalEmail)
                        .addComponent(driverId, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(driverId, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(jLabel5)
                        .addComponent(lastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(firstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel6)
                        .addComponent(address, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel7)
                        .addComponent(city, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(state, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel8)
                        .addComponent(jLabel9)
                        .addComponent(zipcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(workPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel10)
                        .addComponent(jLabel11)
                        .addComponent(extention, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel12)
                        .addComponent(jLabel13)
                        .addComponent(mobilePhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(homePhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(dispatchEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(personalEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Documents", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(102, 0, 0)));
            licenseNumber.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    licenseNumberFocusLost(evt);
            jLabel18.setText("License #");
            socialSecurityNumber.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    socialSecurityNumberFocusLost(evt);
            jLabel19.setText("Social Security #");
            dateOfBirth.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    dateOfBirthFocusLost(evt);
            jLabel20.setText("Date of Birth");
            hireDate.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    hireDateFocusLost(evt);
            jLabel21.setText("Hire Date");
            vehicleAssigned.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            jLabel22.setText("Vehicle Assigned");
            javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel18)
                                .addComponent(jLabel19))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(socialSecurityNumber)
                                .addComponent(licenseNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel20)
                                .addComponent(jLabel21))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(hireDate)
                                .addComponent(dateOfBirth, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel22)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(vehicleAssigned, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel18)
                                .addComponent(licenseNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel19)
                                .addComponent(socialSecurityNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel20)
                                .addComponent(dateOfBirth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(hireDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel21))))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(vehicleAssigned, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel22))
                    .addContainerGap())
            jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Payroll Stettings", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(102, 0, 0)));
            payWaitingTime.setText("Pay Waiting Time");
            payWaitingTime.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payWaitingTime.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payExtraStops.setText("Pay Extra Stops");
            payExtraStops.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payExtraStops.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payEarlyLate.setText("Pay Early / Late");
            payEarlyLate.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payEarlyLate.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payTolls.setText("Pay Tolls");
            payTolls.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payTolls.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payParking.setText("Pay Parking");
            payParking.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payParking.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payGasSurcharge.setText("Pay Gas Surcharge");
            payGasSurcharge.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payGasSurcharge.setMargin(new java.awt.Insets(0, 0, 0, 0));
            gratuity.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            gratuity.setText("0");
            gratuity.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    gratuityFocusLost(evt);
            jLabel14.setText("Gratuity %");
            jLabel15.setText("Commission %");
            commission.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            commission.setText("0");
            commission.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    commissionFocusLost(evt);
            perHourRate.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            perHourRate.setText("0");
            perHourRate.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    perHourRateFocusLost(evt);
            perMileRate.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            perMileRate.setText("0");
            perMileRate.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    perMileRateFocusLost(evt);
            jLabel16.setText("Per Mile Rate");
            jLabel17.setText("Per Hour Rate");
            javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
            jPanel4.setLayout(jPanel4Layout);
            jPanel4Layout.setHorizontalGroup(
                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addGap(16, 16, 16)
                            .addComponent(jLabel14)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(gratuity, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(9, 9, 9)
                            .addComponent(jLabel16)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(perMileRate, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addComponent(jLabel15)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(commission, 0, 0, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel17)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(perHourRate, 0, 0, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(payWaitingTime)
                                .addComponent(payEarlyLate)
                                .addComponent(payExtraStops))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel4Layout.createSequentialGroup()
                                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(payParking)
                                        .addComponent(payTolls))
                                    .addGap(36, 36, 36))
                                .addComponent(payGasSurcharge))))
                    .addContainerGap())
            jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {commission, gratuity, perHourRate, perMileRate});
            jPanel4Layout.setVerticalGroup(
                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(gratuity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(perMileRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(14, 14, 14)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(commission, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

  • JTextField update problem when called from PropertyChangeEvent

    Hi,
    I'm trying to create forms that can be dynamically loaded with Class.forname(formName).
    Those forms should always inherit some methods that make it easy to pass data to
    them and receive data from them. The idea is that the data comes from a table which
    sends a hashmap (String column/JTextField-name + String Value pairs) with firePropertyChanged
    as soon as a new row is seleceted. The JTextFields in the form are marked with setName("FieldName") that has to correspond to the name of the columns of the table.
    My problem is that I can't update the fields in my form when I'm calling getRow(HashMap)
    from within propertyChangeEvent but that's necessary to keep the forms flexible.
    JTextFieldName.setText(newText) just won't work. But it works when I call getRow(HashMap)
    from the constructor. SwingWorker and threads to update the form didn't help.
    I don't need to call pack() / update() / repaint() on the JFrame, do I ??
    update() / validate() / repaint() etc. didn't work on the JTextField themselves.
    Below is the code for one of the test-forms (just a JPanel that is inserted in a frame)
    with all of it's methods. Does anybody have a solution to this problem ??
    Thanks for taking time for that !!
    Benjamin
    * testTable.java
    * Created on 15. April 2004, 16:12
    package viewcontrol.GUI;
    * @author gerbarmb
    import javax.swing.*;
    import java.awt.*;
    import java.beans.*;
    import java.util.*;
    public class testTable extends javax.swing.JPanel
              implements
                   java.awt.event.KeyListener,
                   java.beans.PropertyChangeListener {
          * public static void main(String[] argv) { testTable tt = new testTable();
          * JFrame jf = new JFrame(); jf.setContentPane(tt); jf.setVisible(true); }
         /** Creates new customizer testTable */
         public testTable() {
              initComponents();
              HashMap hm = new HashMap();
               * Only for debugging, to see that the method getRow() works when
               * called from the constructor.
               hm.put("ttext", "TEst");
               this.getRow(hm);
          * 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
              java.awt.GridBagConstraints gridBagConstraints;
              jLabel1 = new javax.swing.JLabel();
              textIn = new javax.swing.JTextField();
              jLabel2 = new javax.swing.JLabel();
              intIn = new javax.swing.JTextField();
              jLabel3 = new javax.swing.JLabel();
              numIn = new javax.swing.JTextField();
              jLabel4 = new javax.swing.JLabel();
              dateIn = new javax.swing.JTextField();
              jLabel5 = new javax.swing.JLabel();
              dateTimeIn = new javax.swing.JTextField();
              jLabel6 = new javax.swing.JLabel();
              jCheckBox1 = new javax.swing.JCheckBox();
              keepValues = new javax.swing.JCheckBox();
              jButton1 = new javax.swing.JButton();
              setLayout(new java.awt.GridBagLayout());
              jLabel1.setText("Text");
              add(jLabel1, new java.awt.GridBagConstraints());
              textIn.setName("ttext");
              textIn.setPreferredSize(new java.awt.Dimension(100, 21));
              textIn.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent evt) {
                        textInActionPerformed(evt);
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridwidth = 2;
              add(textIn, gridBagConstraints);
              jLabel2.setText("Integer");
              add(jLabel2, new java.awt.GridBagConstraints());
              intIn.setName("tint");
              intIn.setPreferredSize(new java.awt.Dimension(50, 21));
              add(intIn, new java.awt.GridBagConstraints());
              jLabel3.setText("Number");
              add(jLabel3, new java.awt.GridBagConstraints());
              numIn.setName("tnum");
              numIn.setPreferredSize(new java.awt.Dimension(50, 21));
              add(numIn, new java.awt.GridBagConstraints());
              jLabel4.setText("Date");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 0;
              gridBagConstraints.gridy = 1;
              add(jLabel4, gridBagConstraints);
              dateIn.setName("tdate");
              dateIn.setPreferredSize(new java.awt.Dimension(50, 21));
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 1;
              gridBagConstraints.gridy = 1;
              add(dateIn, gridBagConstraints);
              jLabel5.setText("DateTime");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 2;
              gridBagConstraints.gridy = 1;
              add(jLabel5, gridBagConstraints);
              dateTimeIn.setName("tidate");
              dateTimeIn.setPreferredSize(new java.awt.Dimension(80, 21));
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridy = 1;
              add(dateTimeIn, gridBagConstraints);
              jLabel6.setText("Bit");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridy = 1;
              add(jLabel6, gridBagConstraints);
              jCheckBox1.setName("tbit");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridy = 1;
              add(jCheckBox1, gridBagConstraints);
              keepValues.setText("keep values");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 7;
              gridBagConstraints.gridy = 3;
              add(keepValues, gridBagConstraints);
              jButton1.setText("Send");
              jButton1.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jButton1ActionPerformed(evt);
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 7;
              gridBagConstraints.gridy = 2;
              add(jButton1, gridBagConstraints);
         }//GEN-END:initComponents
         private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
              sendRow();
         }//GEN-LAST:event_jButton1ActionPerformed
         private boolean sendRow() {
              java.util.HashMap hm = new java.util.HashMap();
              Component[] cs = this.getComponents();
              for (int i = 0; i < cs.length; i++) {
                   if (((Component) cs).getName() != null) {
                        if (cs[i] instanceof JCheckBox) {
                             String value = ((JCheckBox) cs[i]).isSelected() ? "1" : "0";
                             hm.put(cs[i].getName(), value);
                        } else if (cs[i] instanceof JCheckBox) {
                             hm.put(cs[i].getName(), ((JTextField) cs[i]).getText());
              } // end for
              firePropertyChange("rowChanged", null, hm);
              return true;
         private void getRow(java.util.HashMap hm) {
              //if (! this.keepValues.isSelected()) {
              Component[] cs = this.getComponents();
              for (int i = 0; i < cs.length; i++) {
                   if (cs[i].getName() != null && hm.containsKey(cs[i].getName())) {
                        Component component = cs[i];
                        String componentName = cs[i].getName();
                        String componentValue = (String) hm.get(component.getName());
                        if (cs[i] instanceof JTextField) {
                             // output for debugging
                             System.out.println("Setting " + cs[i].getName() + " = "
                                       + componentValue);
                             ((JTextField) component).setText(componentValue);
                        } else if (cs[i] instanceof JCheckBox) {
                             // output for debugging
                             System.out.println("JCheckBox found");
                             JCheckBox cb = (JCheckBox) component;
                             boolean selected = (componentValue == null ? false : (componentValue.equals("1")
                                       ? true
                                       : false));
                             ((JCheckBox) component).setSelected(selected);
              } // end for
              /* Uncomment this code snippet to retrieve the text that has been set
              for the components (that means JTextFields)
              This is just for debugging !
              Component[] cs = this.getComponents(); for (int i = 0; i < cs.length;
              i++) { if (cs[i].getName() != null) { if (cs[i] instanceof
              JTextField) { System.out.println("Value of " +cs[i].getName() + " = " +
              ((JTextField) cs[i]).getText()); } } } // end for
         private void textInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textInActionPerformed
         }//GEN-LAST:event_textInActionPerformed
         public void keyPressed(java.awt.event.KeyEvent e) {
              if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
                   sendRow();
         public void keyReleased(java.awt.event.KeyEvent e) {
         public void keyTyped(java.awt.event.KeyEvent e) {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
              if (evt.getPropertyName().equals("newRow")) {
                   final PropertyChangeEvent finalEvt = evt;
                   Runnable makeChanges = new Runnable () {
                        public void run() {
                             getRow((java.util.HashMap) finalEvt.getNewValue());
         // Variables declaration - do not modify//GEN-BEGIN:variables
         private javax.swing.JTextField dateIn;
         private javax.swing.JTextField dateTimeIn;
         private javax.swing.JTextField intIn;
         private javax.swing.JButton jButton1;
         private javax.swing.JCheckBox jCheckBox1;
         private javax.swing.JLabel jLabel1;
         private javax.swing.JLabel jLabel2;
         private javax.swing.JLabel jLabel3;
         private javax.swing.JLabel jLabel4;
         private javax.swing.JLabel jLabel5;
         private javax.swing.JLabel jLabel6;
         private javax.swing.JCheckBox keepValues;
         private javax.swing.JTextField numIn;
         private javax.swing.JTextField textIn;
         // End of variables declaration//GEN-END:variables

    The problem of the change in the form not being comitted is that
    I forgot SwingUtilities.invokeLater(makeChanges); in the bottom
    part in public void propertyChange(java.beans.PropertyChangeEvent evt)
    after having created a new Runnable.
    Changes to the UI often have to be comitted by SwingUtitlities.invokeLater()
    though I don't know that much about Swing yet.
    Thanks to everybody who tried to solve that problem.
    Benjamin

  • JtextField text too long problem

    I have a little problem, I'm sure its very very simple to fix. The text I put into my JTextField is longer than the visible portion, so when I put text in there it keeps scrolling it to the end, so the start portion of the text isnt visible anymore (it scrolls it to the end instead). Now obviously I would rather want the beginning portion of the text to show, but I havent found a way to do that nicely (there must be some simple setting/function for this). And I dont want to crop the text either...
    Thanks :)

    Use a JTextArea and call setCaretPosition(0) method on it.

  • Problem in displaying long string in JTextField

    Hi All,
    I got problem in displaying long String in JtextField. It does center alignment & I can see middle part of string where length of JTextfield is 6 char. How can I do left alignement so that I can see starting 6 character?
    --Harish                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    you may try this:
    yourTextFieldName.setHorizontalAlignment(JTextField.LEFT);
    or
    yourTextFieldName.setHorizontalAlignment(JTextField.LEADING);
    hth.

  • Java plug-in 1.4.1 proxy configuration issue causes JTextField TAB problems

    I have an applet that has multiple JTextFields in it. I recently updated my Java plug-in to version 1.4.1, and now using TAB to navigate among text fields does not always work when I first bring up a browser and load the applet.
    I've found, however, that if I open the Java Console and hit "p" (reload proxy configuration), and then reload my applet (hit Refresh/Reload on my browser), the Tab key works as expected. I did not have this issue with releases prior to 1.4.1.
    Any clue on how I can ensure proper proxy configuration upon initial instantiation of the browser? I've seen the problem in both IE 6.0 and Netscape 7.0.
    Note that the reloading of the proxy configuration only appears to be necessary once per browser session.

    The navigation isn't working. I click in the first text field to give the initial field focus. I then hit TAB and nothing happens. I have a key listener set up for the ENTER key, and this is also supposed to navigate to the next field via:
    ((JTextField)evt.getSource()).transferFocus();
    To see if there was a problem with my build environment or threads in my application, I came up with the following dummy applet:
    import java.awt.BorderLayout;
    import javax.swing.BoxLayout;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class TestApplet extends JApplet {
    public void init() {
    super.init();
    public void start() {
    JPanel myPanel = new JPanel();
    myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS));
    JTextField textField1 = new JTextField("Text Field 1");
    myPanel.add(textField1);
    JTextField textField2 = new JTextField("Text Field 2");
    myPanel.add(textField2);
    JTextField textField3 = new JTextField("Text Field 3");
    myPanel.add(textField3);
    getContentPane().add(BorderLayout.CENTER, myPanel);
    public void stop() {
    super.stop();
    I then compiled this applet using the following:
    javac TestApplet.java
    I then put together the following HTML file:
    <HTML>
    <HEAD>
    <TITLE>Test Applet</TITLE>
    </HEAD>
    <BODY MARGINWIDTH="0" MARGINHEIGHT="0" BGCOLOR="white">
    <APPLET
    CODE=TestApplet.class
    WIDTH=635
    HEIGHT=500
    ALIGN=left
    VSPACE=10
    HSPACE=10
    >
    </APPLET>
    </BODY>
    </HTML>
    The results are the same. I am not able to navigate using the TAB key until I bring up the Java console and then close it again. I would think that if this was a bug in 1.4.1_01, I would have seen it all over the forums. Any help would be greatly appreciated.

  • Jtextfield new line problem

    Hey guys :-)
    I seem to have a little problem with my jtextfield, it seems to be ignoring any "\n"'s i tell it to print. The code to setup my jtextfield is below and was created with jigloo for eclipse!
    fileInputjTextField1 = new JTextField();
    this.getContentPane().add(getFileInputjTextField1());
    fileInputjTextField1.setBounds(20, 20, 420, 200);
    fileInputjTextField1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));And i'm setting it with...
         public void setWindowText(){
              LoadHelp helpLoader = new LoadHelp(fileName);
              fileInputjTextField1.setText(helpLoader.readInHelp());
         }The readInHelp function returns a string which contains "\n's". using println it recognises the new lines, but the text field won't.
    Also, the text is appearing the the center of the box instead of the top line?
    Any help appreciated :-) Am a little new to gui coding

    This give the code below :
    JTextArea textarea = new JTextArea();
    textarea.setBounds(20, 20, 420, 200); // Set the dimensions
    textarea.setText("line1\nline2");

  • JTextField data reading problem

    Hello,
    I am attempting to construct a gui in which I parse data from a file into 3 different arrays, one is pure numbers the other two are strings of variables describing the data for a specific index of the data in the first array.
    I pass the raw data (all the numbers) to a plotting function, which plots 3 graphs at a time and is placed in a JLayeredPane. Over the plot I have a bar (place marker) with an associated mouselistener which calculates which index of the raw data array the bar is over as the bar is dragged over the plot.
    Beside the plots are two Jpanels that contain the data of the other two arrays. I only want to show the variable name and the data associated with index that is calculated from the bar/mouselistener described above.
    I designed this using JTextFields. I did not want to use JTable, because I only want to show the one column of data at a time.
    My problem is when I try to create an array of JTextFields, only a small portion of the data is passed. I want to use to 80 variables, but will only accept 12.
    for(int m=0;m<dvnum+1;m++){
         System.out.println("diagvar["+m+"][0]= "+diagvar[m][0]);
    for(int m=1;m<dvnum+1;m++){
         diaglabelField[m-1] = new JTextField(diagvar[m][0]);
         System.out.println("diaglabelfield= "+diagvar[m][0]);
         diagconfidenceField[m-1] = new JTextField(diagvar[m][1]);
         diagfieldPane.add(diaglabelField[m-1]);
         diagfieldPane.add(diagconfidenceField[m-1]);
    }where dvnum is the number of variables. The output from above gives a list of all the variable names, then a list of only those that were accepted into the JTextFields.
    Is there a limit as to how many JTextFields I can use? Or an easier way of doing this? If I use a smaller data set (under 15) it works, over that it only accepts 12 or so.
    I was thinking JTable could be used, but I would have to pass and build a JTable every time I wanted to look at a different data set for the new index.

    That's a long post, but I couldn't figure out from it just what your problem is. I'm guessing that your panel with the JTextFields only has room for 12 of them, and it doesn't scroll to show the others (from 13 to 80).
    If I'm right, I would suggest you don't use a bunch of JTextFields to show this data. And since there's only one column of data, you don't really need a JTable either. A JList would work just fine, assuming you don't need to update the data. Put it in a JScrollPane and you'll be able to use as many entries as you like.

  • I want to search in JList through JTextField [Encountering Problems :( ]

    I want to search in the JList through JTextField
    As i will type in the JTextField the Text will be compared with the itmes present in the JList and after finding that text in the JList, it will come on the top of the JList..........
    So make it clear that there are only two components JTextField and JList
    and my problem is related with only these items..
    Thanks......

    Why are you asking this question again?
    You asked and received the same answer in this [url http://forum.java.sun.com/thread.jsp?thread=533699&forum=57]thread.
    One way to make sure you don't get answers is to ask the same question over and over and to ignore your original post.

  • JTextField focus problems in JApplet

    I have a JApplet like this:
    public class AppletLogin extends JApplet {
    public void init() {
    this.setSize(new Dimension(400,300));
    this.getContentPane().setLayout(new FlowLayout());
    this.getContentPane().add(new JTextField(12));
    this.getContentPane().add(new JTextField(12));
    The first problem I have is that both JTextField don't show the cursor if you click in them, they also don't show selected text. If you select another window and then you select back the browser, the cursor appears.
    The second problem is that sometimes, if the cursor appears in the first JTextField and with the TAB or with the mouse you set the focus on the second JTextField, then you can't focus back to the first JTextField. This second problem disappears if you add "this.requestFocus()" in init.
    This behaviour is shown in Windows NT 4.0 and 98 with Netscape 4.7 and 6.2.
    I don't have this problem in Windows 2000 - Netscape 4.7 / 6.2 and Linux - Netscape 6.2.
    The Plugin is 1.3.1_01a and 1.3.1_02.
    I think I have the same problem explained in bug 4186928 but with a JApplet. I have tried the "dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_ACTIVATED))" workaround, using the 'SwingUtilities.getWindowAncestor(this)' Window, but it doesn't
    work.
    Any suggestions to solve the first problem? Should I submit a bug?

    Of course. Here is the original code. I have only removed 'imports' from other classes of the project used for localization and image loading.
    If you want me to translate for you the Spanish comments to English, please tell me.
    This is the code as is now. I have already tried 'requestFocus' and 'grabFocus' even inside a MouseListener attached to 'usuario' (user) and 'clave' (passwd), with no success.
    This code works fine with 1.2.2 plug-in on any OS and with 1.3.1_02 plug-in on Windows 2000 and Linux.
    But with 1.3.1_02 plug-in under Windows 98/NT4.0 and Netscape 4.7/6.2 the focus is crazy. Our customer uses Windows NT 4.0.
    This panel is for user and passwd validation. We use it attached to an JApplet. It has some methods to attach ActionListener to it. It also has a KeyListener to capture 'intro' events. Thats all.
    package project.pkg
    import java.util.TooManyListenersException;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    import javax.swing.border.EmptyBorder;
    // import of other.project.pkg
    // import of other.project.pkg
    import javax.swing.*;
    import java.awt.*;
      * Panel de acceso a la aplicaci�n.
      * @version  $Revision: 1.8 $
    public class PanelAcceso extends JRootPane {
       // Marca de revision. ///////////////////////////////
       private final static String VERSION = "@(#) $Id: PanelAcceso.java,v 1.8 2001/05/08 15:55:46 user Exp $";
       /** Campo usuario */
       private JTextField usuario;
       /** Campo clave */
       private JTextField clave;
       /** Panel de los controles */
       private JPanel controles;
       /** Panel auxiliar marco para controles. */
       private JPanel marco;
       /** ActionListener para notificaci�n de intro. de usuario y passwd */
       private ActionListener entrarActionListener = null;
        * Construye un panel de acceso.
       public PanelAcceso() {
         JLabel portada = new JLabel(/*HERE goes an ImageIcon*/);
         portada.setHorizontalAlignment( SwingUtilities.CENTER);
         portada.setVerticalAlignment( SwingUtilities.CENTER);
         getContentPane().setLayout( new BorderLayout());
         getContentPane().add( portada, BorderLayout.CENTER);
         getContentPane().setBackground( Color.white);
         controles = new JPanel();
         controles.setLayout(new GridLayout(4,2,5,5));
         controles.setOpaque(false);
         controles.add( new JLabel("Ver. 2.5.1"));
         controles.add(Box.createHorizontalGlue());
         controles.add(Box.createHorizontalGlue());
         controles.add(Box.createHorizontalGlue());
         controles.add( new JLabel("User") );
         usuario = new JTextField( 12);
         usuario.addKeyListener(keyListener);
         controles.add( usuario);
         controles.add( new JLabel("Passwd") );
         clave = new JPasswordField( 12);
         clave.addKeyListener(keyListener);
         controles.add( clave);
         // Panel auxiliar marco para controles.
         marco = new JPanel(new FlowLayout(FlowLayout.RIGHT));
         marco.setOpaque(false);
         marco.add(controles);
         setGlassPane(marco);
         // Listener para fijar el borde de marco seg�n cambie de
         // tama�o el panel.
         marco.addComponentListener( new ComponentAdapter() {
           public void componentResized(ComponentEvent e) {
             changeEmptyBorder();
           public void componentShown(ComponentEvent e) {
             changeEmptyBorder();
         marco.setVisible(true);
        * Devuelve el usuario introducido.
       public String getUser() {
         return usuario.getText();
        * Devuelve la contrase�a introducida.
       public String getPasswd() {
         return clave.getText();
        * Limpia el panel de acceso.
       public void limpiar() {
         clave.setText("");
         usuario.setText("");
        * A�ade un listiener a los eventos de
        * petici�n de acceso dado un usuario y
        * una contrase�a.
        * @throws TooManyListenersException si ya se ha a�adido un listener.
       public void addEntrarListener(ActionListener l) throws TooManyListenersException {
         if ((entrarActionListener != null) && (entrarActionListener != l))
           throw new TooManyListenersException("Solo se admite un listener");
         else
           entrarActionListener = l;
        * Borra un listener.
       public void removeEntrarListener(ActionListener l) {
         if (entrarActionListener == l)
           entrarActionListener = null;
         else
           throw new IllegalArgumentException("Intento de borrar un listener no a�adido");
        * Borra todos los listeners.
       public void removeEntrarListeners() {
         entrarActionListener = null;
        * Instancia privada de KeyListener para capturar
        * los 'enter' en los campos de usuario y passwd.
       private KeyListener keyListener = new KeyListener() {
          * Method to handle events for the KeyListener interface.
          * @param e KeyEvent
         public void keyPressed(KeyEvent e) {
           if (e.getKeyCode() != KeyEvent.VK_ENTER)
             return;
           if ((e.getSource() == usuario) )
             clave.requestFocus();
           else {
             requestFocus(); // Se evitan varias pulsaciones seguidas.
             if (entrarActionListener != null)
               entrarActionListener.actionPerformed(new ActionEvent(this, 0, ConstantesXigus.ACCION_ENTRAR));
         /** Method to handle events for the KeyListener interface. */
         public void keyReleased(KeyEvent e) {}
         /** Method to handle events for the KeyListener interface. */
         public void keyTyped(KeyEvent e) {}
        * Ajusta el borde del marco de controles para que aparezcan centrados.
       private void changeEmptyBorder() {
         Dimension dimMarco   = marco.getSize();
         Dimension dimInterno = controles.getPreferredSize();
         int altoBorde  = dimMarco.height - dimInterno.height;
         int anchoBorde = (dimMarco.width - dimInterno.width)/2;
         marco.setBorder( new EmptyBorder( (int)(altoBorde * 0.75), anchoBorde, (int)(altoBorde * 0.25), anchoBorde));
    }Thank you very much for your help

Maybe you are looking for