Note that there are some explanatory texts on larger screens.

plurals
  1. POint field validation in swing for user registration form
    primarykey
    data
    text
    <p>Swing work I am having difficulties doing a simple validation of a text field that has as a value - an int variable. I need the following:</p> <ul> <li>permit only digits</li> <li>don't allow a value of 0 or bellow</li> <li>It has to be mandatory to fill .</li> </ul> <pre><code>private void btnsaveActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: User controller=new User( new Integer(textuid.getText().trim()),textname.getText(), textpassword.getText(),textrepassword.getText()); controller.saveUser(db.getCon()); // int a= new Integer(textuid.getText().trim()); System.out.print(controller.getUid()); if(Integer.parseInt(textuid.getText()) &lt;=0){ JOptionPane.showMessageDialog( textuid, "Must enter a value greater than zero"); } if(textuid.getText().equals("s")){ JOptionPane.showMessageDialog( textuid, "Must enter a value greater than zero"); } // if(textname.getText().equals("")) // { // JOptionPane.showMessageDialog( textname, "Name not empty"); // } // if(textpassword.getText().equals("")){ // JOptionPane.showMessageDialog( textname, "Password not empty"); // } // if(textrepassword.getText().equals("")){ // JOptionPane.showMessageDialog( textname, "Password not empty"); // } } </code></pre> <p>show error message</p> <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:470) at java.lang.Integer.&lt;init&gt;(Integer.java:660) at com.smart.ui.UserForm.btnsaveActionPerformed(UserForm.java:149) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6267) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6032) at java.awt.Container.processEvent(Container.java:2041) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168) at java.awt.Container.dispatchEventImpl(Container.java:2085) at java.awt.Window.dispatchEventImpl(Window.java:2478) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) </code></pre> <p>I can't solve this. please help. it's my first post</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload