I have a JPanel that uses FlowLayout. I am adding several JLabels to a JPanel, use setPreferedSize () to adjust their size and save them in the label_list. Everything is working fine. Then I want to resize them:
for(JLabel c:label_list){
c.setPreferedSize(new Dimension(10,10));
}
And it does not work.
c.setBackground(Color.red)
and similar things work. Why can't I use setPreferedSize here?
c.setBounds (1,1,10,10) and c.setSize (10,10) Works, but after updating the user interface (resizing the panel), each size returns to its normal state.
source
share