Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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?

    private void convertUpperActionPerformed(java.awt.event.ActionEvent evt) {
            convertUpper.s
        }


  2. #2
    Member
    Join Date
    Jan 2013
    Posts
    39
    My Mood
    Relaxed
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default 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).
    String text;
     
    while(){
          text = textfield.getText();
          text.toUpperCase();
          textfield.setText(text);
    }

  3. #3
    Administrator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,848
    Thanks
    64
    Thanked 2,645 Times in 2,615 Posts

    Default 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.

  4. #4
    Member
    Join Date
    Jan 2013
    Posts
    39
    My Mood
    Relaxed
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default 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.

  5. #5
    Administrator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,848
    Thanks
    64
    Thanked 2,645 Times in 2,615 Posts

    Default 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?

  6. #6
    Member
    Join Date
    Jan 2013
    Posts
    39
    My Mood
    Relaxed
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default 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

  7. #7
    Administrator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,848
    Thanks
    64
    Thanked 2,645 Times in 2,615 Posts

    Default 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.

  8. #8
    Junior Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why You Should Blog for Business

    An fascinating discussion is worth comment. I think that you should certainly write alot more on this subject, it may well not be a taboo topic but typically men and women are not sufficient to speak on such topics. To the next. Cheers


    Custom NFL Jerseys
    Cheap NFL Jerseys

Similar Threads

  1. Problem with Action Event
    By jayzee98 in forum What's Wrong With My Code?
    Replies: 16
    Last Post: August 29th, 2012, 10:04
  2. [SOLVED] Is there a way to make things happen if a certain text is entered in a TextField?
    By DusteroftheCentury in forum Java Theory & Questions
    Replies: 25
    Last Post: January 26th, 2012, 19:14
  3. [SOLVED] difference between action event from 2 buttons with same name?
    By nggdowt in forum AWT / Java Swing
    Replies: 5
    Last Post: November 7th, 2011, 09:51
  4. How to display the results + repeat to the number entered by user?
    By TheBattousaixx in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 17th, 2011, 23:56
  5. jbutton and action event
    By mt888 in forum AWT / Java Swing
    Replies: 3
    Last Post: March 26th, 2010, 06:24