Forums Register Login

JOptionPane and FocusListener

+Pie Number of slices to send: Send
I want to show a warning so that one JTextField should not be left blank. I used the focusLost method of focuslistener. In this method i used JOptionPane.showMessageDialog(this, "do not leave blank", "Blank", JOptionPane.INFORMATION_MESSAGE). I got this message box as I leave that text field (when it is blank). However, I do not know how to get rid of this message. Kindly advice. Also note that focusLost() method is void and cannot return any integers.
+Pie Number of slices to send: Send
well, it works for me. I'm using as follows :
if(textName.equals("myTF")){
int numDays2 = (new Integer(myTF.getText())).intValue();
if (numDays2 <= 0){
JOptionPane.showMessageDialog(this, "Minimum # of scheduled hours/day cannot be less or equal to 0.", "Error Message ", JOptionPane.OK_OPTION);
return;
}
}
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 767 times.
Similar Threads
Editable drop down combo box
Controlling Button Focus with Arrow Keys
need JTextField that change color when focused
Change Focus When Enter Is Pressed
Losing focus callback - JTextField ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:19:59.