Results 1 to 10 of 10
  1. #1
    dharanikrm is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Post paste special symbols in JTextField

    Hi,

    I am unable to see the special symbols like greek character set when copied from character map of windows and pasted in the JTextField.

    eg: when I copy alpha, beta symbols from character map and paste in text field they are displayed as a,b respectively instead of displaying their actual symbols

    Regards,
    Kumar

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,431
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by dharanikrm View Post
    I am unable to see the special symbols like greek character set when copied from character map of windows and pasted in the JTextField.

    eg: when I copy alpha, beta symbols from character map and paste in text field they are displayed as a,b respectively instead of displaying their actual symbols
    Can the font of your JTextField display those special characters? Try. e.g. the Arial MS Unicode font.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    dharanikrm is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    Hi Jos,

    I tried setting the font of the JTextField to Arial MS Unicode font, but invain.

    Regards,
    Kumar

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,431
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by dharanikrm View Post
    I tried setting the font of the JTextField to Arial MS Unicode font, but invain.
    Does the copy/paste mechanism itself work? i.e. try to paste the text to something else that is capable of displaying the Greek characters and see what happens.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Aeroren is offline Member
    Join Date
    Jan 2011
    Posts
    9
    Rep Power
    0

    Default

    Maybe a stupid question, but are you actually copying 'alpha' and 'beta' characters (U+03B1 and U+03B2), or are you copying the 'a' and 'b' characters from the Symbol font?

    (Hope this works)
    Try: α β

  6. #6
    dharanikrm is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    Hi Aeroren,

    As I have mentioned in my first post, I am getting the problem when I am trying to copy the greek symbols from character map of windows (start->programs->accessories->system tools->character map) and paste in the text field in the swing application.In the other cases I guess it will work.

  7. #7
    Aeroren is offline Member
    Join Date
    Jan 2011
    Posts
    9
    Rep Power
    0

    Default

    Yes, but are you copying the 'a' and 'b' from the Symbol font, or actually copying alpha and beta, which are a lot further down? The 'a' and 'b' from the Symbol font aren't actually an alpha and beta, Symbol simple draws the 'a' and 'b' that way. If you paste them in another window that uses a different font, they won't look like alpha an beta anymore.

    But if you only wish to use Greek characters you can change the font of your textfield to Symbol.

  8. #8
    dharanikrm is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    Hi Aeroren,

    Thnx for your quick reply...I am copying the actual α ,β symbols that you can find in the character map of windows when you select symbols in the drop down list. I could see the actual symbols when I try to paste the same in text document but I am getting a,b when I say ctrl+v to paste the same in the text field

  9. #9
    Aeroren is offline Member
    Join Date
    Jan 2011
    Posts
    9
    Rep Power
    0

    Default

    Now I'm kinda confused... :) Did you copy the alpha and beta characters in your post from mine or from the charmap?

    Anyway, to be sure I created a simple JFrame with a JTextField in it and it accepts the alpha character as it should, without setting any parameters (i just used this.add(new JTextField()); ) The AWT version also works by the way.

    Now, there might be different versions of the CharMap, but the one I'm using (Windows Vista) only has a dropdown list for font. If that's what you're using to change it to "Symbol" than that means you're not actually copying an alpha character but Symbol's representation of an 'a' (which happens to look like an alpha). If you paste this in a program like word, it will copy the font along and it will still look like an alpha. If, however, you copy the text to a field with another font (like notepad, this forum or your JTextField) it will look like an 'a'. In order to get the actual alpha character (UTF16 0x03B1) you need to select a font like Arial and scroll down about a third of the way. There you'll find the actual alpha and beta characters

  10. #10
    dharanikrm is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    Thnx Aeroren, I think you are right and the explanation was pretty much clear. When I tried to copy the real alpha and beta characters by selecting the font Arial I could see them in my text field.

Similar Threads

  1. Checking If A String Contains Symbols
    By SwissR in forum New To Java
    Replies: 7
    Last Post: 07-27-2010, 09:07 AM
  2. Representing ERD with symbols
    By vivvy in forum JDBC
    Replies: 1
    Last Post: 02-17-2010, 05:17 PM
  3. Replies: 0
    Last Post: 07-13-2009, 05:22 PM
  4. Plotting Symbols in Java 2D
    By cowboy007 in forum Java 2D
    Replies: 1
    Last Post: 03-08-2009, 01:13 PM
  5. How to cut symbols from a string?
    By gutters in forum New To Java
    Replies: 3
    Last Post: 06-16-2008, 03:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •