Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Double text alignment

 
John Fiupove
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am new here. I am developing free POS...
Is it possible to double align text, eg. 1 item on the left and price on the right?
I already figure it out I can use <html> tags to get double lines in jlist element.

[IMG=http://img600.imageshack.us/img600/8288/unled1cd.gif][/img]

Uploaded with ImageShack.us

Sorry for my bad english....
Johhny.
 
Andraz Poje
Ranch Hand
Posts: 32
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you should use monospaced font, count max. size of letters and than substact or stg...
I don`t have better answer, sorry...
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't followed that link. But if your question is about how to get the data in a JList to align itself into columns, well, that's what a JTable is for.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
John Fiupove
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! Jtable is great! Only problem is visual one. How can I make row selection without that border in the middle?

 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this discussion would sit better on our GUIs forum. Moving.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use either a JList or a JTable with a custom renderer. Read about renderers here.

For a list, the renderer could be a JPanel with two JLabels with appropriate horizontal alignment. Or you could use a BoxLayout and add a horizontal glue between the two labels.

For a table, you could extend DefaultTableCellRenderer and invoke the super implementation of getTableCellRendererComponent with the hasFocus parameter false.
 
John Fiupove
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JTable as recommended. Superimplementation removes focus (blue line), but joint edges between two horizontal cells in the middle is still there...
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the API for methods that set whether the gridlines are painted shown.
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only problem is that that method also removes the horizontal lines, not just the vertical lines.

Edit: scratch that. I was only aware of the method to show all or nothing. Apparently there are also methods to show only vertical or only horizontal.
 
John Fiupove
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


or



It removes them but if 1 cell is selected, entire row gets selected. And vertical lines between cells are still visible
 
John Fiupove
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic