0
我有這一切對象:爪哇 - 選擇在一個框架
jLabel1.setBorder(null);
jLabel2.setBorder(null);
jLabel3.setBorder(null);
jLabel4.setBorder(null);
jLabel5.setBorder(null);
jLabel6.setBorder(null);
我想讓它更簡單,更菜鳥...任何想法?
我有這一切對象:爪哇 - 選擇在一個框架
jLabel1.setBorder(null);
jLabel2.setBorder(null);
jLabel3.setBorder(null);
jLabel4.setBorder(null);
jLabel5.setBorder(null);
jLabel6.setBorder(null);
我想讓它更簡單,更菜鳥...任何想法?
嘗試
Component[] components = frame.getContentPane().getComponents();
for (Component component : components) {
if (component instanceof JComponent) {
((JComponent) component).setBorder(null);
}
}
如果你只想要JLabel
S,不是所有的組件有一個空邊界,改變instanceof
檢查,並投以JLabel
要包括你的答案被camickr評論,JLabel
默認沒有邊框,所以你不必做任何事情。你應該這樣做,只有當你在某個時候指定了邊界並且想要擺脫邊界。
謝謝,那肯定會奏效!我確實有邊界,我不想用手寫出所有的組件。 – Ali 2009-12-23 17:40:20
默認情況下JLabel沒有邊框,所以你不必做任何事情。 – camickr 2009-12-23 07:15:09