Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Is It Possible To Set Input Numbers for JTextFiled?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
greetings all
i have a JTextField For Inputting numbers only
when trying to input digits,the windos settings is to write in english
so Numbers Are Typed 0123456789
but i want when the user tries to input numbers it's automatically typed in arabic numbers,any ideas how to do that?
 
Marshal
Posts: 74695
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like something I ought to move to the Swing forum . . .

Several ways to do it; you can set up a regular expression to test the text; you might get "\\d*" to work.
You can parse the text into an int then print it back in Arabic script. You could even have a KeyListener or something which listens for keystrokes. But you will probably get better answers on the Swing forum.
 
mahmoud saleh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are there any samples like this?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a DocumentFilter might be an option, but how are you handling pasting of text?
 
mahmoud saleh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
really didnot think of that
i didnot do such a behaviour before
 
Author
Posts: 974
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mahmoud saleh:
i have a JTextField For Inputting numbers only
when trying to input digits,the windos settings is to write in english
so Numbers Are Typed 0123456789
but i want when the user tries to input numbers it's automatically typed in arabic numbers,any ideas how to do that?



First of all, we should be careful with terminology because in
many parts of the world 0123456789 are called "Arabic numerals".
(as opposed to Roman numerals: I, II, III, IV, V, VI, VII, VIII, IX)

But I take it you want to see ٠١٢٣٤٣٥٦٧٨٩ from unicode block 0600?
(For lack of a better name, I'll call these "Arabic Arabic" numerals.)

If so, I'm not sure this best way, but it should work:There shouldn't be any left-to-right vs. right-to-left orientation issues.
[ October 10, 2008: Message edited by: Brian Cole ]
reply
    Bookmark Topic Watch Topic
  • New Topic