Hi,
I want to add a JPanel (called panel) to the mother object, in this case another JPanel. On 'panel' there should be a list of some CheckBoxes, and since their number is not constant, I want to have a possibility to scroll down the 'panel' to see them all if there are more of them. So, I wanted to add 'panel' to a JScrollPane scrollPane, but it does not work. Do you know what have I done wrong?
JPanel panel; JScrollPane scrollPane; //this is in the constructor of the mother object, JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEtchedBorder()); panel.setBounds(0,0,415,420); panel.setBackground(new Color(255,255,255)); scrollPane = new JScrollPane(panel); add(scrollPane, 0, 40, 415, 400); //method add defined in the mother object public void add(Component c, int x, int y, int sX, int sY) { add(c); c.setBounds(x,y,sX,sY); }
In the final program, the scrollPane appears on the mother JPanel, but without any sign of the 'panel'. I tried to add some other object to 'panel' (test JLabels and JButtons), but it was still the same - no 'panel' clipped to the scrollPane.
Thank you very much for your response.