This is my click action:
succ.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
int x=0;
int i;
labelpanel.revalidate();
labelpanel.repaint();
for (i=status; i<status+5; i++){
RidimIcon locand = new RidimIcon();
labelapp.get(i).setBounds(74+x, 1, 80, 90);
labelapp.get(i).setIcon(locand.newicona(pathicon[i], labelapp.get(i)));
labelpanel.add(labelapp.get(i));
x=x+120;
}
status=status+5; //change status
}
});
"Labelpanel" is an array of JLabel:
try {
ResultSet rs = Datainter.eseguiQuery(query);
while(rs.next())
{
pathicon[contatore] = rs.getString("locandina");
JLabel tmplabel = new JLabel();
labelapp.add(tmplabel);
labelapp.get(contatore).setIcon(new ImageIcon(pathicon[contatore]));
contatore++;
}
} catch (SQLException e) {
e.printStackTrace();
}
i want to create programm that see 5 image at click. I have an array labels with 50 images, when i click first time i see 1 - 5 labels[1-5], when i click second time i see labels[5-10], third time [10-11] etc.. Why i see only first 5 labelapp when i click on "succ"? How can i see other 5 labelapp when i click again and leave first 5 images in panel?
(with RemoveAll i cant see my last Jlabels:
prec.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int x=0;
int i;
labelpanel.removeAll();
for (i=status; i<status-5; i--){
RidimIcon locand = new RidimIcon();
labelapp.get(i).setBounds(74+x, 1, 80, 90);
labelapp.get(i).setIcon(locand.newicona(pathicon[i], labelapp.get(i)));
labelpanel.add(labelapp.get(i));
x=x+120;
}
labelpanel.revalidate();
labelpanel.repaint();
status=status-5;
}
});