This may be a silly question, and I'd rather not use the NetBeans inbuilt GUI editor, but I've been asked to.
The problem I'm having is I'm attempting to add a JPanel (itself containing a few labels) to an already existing JScrollPane that is on a JFrame. The JScrollPane and JFrame have been created using the NetBeans GUI editor.
I have an ArrayList (of undetermined size) of orders, and for each order in the ArrayList I'm attempting to create a JPanel and put it in the JScrollPane.
I'm having trouble with adding a JPanel to a JScrollPane and then adding labels to the JPanel. I've looked at tutorials online but all of them need reference to the JFrame... but because I'm using the inbuilt GUI editor that comes with NetBeans I can't reference the JFrame in the code.
The code I'm currently using:
FlowLayout experimentLayout = new FlowLayout(FlowLayout.CENTER);
JPanel panel = new JPanel();
panel.setLayout(experimentLayout);
JPanel panel2 = new JPanel();
JLabel label2 = new JLabel("Hello");
scrollPane.add(panel); //ScrollPane is already on form (put there by GUI editor)
panel.add(panel2);
panel2.add(label2);
Any help on how to add these JPanel to the JScrollPane would be very much appreciated!