How to make a scrollable JList to add details got from a JOptionPane?

To make the JList scrollable, simply embed it in a JScrollPanel. Instead of.

To make the JList scrollable, simply embed it in a JScrollPanel. Instead of add(myList, constraints); do add(new JScrollPanel(myList), constraints); To extend the list, just get the JList's ListModel (using getListModel) and use add to add objects. More on using ListModels in Sun's tutorial.

As discussed in How to Use Lists, JList uses a list model as the source of data it displays. Just add your data to a DefaultListModel, and use it to construct your list. DefaultListModel dlm = new DefaultListModel(); // add data JList list = new JList(dlm); panel.

Add(new JScrollPane(list)).

You've to use the ActionListener of Button, that you've missed in the code snippet. In the OK Option : JList jlist = ...; jlist. Add(txtflightno.getText()); jlist.

Add(txtmechanicalstatus.getText()); jlist. Add(txtmedicalstatus.getText()); .... .... & add(new JScrollPanel(myList), constraints); After this use validate method of Component to update the list with this new item. But one thing you should remember is that list displays each item row-wise.

I suggest you to use JTable with which you can display your items in a meaningful way...

Coder: I don't see where @Haxed needs an ActionListener; the JOptionPane's OK button should do. Also, JList can't accept data directly; a ListModel should be used instead. – trashgod Jul 8 '10 at 6:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions