-1

so i'm making an interface using NetBeans, and here's what I want to do :

I've created a JPanel class, wich shows some informations on objects (labels, texFields and buttons). I want to add several panels like the one above, into a same JScrollPane (to look like a list of independant Panels).

I can't use JList, because I don't want to list just the "toString" of my panels, I've look this : http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html#renderer But I don't think this can help me (this explain how to put icons into a cellRenderer, but i'd like to add directly a Panel into a vertical List of other panels)...

Memo36
  • 333
  • 4
  • 11
  • 1
    Add a `JScrollPane` to you form, add a `JPanel` to the scroll pane. You can now treat this panel as any normal container, change it's layout, add other components to it. You might like to take a look at [How to use scroll panes](http://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html) – MadProgrammer Apr 12 '13 at 00:04
  • But how can I put Panels into je ScrollPane one above the other ? – Memo36 Apr 12 '13 at 02:13
  • Use a `GridLayout` on the "view", set to have 0 rows and 1 column. The add any new `JPanel`s you want to the `JPanel` which is acting as the view for the scroll pane – MadProgrammer Apr 12 '13 at 02:15
  • Oh yeah ok, I didn't understand the fact that I needed to put an other JPanel into my ScrollPane. Works good, thanks ! – Memo36 Apr 12 '13 at 15:27

1 Answers1

3

This example lets you scroll little thumbnail images, but the ImagePanel could have components. It uses FlowLayout for a horizontal layout, but GridLayout(0, 1) would work for a vertical layout.

Community
  • 1
  • 1
Catalina Island
  • 7,027
  • 2
  • 23
  • 42