JList text alignment

I have JListwith elements that I want to show two values. Is there a way for it to display the name of the string and then have the correct string to show the value. Something like that:

Title__________________120
Title2_________________135

Is it possible to pass two lines to an element and display the first line on the left and the second on the right?

+5
source share
1 answer

Of course, implement a custom renderer . You can return JPanelby using BorderLayoutas a rendering component with the text LHS in WESTand text RHS in EAST.

- HTML (a JLabel), HTML, 100% . (, , ).


BTW - , JTable . .


.. jtable ?

! , . "Jane".

Table with row selected

, , .

JTable JList.

, . , , , ( ) .

+6

All Articles