Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase
I'm trying to figure how to write an ActionEvent for a Radio Button to convert text entered in a text field to uppercase. I'm lost on where to begin. Do I need to get or set something?
Code :
private void convertUpperActionPerformed(java.awt.event.ActionEvent evt) {
convertUpper.s
}
Re: Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase
you have to make a JFrame first with a text field
If you want the text automaticly changed to uppercase.
you should put this code in a loop(could be in the main).
Code :
String text;
while(){
text = textfield.getText();
text.toUpperCase();
textfield.setText(text);
}
Re: Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase
@The_pizzaguy what does that code do when compiled and executed?
It doesn't compile and could be a useless, endless loop if it did.
Re: Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase
It is just an example, and the while loop used in my last comment could be the main update loop.
If that loop is running it will auto update the code to uppercase.
Re: Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase
Endless loops like that are usually a big waste of resources.
Why post junky code?
Re: Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase
I wouldnt know how to do it else, could you give me an example then? XD
Re: Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase
There are listeners and documents that can be used to control data in a text field.
Don't post junky code.