Home > Back-end >  JTextField reading problems in GUI
JTextField reading problems in GUI

Time:09-16

Want to read the number in the text box, date, should use what method? I've tried using getText () can only read the string, use int x=Integer. The parseInt (textfield1. The getText ()) no, urgent, please passing will be friend help me disambiguation answer, very grateful,

CodePudding user response:

String is is time

So, string transfer time

CodePudding user response:

Integer. Parselnt () method will be the only digital string class into Integer, if you have any character in the string, it is recommended to use string method split or intercept the substring method for digital string, then read,

CodePudding user response:

The
reference Z left the building Lord reply:
want to read the number in the text box, date, should use what method? I've tried using getText () can only read the string, use int x=Integer. The parseInt (textfield1. The getText ()) no, urgent, please passing will be friend help me disambiguation answer, very grateful,


Ask what cannot turn, but you just put textfield1. The getText () content printed look not to know,

CodePudding user response:

Behind and the getText () best to add the trim (), remove the whitespace, after all, when input would be wrong

CodePudding user response:

reference qq_39936465 reply: 3/f
Quote: refer to the original poster Z left reply:

Want to read the number in the text box, date, should use what method? I've tried using getText () can only read the string, use int x=Integer. The parseInt (textfield1. The getText ()) no, urgent, please passing will be friend help me disambiguation answer, very grateful,


Ask what cannot turn, but you just put textfield1. The getText () content printed look not to know,

Thank you, find the reason, the first thing to figure out whether Textfeild is empty, not empty words can transform, but there won't be able to convert the date type

CodePudding user response:

Z left reference 5 floor response:
Quote: refer to the third floor qq_39936465 response:
Quote: refer to the original poster Z left reply:

Want to read the number in the text box, date, should use what method? I've tried using getText () can only read the string, use int x=Integer. The parseInt (textfield1. The getText ()) no, urgent, please passing will be friend help me disambiguation answer, very grateful,


Ask what cannot turn, but you just put textfield1. The getText () content printed look not to know,

Thank you, find the reason, the first thing to figure out whether Textfeild is empty, not empty words can transform, but there won't be able to convert the date type


Turn date without reason you cannot convert a string

CodePudding user response:

 
The Date Date=new SimpleDateFormat (" yyyy - MM - dd "). The parse (textfield1. The getText (). The trim ());
The String now=new SimpleDateFormat (" on dd MM yyyy years "). The format (date);

System. The out. Println (now);

  • Related