我寫了一個小程序,將切換數量L & F 只需從列表中選擇L & F,按鈕將看起來不同。當第二次機會在java中的外觀和感覺
,我初學者用java :)
這是我的代碼
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int selectedIndices[] = jList1.getSelectedIndices();
try {
for (int j = 0; j < selectedIndices.length; j++){
if(j == 0){
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
this.pack();
}
if(j == 1){
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
this.pack();
}
if(j == 2){
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
// this.pack();
}
if(j == 3){
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
this.pack();
}
}
}
catch (Exception e) {
}
}
你曾經有超過1個選擇的指標嗎?使用j只是一個索引變量似乎不正確... – ControlAltDel 2012-04-26 18:16:02