Example usage for javax.swing SwingUtilities updateComponentTreeUI

List of usage examples for javax.swing SwingUtilities updateComponentTreeUI

Introduction

In this page you can find the example usage for javax.swing SwingUtilities updateComponentTreeUI.

Prototype

public static void updateComponentTreeUI(Component c) 

Source Link

Document

A simple minded look and feel change: ask each node in the tree to updateUI() -- that is, to initialize its UI property with the current look and feel.

Usage

From source file:com.softeffect.primemovers.ui.ClientApplication.java

/**
 * Method called by LoginDialog to notify the sucessful login.
 * /*from w  ww. j  av  a2 s.  c om*/
 * @param loginInfo
 *            login information, like username, password, ...
 */
public void loginSuccessful(Map loginInfo) {
    MDIFrame mdi = new MDIFrame(this);
    try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        /* Turn off metal's use of bold fonts */
        UIManager.put("swing.boldMetal", Boolean.FALSE);
        SwingUtilities.updateComponentTreeUI(mdi);
    } catch (Throwable ex) {
        ex.printStackTrace();
    }
}

From source file:model.settings.ReadSettings.java

/**
 * checks whether program information on current workspace exist.
 * @return if workspace is now set.//w  ww.  ja va  2s .  c o m
 */
public static String install() {
    boolean installed = false;
    String wsLocation = "";
    /*
     * does program root directory exist?
     */
    if (new File(PROGRAM_LOCATION).exists()) {

        //try to read 
        try {
            wsLocation = readFromFile(PROGRAM_SETTINGS_LOCATION);

            installed = new File(wsLocation).exists();
            if (!installed) {
                wsLocation = "";
            }

        } catch (FileNotFoundException e) {
            System.out.println("file not found " + e);
            showErrorMessage();
        } catch (IOException e) {
            System.out.println("io" + e);
            showErrorMessage();
        }
    }

    //if settings not found.
    if (!installed) {

        new File(PROGRAM_LOCATION).mkdir();
        try {

            //create new file chooser
            JFileChooser jc = new JFileChooser();

            //sets the text and language of all the components in JFileChooser
            UIManager.put("FileChooser.openDialogTitleText", "Open");
            UIManager.put("FileChooser.lookInLabelText", "LookIn");
            UIManager.put("FileChooser.openButtonText", "Open");
            UIManager.put("FileChooser.cancelButtonText", "Cancel");
            UIManager.put("FileChooser.fileNameLabelText", "FileName");
            UIManager.put("FileChooser.filesOfTypeLabelText", "TypeFiles");
            UIManager.put("FileChooser.openButtonToolTipText", "OpenSelectedFile");
            UIManager.put("FileChooser.cancelButtonToolTipText", "Cancel");
            UIManager.put("FileChooser.fileNameHeaderText", "FileName");
            UIManager.put("FileChooser.upFolderToolTipText", "UpOneLevel");
            UIManager.put("FileChooser.homeFolderToolTipText", "Desktop");
            UIManager.put("FileChooser.newFolderToolTipText", "CreateNewFolder");
            UIManager.put("FileChooser.listViewButtonToolTipText", "List");
            UIManager.put("FileChooser.newFolderButtonText", "CreateNewFolder");
            UIManager.put("FileChooser.renameFileButtonText", "RenameFile");
            UIManager.put("FileChooser.deleteFileButtonText", "DeleteFile");
            UIManager.put("FileChooser.filterLabelText", "TypeFiles");
            UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
            UIManager.put("FileChooser.fileSizeHeaderText", "Size");
            UIManager.put("FileChooser.fileDateHeaderText", "DateModified");
            SwingUtilities.updateComponentTreeUI(jc);

            jc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            jc.setMultiSelectionEnabled(false);

            final String informationMsg = "Please select the workspace folder. \n"
                    + "By default, the new files are saved in there. \n\n"
                    + "Is changed simply by using the Save-As option.\n"
                    + "If no folder is specified, the default worspace folder \n"
                    + "is the home directory of the current user.";
            final int response = JOptionPane.showConfirmDialog(jc, informationMsg, "Select workspace folder",
                    JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);

            final String defaultSaveLocation = System.getProperty("user.home")
                    + System.getProperty("file.separator");
            File f;
            if (response != JOptionPane.NO_OPTION) {

                //fetch selected file
                f = jc.getSelectedFile();
                jc.showDialog(null, "select");
            } else {
                f = new File(defaultSaveLocation);
            }

            printInformation();

            if (f == null) {
                f = new File(defaultSaveLocation);
            }
            //if file selected
            if (f != null) {

                //if the file exists
                if (f.exists()) {
                    writeToFile(PROGRAM_SETTINGS_LOCATION, ID_PROGRAM_LOCATION + "\n" + f.getAbsolutePath());
                } else {

                    //open message dialog
                    JOptionPane.showConfirmDialog(null, "Folder does " + "not exist",
                            "Error creating workspace", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
                            null);
                }

                //recall install
                return install();
            }

        } catch (IOException e) {
            System.out.println(e);
            JOptionPane.showConfirmDialog(null, "An exception occured." + " Try again later.",
                    "Error creating workspace", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null);
        }
    }

    if (System.getProperty("os.name").equals("Mac OS X")) {

        installOSX();
    } else if (System.getProperty("os.name").equals("Linux")) {
        installLinux();
    } else if (System.getProperty("os.name").equals("Windows")) {
        installWindows();
    }

    return wsLocation;

}

From source file:com.sshtools.appframework.ui.SshToolsApplicationFrame.java

public void updateUI() {
    SwingUtilities.updateComponentTreeUI(this);
    if (getApplication() != null) {
        for (Iterator i = getApplication().additionalOptionsTabs.iterator(); i.hasNext();) {
            SwingUtilities.updateComponentTreeUI(((JComponent) i.next()));
        }/*from   w  w w.  j ava2  s  .  co m*/
    }

}

From source file:com.igormaznitsa.sciareto.ui.MainFrame.java

public MainFrame(@Nonnull @MustNotContainNull final String... args) {
    super();/*from  w  ww .  ja  va2  s. c  o m*/
    initComponents();

    this.stackPanel = new JPanel();
    this.stackPanel.setFocusable(false);
    this.stackPanel.setOpaque(false);
    this.stackPanel.setBorder(BorderFactory.createEmptyBorder(32, 32, 16, 32));
    this.stackPanel.setLayout(new BoxLayout(this.stackPanel, BoxLayout.Y_AXIS));

    final JPanel glassPanel = (JPanel) this.getGlassPane();
    glassPanel.setOpaque(false);

    this.setGlassPane(glassPanel);

    glassPanel.setLayout(new BorderLayout(8, 8));
    glassPanel.add(Box.createGlue(), BorderLayout.CENTER);

    final JPanel ppanel = new JPanel(new BorderLayout(0, 0));
    ppanel.setFocusable(false);
    ppanel.setOpaque(false);
    ppanel.setCursor(null);
    ppanel.add(this.stackPanel, BorderLayout.SOUTH);

    glassPanel.add(ppanel, BorderLayout.EAST);

    this.stackPanel.add(Box.createGlue());

    glassPanel.setVisible(false);

    this.setTitle("Scia Reto");

    setIconImage(UiUtils.loadImage("logo256x256.png"));

    this.stateless = args.length > 0;

    final MainFrame theInstance = this;

    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(@Nonnull final WindowEvent e) {
            if (doClosing()) {
                dispose();
            }
        }
    });

    this.tabPane = new EditorTabPane(this);

    this.explorerTree = new ExplorerTree(this);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(250);
    splitPane.setResizeWeight(0.0d);
    splitPane.setLeftComponent(this.explorerTree);
    splitPane.setRightComponent(this.tabPane);

    add(splitPane, BorderLayout.CENTER);

    this.menuOpenRecentProject.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            final File[] lastOpenedProjects = FileHistoryManager.getInstance().getLastOpenedProjects();
            if (lastOpenedProjects.length > 0) {
                for (final File folder : lastOpenedProjects) {
                    final JMenuItem item = new JMenuItem(folder.getName());
                    item.setToolTipText(folder.getAbsolutePath());
                    item.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openProject(folder, false);
                        }
                    });
                    menuOpenRecentProject.add(item);
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            menuOpenRecentProject.removeAll();
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    this.menuOpenRecentFile.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            final File[] lastOpenedFiles = FileHistoryManager.getInstance().getLastOpenedFiles();
            if (lastOpenedFiles.length > 0) {
                for (final File file : lastOpenedFiles) {
                    final JMenuItem item = new JMenuItem(file.getName());
                    item.setToolTipText(file.getAbsolutePath());
                    item.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFileAsTab(file);
                        }
                    });
                    menuOpenRecentFile.add(item);
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            menuOpenRecentFile.removeAll();
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    if (!this.stateless) {
        restoreState();
    } else {
        boolean openedProject = false;
        for (final String filePath : args) {
            final File file = new File(filePath);
            if (file.isDirectory()) {
                openedProject = true;
                openProject(file, true);
            } else if (file.isFile()) {
                openFileAsTab(file);
            }
        }
        if (!openedProject) {
            //TODO try to hide project panel!
        }
    }

    final LookAndFeel current = UIManager.getLookAndFeel();
    final ButtonGroup lfGroup = new ButtonGroup();
    final String currentLFClassName = current.getClass().getName();
    for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(info.getName());
        lfGroup.add(menuItem);
        if (currentLFClassName.equals(info.getClassName())) {
            menuItem.setSelected(true);
        }
        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(@Nonnull final ActionEvent e) {
                try {
                    UIManager.setLookAndFeel(info.getClassName());
                    SwingUtilities.updateComponentTreeUI(theInstance);
                    PreferencesManager.getInstance().getPreferences().put(Main.PROPERTY_LOOKANDFEEL,
                            info.getClassName());
                    PreferencesManager.getInstance().flush();
                } catch (Exception ex) {
                    LOGGER.error("Can't change LF", ex);
                }
            }
        });
        this.menuLookAndFeel.add(menuItem);
    }
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

public MainForm(final String fileToOpen) {
    Log.info("Start in editor mode");

    this.application = null;
    this.hexLayerList = null;

    initComponents();// w  w w.  j  a  v  a2s. c o m

    final JFrame theFrame = this;

    for (final javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        final JMenuItem landfItem = new JMenuItem(info.getName());
        landfItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                } catch (Exception ex) {
                    Log.error("Can't change L&F", ex);
                }
                SwingUtilities.updateComponentTreeUI(theFrame);
            }
        });
        menuLANDF.add(landfItem);
    }

    popupMenu = new JPopupMenu();
    final JMenuItem comments = new JMenuItem("Comments");
    comments.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // open dialog for cell comment
            final CellCommentDialog commentDialog = new CellCommentDialog(theFrame,
                    "Commentaries for the cell at " + popupHex.getColumn() + "," + popupHex.getRow(),
                    cellComments.getForHex(popupHex));
            commentDialog.setVisible(true);
            final String result = commentDialog.getResult();
            if (result != null) {
                cellComments.setForHex(popupHex, result);
            }
        }
    });
    popupMenu.add(comments);

    hexMapPanelDesktop = new Desktop();
    layers = new LayerListModel(256, 128);

    try {
        this.setIconImage(ImageIO.read(this.getClass().getClassLoader()
                .getResource("com/igormaznitsa/jhexed/swing/editor/icons/logo.png")));
    } catch (Exception ex) {
        Log.error("Can't load app icon", ex);
    }

    hexMapPanel = new HexMapPanel(this.layers);
    hexMapPanel.addHexMapPanelListener(this);

    hexMapPanel.addMouseListener(this);
    hexMapPanel.addMouseMotionListener(this);
    hexMapPanel.addMouseWheelListener(this);

    this.panelMainArea.add(hexMapPanelDesktop, BorderLayout.CENTER);

    this.frameLayers = new FrameLayers(layers, hexMapPanel);
    this.frameTools = new FrameTools();
    this.frameToolOptions = new FrameToolOptions();

    hexMapPanelDesktop.addFrame(this.frameLayers);
    hexMapPanelDesktop.addFrame(this.frameTools);
    hexMapPanelDesktop.addFrame(this.frameToolOptions);

    this.frameLayers.setVisible(true);
    this.frameTools.setVisible(true);
    this.frameToolOptions.setVisible(true);

    hexMapPanelDesktop.setContentPane(hexMapPanel);

    this.dsl = new GroovyPluginBase(this, this.layers);
    this.compilerConfiguration = new CompilerConfiguration();
    this.compilerConfiguration.setScriptBaseClass(DelegatingScript.class.getName());
    this.groovyShell = new GroovyShell(this.compilerConfiguration);

    InsideApplicationBus.getInstance().addAppBusListener(this);

    loadSettings();

    resetState();

    Log.info("The MainForm created");

    registerInternalPlugins();
    registerExternalPlugins(".");

    if (fileToOpen != null) {
        Log.info("Started with parameter: " + fileToOpen);
        final File file = new File(fileToOpen);
        loadFromFile(file);
    }

    this.lookupContainer = new ObjectLookup(this, this.hexMapPanel.getHexEngine(), this,
            Log.makeApplicationLog());
    this.applicationGraphics = null;
}

From source file:v800_trainer.JCicloTronic.java

/** Creates new form JCicloTronic */
public JCicloTronic() {

    ScreenSize = new Dimension();
    SelectionChanged = false;/*from www .  j  a  va2  s .co  m*/
    ScreenSize.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 50,
            java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 50);
    Size = new Dimension();

    Properties = new java.util.Properties();
    SystemProperties = java.lang.System.getProperties();
    chooser = new javax.swing.JFileChooser();
    RawData = new byte[98316];
    //        System.setProperty("jna.library.path" , "C:/WINDOWS/system32");

    try {
        FileInputStream in = new FileInputStream(SystemProperties.getProperty("user.dir")
                + SystemProperties.getProperty("file.separator") + "JCicloexp.cfg");
        Properties.load(in);
        in.close();
    } catch (Exception e) {
        FontSize = 20;
        setFontSizeGlobal("Tahoma", FontSize);

        JOptionPane.showMessageDialog(null,
                "Keine Config-Datei in:  " + SystemProperties.getProperty("user.dir"), "Achtung!",
                JOptionPane.ERROR_MESSAGE);
        Properties.put("working.dir", SystemProperties.getProperty("user.dir"));
        Eigenschaften = new Eigenschaften(new javax.swing.JFrame(), true, this);
        this.setExtendedState(Frame.MAXIMIZED_BOTH);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        double width = screenSize.getWidth();
        double height = screenSize.getHeight();
        this.setSize(new Dimension((int) width, (int) height));
        this.setPreferredSize(new Dimension((int) width, (int) height));
        this.setMinimumSize(new Dimension((int) width, (int) height));
        repaint();
    }
    try {

        UIManager.setLookAndFeel(Properties.getProperty("LookFeel"));
        SwingUtilities.updateComponentTreeUI(this);
        this.pack();
    } catch (Exception exc) {
    }

    if (debug) {
        try {
            System.setErr(new java.io.PrintStream(new FileOutputStream(Properties.getProperty("working.dir")
                    + SystemProperties.getProperty("file.separator") + "error.txt")));
            //        System.err =  new FileOutputStream(Properties.getProperty("working.dir") + SystemProperties.getProperty("file.separator") + "error.txt");
            System.setOut(new java.io.PrintStream(new FileOutputStream(Properties.getProperty("working.dir")
                    + SystemProperties.getProperty("file.separator") + "error.txt")));
        } catch (Exception err) {
        }
    }

    initComponents();

    setTitle("V800 Trainer    Datadir: " + Properties.getProperty("data.dir"));

    icon = new ImageIcon("hw.jpg");
    setIconImage(icon.getImage());

    if (Integer.parseInt(Properties.getProperty("View Geschw", "1")) == 1) {
        Graphik_check_Geschwindigkeit.setSelected(true);
    } else {
        Graphik_check_Geschwindigkeit.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Hhe", "1")) == 1) {
        Graphik_check_Hhe.setSelected(true);
    } else {
        Graphik_check_Hhe.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Hf", "1")) == 1) {
        Graphik_check_HF.setSelected(true);
    } else {
        Graphik_check_HF.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Temp", "1")) == 1) {
        Graphik_check_Temp.setSelected(true);
    } else {
        Graphik_check_Temp.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Steigp", "1")) == 1) {
        Graphik_check_Steigung_p.setSelected(true);
    } else {
        Graphik_check_Steigung_p.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Steigm", "1")) == 1) {
        Graphik_check_Steigung_m.setSelected(true);
    } else {
        Graphik_check_Steigung_m.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View av_Geschw", "1")) == 1) {
        Graphik_check_av_Geschw.setSelected(true);
    } else {
        Graphik_check_av_Geschw.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Cadence", "1")) == 1) {
        Graphik_check_Cadence.setSelected(true);
    } else {
        Graphik_check_Cadence.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Schrittlnge", "1")) == 1) {
        Graphik_check_Schrittlnge.setSelected(true);
    } else {
        Graphik_check_Schrittlnge.setSelected(false);
    }

    if (Integer.parseInt(Properties.getProperty("ZeitStreckeAbstnde", "1")) == 1) {
        Graphik_check_Abstand.setSelected(true);
    } else {
        Graphik_check_Abstand.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("SummenHisto", "1")) == 1) {
        Summenhistogramm_Check.setSelected(true);
    } else {
        Summenhistogramm_Check.setSelected(false);
    }

    if (Integer.parseInt(Properties.getProperty("xy_Strecke", "1")) == 1) {
        Graphik_Radio_Strecke.setSelected(true);
        Graphik_Radio_Zeit.setSelected(false);
    } else {
        Graphik_Radio_Strecke.setSelected(false);
        Graphik_Radio_Zeit.setSelected(true);
    }

    //Buttons fr XY-Darstellung   (ber Strecke oder ber Zeit)
    X_Axis = new ButtonGroup();
    X_Axis.add(Graphik_Radio_Strecke);
    X_Axis.add(Graphik_Radio_Zeit);

    //Buttons fr Jahresbersicht
    bersicht = new ButtonGroup();
    bersicht.add(jRadioButton_jahresverlauf);
    bersicht.add(jRadioButton_monatsbersicht);

    Datenliste_Zeitabschnitt.addItem("nicht aktiv");
    Datenliste_Zeitabschnitt.addItem("vergangene Woche");
    Datenliste_Zeitabschnitt.addItem("vergangener Monat");
    Datenliste_Zeitabschnitt.addItem("vergangenes Jahr");
    Datenliste_Zeitabschnitt.addItem("Alles");

    if (Datentabelle.getRowCount() != 0) {
        Datentabelle.addRowSelectionInterval(0, 0);
        Datenliste_scroll_Panel.getViewport().setViewPosition(new java.awt.Point(0, 0));
    }
    //        if (Properties.getProperty("CommPort").equals("nocom")) {
    //            jMenuReceive.setEnabled(false);
    //        } else {
    //            jMenuReceive.setEnabled(true);
    //        }

    jLabel69_Selektiert.setText(Datentabelle.getSelectedRowCount() + " / " + Datentabelle.getRowCount());

    setFileChooserFont(chooser.getComponents());
    locmap = true;
    Map_Type.removeAllItems();
    Map_Type.addItem("OpenStreetMap");
    Map_Type.addItem("Virtual Earth Map");
    Map_Type.addItem("Virtual Earth Satelite");
    Map_Type.addItem("Virtual Earth Hybrid");
    locmap = false;
    //    ChangeModel();
}

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * Changes the font size to what the user selects (between 8-30)
 *///  w  w  w.j a v  a  2  s  .co m
private void changeFontSize() {
    Integer[] nums = new Integer[23];
    for (int i = 8; i <= 30; i++) {
        nums[i - 8] = i;
    }
    try {
        int size = (int) JOptionPane.showInputDialog(this, "Choose a font size:", "Font Size",
                JOptionPane.PLAIN_MESSAGE, null, nums, Main.getState().getSettings().getFontSize());
        FontUIResource font = new FontUIResource("Dialog", Font.BOLD, size);

        Main.setUIFont(font);
        Main.getState().getSettings().setFontSize(size);
        SwingUtilities.updateComponentTreeUI(gr);

        for (JInternalFrame i : desktop.getAllFrames())
            i.pack();

    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:com.apatar.ui.Actions.java

public void setLookAndFeel(String className) {
    try {/*from w  w w .  j a  v  a  2s.c  om*/
        UIManager.setLookAndFeel(className);
    } catch (Exception e) {
    }
    SwingUtilities.updateComponentTreeUI(frame);
}

From source file:org.pegadi.client.ApplicationLauncher.java

protected void setTheme(String theme) {
    //TODO: fix nullpointerexception
    log.debug("theme: {}", theme);
    String lfTheme;/*w  ww . ja  va  2 s .  co m*/
    if (theme.equalsIgnoreCase("system")) {
        lfTheme = UIManager.getSystemLookAndFeelClassName();
    } else if (theme.equalsIgnoreCase("swing")) {
        lfTheme = UIManager.getCrossPlatformLookAndFeelClassName();
        lfTheme = UIManager.getSystemLookAndFeelClassName();
    } else if (theme.equalsIgnoreCase("gtk")) {
        lfTheme = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        //DEBUG
        lfTheme = UIManager.getSystemLookAndFeelClassName();
    } else {
        log.error("Invalid L&F theme");
        throw new IllegalArgumentException("'" + theme + "' is not a supported L&F");
    }

    if (!lfTheme.equals(UIManager.getLookAndFeel().getName())) {
        try {
            UIManager.setLookAndFeel(lfTheme);
        } catch (Exception e) {
            log.warn("Unable to set selected L&F, swapping to a default L&F");
            UIManager.LookAndFeelInfo[] installedLF = UIManager.getInstalledLookAndFeels();
            try {
                UIManager.setLookAndFeel(installedLF[0].getClassName());
            } catch (Exception e2) {
                log.error("Unable to load any L&F, exiting", e2);
                System.exit(-1);
            }
        }
        try {
            log.debug("attempting to update componenttreeui");
            SwingUtilities.updateComponentTreeUI(this.getContentPane());
        } catch (Exception swe) {
            log.error("Unable to update component tree", swe);
        }
    }
    pack();
    //Might be the cause of occasional NullpointEx due to system
    //not being able to locate LookAndFeel
}

From source file:JXTransformer.java

private void setLaf(String laf) {
        try {//from w w  w .  j  av a 2s  .c  o m
            UIManager.setLookAndFeel(laf);
            SwingUtilities.updateComponentTreeUI(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
        for (JXTransformer t : transformers) {
            t.revalidate();
            t.repaint();
        }
    }