This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Center and right justification in JTextAreas was requested in Bug 4201966. The evaluation states, "You can do it via Document in case document is instanceof StyledDocument."
I'm not familiar with these interfaces (Document and StyledDocument), but that's where I would start looking.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Davy Kelly
Ranch Hand
Joined: Jan 12, 2004
Posts: 384
posted
0
thanks marc,
I am not familiar with these either...oh well I think this will need to wait a while
davy
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
do you want the typed text to appear from the right?
if so, this may do what you want textArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
for the cursor to initially appear on the right (when program opens), add these 2 lines prior to setting the frame's visibility to true
davy [ March 07, 2007: Message edited by: Davy Kelly ]
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
I don't follow...
will have both lines/words at the right.
can you post an example of the problem?
Davy Kelly
Ranch Hand
Joined: Jan 12, 2004
Posts: 384
posted
0
here is the program, and I put text on the first JTextArea davy
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
I meant code example, like this
Davy Kelly
Ranch Hand
Joined: Jan 12, 2004
Posts: 384
posted
0
here is the Booking Sheet in its entirety, without the date picker ok, the code could be cleaner, remember this is my very first program, that I am building from scratch.
davy
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
works OK for me, java 1.5.0_05
Davy Kelly
Ranch Hand
Joined: Jan 12, 2004
Posts: 384
posted
0
I know it works,
problem is in JTextArea for say 9:00 am, the first line starts one space in, but line two of 9:00am does not...
davy
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
all through this it seemed you wanted your text right-justified. now it seems you just want the text indented a bit.
if so, add this line textArea.setMargin(new Insets(0,5,0,0));//5 from left, modify to suit
Davy Kelly
Ranch Hand
Joined: Jan 12, 2004
Posts: 384
posted
0
thanks,
well I am sorry if it seems as if I wanted right justification, but thats not really what I want.
I like the insets idea, but if you have a look at the image above in this thread, it has one text area, that text areas have 2 rows, those 2 rows do not get the same inset, it only deals with the first row.
I think I am either going to have to leave this as is, or try and figure out DOcument...
but thanks anyway
davy
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
setMargin() works for all rows.
perhaps the current problem is the 'space' you're adding to the first row (?)
Davy Kelly
Ranch Hand
Joined: Jan 12, 2004
Posts: 384
posted
0
I got rid of that " " but the set margin is not working....
it compiles fine, but just not working.
I have tried the API, changed the ints for setMargin
davy
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> I got rid of that " " but the set margin is not working....
what changes did you make to your previously posted code?
Davy Kelly
Ranch Hand
Joined: Jan 12, 2004
Posts: 384
posted
0
I commented out the setText() and added the line you gave me, and played with the values,
checked the API, said something about the borders insets.... not sure, need to check the border class now
davy
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
well, I learned something out of this - setMargin doesn't work when a border is set (not in 1.4.0_01, anyway)
there seems to be a workaround:
comment out the 3 lines where you set the border 1) at the beginning of the for() 2) in the if(x == 3) 3) in the if(x == 9)
then, at the bottom of the for(), where you add appointmentArray[x] to sheetBox
basically, puts the border around a panel, instead of the textArea
Davy Kelly
Ranch Hand
Joined: Jan 12, 2004
Posts: 384
posted
0
Thank you very much michael,
you have been extremely helpful. I am grateful.
it worked wonderfully.
davy
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.