• Post Reply Bookmark Topic Watch Topic
  • New Topic

Aligning text in JTextArea  RSS feed

 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code:

This is a class that provides a panel on the screen the area of concern is JTextArea st. Each row will initially have a string. Then as required an int could be added to each row followed by a float. The reason for the int & float being added is when the user makes a selection.
What I would like is the string followed by some padding then int followed by some padding then the float. If I pad them manually, like I have started doing in the code. The int are all out out line with each other. So when you look down the column of ints they are like a dogs back leg.
Is there any way of aligning btext this way? I played with insert() method but apparently this is not what insertb was meant for.
Please help, thanks, Dave.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't a JTable be more appropriate for this type of thing?
 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTable sounds like a good idea Ken. Only problem I can see with JTable is that the fields can be edited & it doesn't inherit setEditable(). Maybe there is an equivalent in JTable, I'll keep reading the API.
 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it, isCellEditable(int row, int col). Seems to stop any altering. Right I'm off to bed, so I can be up nice & early & drive myself mad with GUI's. Thanks again, Dave.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved your own problem.
 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could have used monospace font aswell (damn I'm slow!).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!