• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Double text alignment

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Sheriff
Posts: 28329
97
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79974
396
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
John Fiupove
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79974
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this discussion would sit better on our GUIs forum. Moving.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the API for methods that set whether the gridlines are painted shown.
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally



 
Let nothing stop you! Not even this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic