LookAndFeel not changing in Ubuntu

Posted by Tom Brito on Stack Overflow See other posts from Stack Overflow or by Tom Brito
Published on 2010-04-16T20:31:49Z Indexed on 2010/04/16 21:03 UTC
Read the original article Hit count: 365

Filed under:
|
|
|

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");
    }

}

© Stack Overflow or respective owner

Related posts about java

Related posts about swing