i have this:
jLabel1.setBorder(null);
jLabel2.setBorder(null);
jLabel3.setBorder(null);
jLabel4.setBorder(null);
jLabel5.setBorder(null);
jLabel6.setBorder(null);
i want to make it simpler and less noob... any ideas?
i have this:
jLabel1.setBorder(null);
jLabel2.setBorder(null);
jLabel3.setBorder(null);
jLabel4.setBorder(null);
jLabel5.setBorder(null);
jLabel6.setBorder(null);
i want to make it simpler and less noob... any ideas?
Try
Component[] components = frame.getContentPane().getComponents();
for (Component component : components) {
if (component instanceof JComponent) {
((JComponent) component).setBorder(null);
}
}
If you want only JLabel
s, not all components to have a null border, change the instanceof
check and the cast to JLabel
To include the comment on your answer by camickr, a JLabel
doesn't have a border by default, so you don't have to do anything. You should do this only in case you have assigned a border at some point and want to get rid of it.