• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create a horizontal list?

 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to create a list that its containts displayed horizontaly?
another thing please,
each item in this list contains many information (e.g name, address,..) all this information is a one item in a horizontal list.

thanks for your ideas
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can cause the fields of each element to appear on one line by overriding toString() like this:
public String toString() { return name + address + city + state; }

You can put lots of stuff on one line by repeatedly using System.out.print(), subject to the size of your line.
 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your reply but may by it was my fault that I was not clear enough.
What I meant is to create a JList into a GUI like the one below:

|--------------------------------------------|
| first last first1 last1 |
| 11 this Rd, 22 another Rd, |
| first@mymail.com first1@hismail.com |
|---------------------------------------------

--------> Reading this JList in this direction
You can see the first item in this JList contains many information about a person called (first last), his address and his email, so when the item is highlighted, all those information will be highlighted at one time considered as one item in a JList.
 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, the image that I created was not clear enough.
 
Vijayendra V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Qusay Jaafar:
thank you for your reply but may by it was my fault that I was not clear enough.
What I meant is to create a JList into a GUI like the one below:

|--------------------------------------------|
| first last first1 last1 |
| 11 this Rd, 22 another Rd, |
| first@mymail.com first1@hismail.com |
|---------------------------------------------


If I understand your question right, you want to have a List box on your GUI inside which you can have three columns. Is that correct?

You can have a Vector to hold three String containing the information that you want and then create a JList using that Vector into the Constructor. Can't you? Try it out.
 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using a vector is the same as using an array or using add(object) method. JList will display all those information vertically.
Let me ask my question in another form.
I need JList into a GUI but I need to scroll its elements horizontally not vertically.
just consider its element (right now) as one object.
 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any idea?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is a GUI-related question, you will probaly get a better response if you wander over to the Swing / AWT / SWT / JFace forum to ask your question.

HTH

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic