vendredi 6 mars 2015

Insert a JPanel with null layout into a JScroll



I have a JPanel (myPanel) with a lot of button inside (this panel is contained in another panel that contain other components). I would insert this JPanel (myPanel) into a scroll to control better the button.


This is a part of my code:



JPanel firstPanel = new JPanel(null);
......
......
JPanel myPanel = new JPanel(null);
myPanel.setBounds(0, position+22, 400, 500);
for (int i=0; i<size; i++) {
JButton button = new JButton(myList.get(i));
if (counter%4 == 0) {
button.setBounds(270, 0+(4*i), 90, 18);
} else if (counter%3 == 0) {
button.setBounds(180, 4+(4*i), 90, 18);
} else if (counter%2 == 0) {
button.setBounds(90, 8+(4*i), 90, 18);
} else {
button.setBounds(0, 12+(4*i), 90, 18);
}
myPanel.add(bottone);
}
......
......
firstPanel.add(myPanel);


So, how can i do to insert it into a scroll?




Aucun commentaire:

Enregistrer un commentaire