Swing component to display String[]

S

Steve

Is there any built-in Java GUI components that will display the contents of
a String array? I'm simply looking to display a vertical list, I'm not
looking for any user interaction with this list.
 
K

Knute Johnson

Steve said:
Is there any built-in Java GUI components that will display the contents of
a String array? I'm simply looking to display a vertical list, I'm not
looking for any user interaction with this list.

You could use an array of Labels or put your array in a TextArea.
 
R

Rhino

Steve said:
Is there any built-in Java GUI components that will display the contents of
a String array? I'm simply looking to display a vertical list, I'm not
looking for any user interaction with this list.
I think you want a JList, probably one which you've set read-only to prevent
the user interaction. You'll probably want to wrap the JList in a
JScrollpane so that the user can see all of the data without using up a lot
of space on your GUI.

The Java Tutorial explains how to do all of this and is well worth having.

Rhino
 
R

Roedy Green

Is there any built-in Java GUI components that will display the contents of
a String array? I'm simply looking to display a vertical list, I'm not
looking for any user interaction with this list.

A JTable is the usual solution. You could use an array of JLabels in
a JScrollPane. You could use a JTextArea with one String per line.
If you want to play games with fonts and colours, you could use a
Canvas/JPanel and drawString
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top