How do I create rows of JPanels in a JPanel under a JBScrollPane?

Usually I'd use BoxLayout but I can't use a BoxLayout because it's not presented as an option and when I try it it doesn't work as it would in normal Java. Like I should be able to just follow the Oracle example to create a set of rows:

http://docs.oracle.com/javase/tutorial/uiswing/layout/box.html

but this doesn't work, using add on the JPanel requires a constraint for some reason otherwise I get a null pointer exception. With a BoxLayout you provide the constraint when you create the layout. All I want is a row of panels in a scroll pane. It's trivial. I'm making a list of users with images and names, so a JList is out of the question since you can only put text in those. I'll keep looking but it looks like JBScrollPane does not have JScrollPane's features.

2 comments
Comment actions Permalink

What exactly does not work? Are you using the UI Designer to set up your UI or are you building manually? What's the stacktrace of the NullPointerException that you're getting?

JBScrollPane certainly does have JScrollPane's features, because it extends JScrollPane; the only differences in behavior concern scrollbar rendering.

0
Comment actions Permalink

Thank you for your reply. I had given up and was going with a tree instead but I just reverted back to the scrollpane to get the stacktrace for you using Local History and this time it worked. Exact same code. All I did was revert. O_o

0

Please sign in to leave a comment.