khammond    01/10/03 06:47:38

  Modified:    src/org/apache/jmeter/protocol/jdbc/config/gui
                        PoolConfigGui.java
  Log:
  Bug fix #3639.
  
  Revision  Changes    Path
  1.8       +49 -4     
jakarta-jmeter/src/org/apache/jmeter/protocol/jdbc/config/gui/PoolConfigGui.java
  
  Index: PoolConfigGui.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/jdbc/config/gui/PoolConfigGui.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PoolConfigGui.java        2001/10/02 14:16:22     1.7
  +++ PoolConfigGui.java        2001/10/03 13:47:38     1.8
  @@ -197,13 +197,58 @@
        public void keyReleased(KeyEvent e)
        {
                String name = e.getComponent().getName();
  -             if(name.equals(CONNECTIONS))
  +
  +             if (name.equals(CONNECTIONS))
                {
  -                     model.setNumConnections(Integer.parseInt(connField.getText()));
  +                     try
  +                     {
  +                             
model.setNumConnections(Integer.parseInt(connField.getText()));
  +                     }
  +                     catch (NumberFormatException nfe)
  +                     {
  +                             if (connField.getText().length() > 0)
  +                             {
  +                                     JOptionPane.showMessageDialog(this, "You must 
enter a valid number",
  +                                                     "Invalid data", 
JOptionPane.WARNING_MESSAGE);
  +
  +                                     // Right now, the cleanest thing to do is 
simply clear the 
  +                                     // entire text field. We do not want to set 
the text to
  +                                     // the default because that would be confusing 
to the user.
  +                                     // For example, the user typed "5t" instead of 
"56". After
  +                                     // the user closes the error dialog, the text 
would change
  +                                     // from "5t" to "1".  A litle confusing. If 
anything, it
  +                                     // should display just "5". Future 
enhancement...
  +                                     connField.setText("");
  +                             }
  +
  +                             
model.setNumConnections(model.getDefaultNumConnections());
  +                     }
                }
  -             else if(name.equals(MAXUSE))
  +             else if (name.equals(MAXUSE))
                {
  -                     model.setMaxUse(Integer.parseInt(maxUseField.getText()));
  +                     try
  +                     {
  +                             
model.setMaxUse(Integer.parseInt(maxUseField.getText()));
  +                     }
  +                     catch (NumberFormatException nfe)
  +                     {
  +                             if (maxUseField.getText().length() > 0)
  +                             {
  +                                     JOptionPane.showMessageDialog(this, "You must 
enter a valid number",
  +                                                     "Invalid data", 
JOptionPane.WARNING_MESSAGE);
  +
  +                                     // Right now, the cleanest thing to do is 
simply clear the 
  +                                     // entire text field. We do not want to set 
the text to
  +                                     // the default because that would be confusing 
to the user.
  +                                     // For example, the user typed "5t" instead of 
"56". After
  +                                     // the user closes the error dialog, the text 
would change
  +                                     // from "5t" to "1".  A litle confusing. If 
anything, it
  +                                     // should display just "5". Future 
enhancement...
  +                                     maxUseField.setText("");
  +                             }
  +
  +                             model.setMaxUse(model.getDefaultMaxUse());
  +                     }
                }
        }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to