aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Double text alignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Double text alignment" Watch "Double text alignment" New topic
Author

Double text alignment

John Fiupove
Greenhorn

Joined: May 16, 2011
Posts: 6
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.


Johhny
Andraz Poje
Ranch Hand

Joined: Sep 25, 2008
Posts: 32
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
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

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

Joined: Oct 13, 2005
Posts: 40052
    
  28
And welcome to the Ranch
John Fiupove
Greenhorn

Joined: May 16, 2011
Posts: 6
Thanks! Jtable is great! Only problem is visual one. How can I make row selection without that border in the middle?

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
I think this discussion would sit better on our GUIs forum. Moving.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

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.

luck, db
There are no new questions, but there may be new answers.
John Fiupove
Greenhorn

Joined: May 16, 2011
Posts: 6
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

Joined: May 03, 2008
Posts: 4664
    
    5

Read the API for methods that set whether the gridlines are painted shown.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
John Fiupove
Greenhorn

Joined: May 16, 2011
Posts: 6


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

Joined: May 16, 2011
Posts: 6
Finally



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Double text alignment