• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextArea Component Orientation  RSS feed

 
bubulont lee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I'm actually learning Java programming and to do so I'm trying to make a simple program.
So as the subject says I'm having problem with my JTextArea.
I setted my JTextArea to RIGHT_TO_LEFT with:
jTextVariable.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

And it works great but not on the leading signs!
If I try to do:
jTextVariable.setText("-1234");

It will output: 1234-

Am I doing something wrong? Is there a way to reset the leading sign to the beginning?

Bu-
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You are right. This IS strange.
However, if you type something before the number it displays properly. Maybe a bug? Sorry, cannot offer anymore assistance beyond this.
1.png
[Thumbnail for 1.png]
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

What does the set orientation method actually do? Is it applicable to numbers? If you enter text in a European language which is written left to right, will that make the text appear right to left.
 
bubulont lee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies!

I have found a work around for numbers:

if (value < 0) {
value = -value;
result.setText(Double.toString(value)+ "-");
}

So with that we correctly get -value and not value-

Bu-
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use a JTextPane or a JEditorPane, alignment of text within the component is supported.

This question has been asked before: http://www.coderanch.com/t/339752/GUI/java/Textarea-Text-Alignment
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!