wood burning stoves*
The moose likes Java in General and the fly likes How to create a horizontal list? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to create a horizontal list?" Watch "How to create a horizontal list?" New topic
Author

How to create a horizontal list?

Qusay Jaafar
Ranch Hand

Joined: May 06, 2002
Posts: 127
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


Qusay
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
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.


Mike Gershman
SCJP 1.4, SCWCD in process
Qusay Jaafar
Ranch Hand

Joined: May 06, 2002
Posts: 127
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

Joined: May 06, 2002
Posts: 127
Sorry, the image that I created was not clear enough.
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
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.


Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Qusay Jaafar
Ranch Hand

Joined: May 06, 2002
Posts: 127
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

Joined: May 06, 2002
Posts: 127
any idea?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create a horizontal list?