Owen
Owen

Reputation: 1551

A Swing component to display separate, selectable strings on different lines?

I'm looking for a Swing component that displays several separate strings (probably from a string array or list) on separate lines within a pane or field (scrollable if there's too many to show at once). The user needs to be able to select one of these lines (double-clicking would be ideal) and thereby trigger a listener that does some magic with that line's string. Can anyone point me in the right direction?

Upvotes: 0

Views: 475

Answers (3)

camickr
camickr

Reputation: 324118

The user needs to be able to select one of these lines (double-clicking would be ideal) and thereby trigger a listener that does some magic with that line's string

You can use the List Action for this.

Upvotes: 1

ChrisJ
ChrisJ

Reputation: 5251

I suggest you to use a JList inside a vertical JScrollPane.

Upvotes: 2

Zoe
Zoe

Reputation: 1833

Try a JList: http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JList.html. Can be added to a ScrollPane if you want to include scrolling ability.

Upvotes: 3

Related Questions