Anyone knows Why the laf is not changing in the following code? (running in Ubuntu)
import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
public class TEST extends JPanel {
public TEST() {
final LookAndFeelInfo[] lafArray = UIManager.getInstalledLookAndFeels();
String[] names = new String[lafArray.length];
for (int i = 0; i < names.length; i++) {
names[i] = lafArray[i].getName();
}
final JComboBox cb = new JComboBox(names);
cb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
try {
int index = cb.getSelectedIndex();
LookAndFeelInfo lafInfo = lafArray[index];
String lafClassName = lafInfo.getClassName();
System.out.println(lafClassName);
UIManager.setLookAndFeel(lafClassName);
} catch (Exception e) {
e.printStackTrace();
}
}
});
add(cb);
}
public static void main(String[] args) throws Exception {
System.out.println("start");
JDialog dialog = new JDialog(null, Dialog.ModalityType.APPLICATION_MODAL);
dialog.setContentPane(new TEST());
dialog.pack();
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
dialog.dispose();
System.out.println("end");
}
}