Davy Kelly
,
Ranch Hand
Mar 06, 2007 10:53:00
Hey everyone, I would like to have some JTextAreas have the cursor sit out to the right of the edge of that area, for all rows of the JTextArea. is this possible? if so what should I be looking for in the API? davy
marc weber
,
Sheriff
staff
Mar 06, 2007 14:03:00
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.
Davy Kelly
,
Ranch Hand
Mar 06, 2007 15:34:00
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
Mar 06, 2007 15:52:00
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 (this is needed in java 1.4.0_01)
Davy Kelly
,
Ranch Hand
Mar 07, 2007 10:52:00
ok, My JTextAreas have 2 lines, How can I make both lines start like that? davy [ March 07, 2007: Message edited by: Davy Kelly ]
Michael Dunn
,
Ranch Hand
Mar 07, 2007 14:03:00
I don't follow... will have both lines/words at the right. can you post an example of the problem?
Davy Kelly
,
Ranch Hand
Mar 07, 2007 15:48:00
here is the program, and I put text on the first JTextArea davy
Michael Dunn
,
Ranch Hand
Mar 07, 2007 17:31:00
I meant code example, like this
Davy Kelly
,
Ranch Hand
Mar 08, 2007 01:31:00
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
Mar 08, 2007 02:48:00
works OK for me, java 1.5.0_05
Davy Kelly
,
Ranch Hand
Mar 08, 2007 09:02:00
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
Mar 08, 2007 11:07:00
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
Mar 08, 2007 11:27:00
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
Mar 08, 2007 11:50:00
setMargin() works for all rows. perhaps the current problem is the 'space' you're adding to the first row (?)
Davy Kelly
,
Ranch Hand
Mar 08, 2007 12:28:00
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
Mar 08, 2007 13:29:00
> 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
Mar 08, 2007 15:09:00
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
Mar 08, 2007 16:55:00
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
Mar 09, 2007 06:13:00
Thank you very much michael, you have been extremely helpful. I am grateful. it worked wonderfully. davy
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com