Jump to content
  • Advertisement
Sign in to follow this  
hisDudeness

easy Java fixes

This topic is 4485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey I'm writing a Java applet and am trying to override some of the default behavior of the JButton controls. I want a JButton to be capable of displaying a Unicode character (say some Japanese character -- it doesn't really matter) on its label, and when selected, to draw that character to a JTextField. So we have the simple code: JButton b1 = new JButton(/* some unicode character */); JTextField t1 = new JTextField(1); (1) How do I specify "some unicode character" in the JButton's initialization? (2) What code would I use in the handler to update the text field with this same character?

Share this post


Link to post
Share on other sites
Advertisement
If it expects a character value, you can use '\uXXXX', where the XXXX are four hex digits specifying the character; or similarly 0xXXXX. For a string, use double quotes instead of single quotes.

In the handler, you would have to ask the button for its label, and sent it to the text field. The best way to find out the necessary "magic words" is to read the API documentation (you can find it easily on java.sun.com).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!