+ 1

JList - space or tabulation

Hello, I have a JList. I filled it with a defaultmodel object. Each item in my defaultModel contains 3 strings. So, i would like of my item in the JList be arrange with tabulation.. How can i arange The Items of my JList? Name FirstName Email Blablabla Bloblo bla@yahoo.com Polo Santos posan@yahoo.com

10th Dec 2017, 1:11 AM
Attitude
Attitude - avatar
5 Respostas
+ 3
Sounds/looks more like you want to use a JTable instead of a JList. You can then remove the the cell borders to make it appear more like a list with headers using table.setShowGrid(false); https://stackoverflow.com/questions/3167112/remove-cells-border-in-a-jtable
10th Dec 2017, 1:32 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Have you tried building each string for the list inserting a \t or 2 between each field? name+"\t"+firstname+"\t"+email
10th Dec 2017, 1:41 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
You'll need to use a monospace font along with String.format(). https://stackoverflow.com/questions/28243788/how-do-i-format-text-within-a-jlist https://stackoverflow.com/questions/8637181/java-formating-strings-in-jlist But, you should really consider using JTable instead. I think you'll find it easier once you understand how to use it IMO.
10th Dec 2017, 2:10 AM
ChaoticDawg
ChaoticDawg - avatar
0
I want to use JList. There's no method named padding to use for that?
10th Dec 2017, 1:38 AM
Attitude
Attitude - avatar
0
Yes i did it. I puted "\t", but nothing happened.
10th Dec 2017, 1:56 AM
Attitude
Attitude - avatar