Example usage for javax.swing UIManager getInstalledLookAndFeels

List of usage examples for javax.swing UIManager getInstalledLookAndFeels

Introduction

In this page you can find the example usage for javax.swing UIManager getInstalledLookAndFeels.

Prototype

public static LookAndFeelInfo[] getInstalledLookAndFeels() 

Source Link

Document

Returns an array of LookAndFeelInfo s representing the LookAndFeel implementations currently available.

Usage

From source file:accinapdf.ACCinaPDF.java

/**
 * @param args the command line arguments
 *//*from www .  j  a  v  a  2s.c  om*/
public static void main(String[] args) {

    controller.Logger.create();
    controller.Bundle.getBundle();

    if (GraphicsEnvironment.isHeadless()) {
        // Headless
        // Erro 
        String fich;
        if (args.length != 1) {
            System.err.println(Bundle.getBundle().getString("invalidArgs"));
            return;
        } else {
            fich = args[0];
        }

        try {
            System.out.println(Bundle.getBundle().getString("validating") + " " + fich);
            ArrayList<SignatureValidation> alSv = CCInstance.getInstance().validatePDF(fich, null);
            if (alSv.isEmpty()) {
                System.out.println(Bundle.getBundle().getString("notSigned"));
            } else {
                String newLine = System.getProperty("line.separator");
                String toWrite = "(";
                int numSigs = alSv.size();
                if (numSigs == 1) {
                    toWrite += "1 " + Bundle.getBundle().getString("signature");
                } else {
                    toWrite += numSigs + " " + Bundle.getBundle().getString("signatures");
                }
                toWrite += ")" + newLine;
                for (SignatureValidation sv : alSv) {
                    toWrite += "\t" + sv.getName() + " - ";
                    toWrite += (sv.isCertification()
                            ? WordUtils.capitalize(Bundle.getBundle().getString("certificate"))
                            : WordUtils.capitalize(Bundle.getBundle().getString("signed"))) + " "
                            + Bundle.getBundle().getString("by") + " " + sv.getSignerName();
                    toWrite += newLine + "\t\t";
                    if (sv.isChanged()) {
                        toWrite += Bundle.getBundle().getString("certifiedChangedOrCorrupted");
                    } else {
                        if (sv.isCertification()) {
                            if (sv.isValid()) {
                                if (sv.isChanged() || !sv.isCoversEntireDocument()) {
                                    toWrite += Bundle.getBundle().getString("certifiedButChanged");
                                } else {
                                    toWrite += Bundle.getBundle().getString("certifiedOk");
                                }
                            } else {
                                toWrite += Bundle.getBundle().getString("changedAfterCertified");
                            }
                        } else {
                            if (sv.isValid()) {
                                if (sv.isChanged()) {
                                    toWrite += Bundle.getBundle().getString("signedButChanged");
                                } else {
                                    toWrite += Bundle.getBundle().getString("signedOk");
                                }
                            } else {
                                toWrite += Bundle.getBundle().getString("signedChangedOrCorrupted");
                            }
                        }
                    }
                    toWrite += newLine + "\t\t";
                    if (sv.getOcspCertificateStatus().equals(CertificateStatus.OK)
                            || sv.getCrlCertificateStatus().equals(CertificateStatus.OK)) {
                        toWrite += Bundle.getBundle().getString("certOK");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.REVOKED)
                            || sv.getCrlCertificateStatus().equals(CertificateStatus.REVOKED)) {
                        toWrite += Bundle.getBundle().getString("certRevoked");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHECKED)
                            && sv.getCrlCertificateStatus().equals(CertificateStatus.UNCHECKED)) {
                        toWrite += Bundle.getBundle().getString("certNotVerified");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHAINED)) {
                        toWrite += Bundle.getBundle().getString("certNotChained");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.EXPIRED)) {
                        toWrite += Bundle.getBundle().getString("certExpired");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.CHAINED_LOCALLY)) {
                        toWrite += Bundle.getBundle().getString("certChainedLocally");
                    }
                    toWrite += newLine + "\t\t";
                    if (sv.isValidTimeStamp()) {
                        toWrite += Bundle.getBundle().getString("validTimestamp");
                    } else {
                        toWrite += Bundle.getBundle().getString("signerDateTime");
                    }
                    toWrite += newLine + "\t\t";

                    toWrite += WordUtils.capitalize(Bundle.getBundle().getString("revision")) + ": "
                            + sv.getRevision() + " " + Bundle.getBundle().getString("of") + " "
                            + sv.getNumRevisions();
                    toWrite += newLine + "\t\t";
                    final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                    final SimpleDateFormat sdf = new SimpleDateFormat("Z");
                    if (sv.getSignature().getTimeStampToken() == null) {
                        Calendar cal = sv.getSignature().getSignDate();
                        String date = sdf.format(cal.getTime().toLocaleString());
                        toWrite += date + " " + sdf.format(cal.getTime()) + " ("
                                + Bundle.getBundle().getString("signerDateTimeSmall") + ")";
                    } else {
                        Calendar ts = sv.getSignature().getTimeStampDate();
                        String date = df.format(ts.getTime());
                        toWrite += Bundle.getBundle().getString("date") + " " + date + " "
                                + sdf.format(ts.getTime());
                    }
                    toWrite += newLine + "\t\t";
                    boolean ltv = (sv.getOcspCertificateStatus() == CertificateStatus.OK
                            || sv.getCrlCertificateStatus() == CertificateStatus.OK);
                    toWrite += Bundle.getBundle().getString("isLtv") + ": "
                            + (ltv ? Bundle.getBundle().getString("yes") : Bundle.getBundle().getString("no"));
                    String reason = sv.getSignature().getReason();
                    toWrite += newLine + "\t\t";
                    toWrite += Bundle.getBundle().getString("reason") + ": ";
                    if (reason == null) {
                        toWrite += Bundle.getBundle().getString("notDefined");
                    } else if (reason.isEmpty()) {
                        toWrite += Bundle.getBundle().getString("notDefined");
                    } else {
                        toWrite += reason;
                    }
                    String location = sv.getSignature().getLocation();
                    toWrite += newLine + "\t\t";
                    toWrite += Bundle.getBundle().getString("location") + ": ";
                    if (location == null) {
                        toWrite += Bundle.getBundle().getString("notDefined");
                    } else if (location.isEmpty()) {
                        toWrite += Bundle.getBundle().getString("notDefined");
                    } else {
                        toWrite += location;
                    }
                    toWrite += newLine + "\t\t";
                    toWrite += Bundle.getBundle().getString("allowsChanges") + ": ";
                    try {
                        int certLevel = CCInstance.getInstance().getCertificationLevel(sv.getFilename());
                        if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING) {
                            toWrite += Bundle.getBundle().getString("onlyAnnotations");
                        } else if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS) {
                            toWrite += Bundle.getBundle().getString("annotationsFormFilling");
                        } else if (certLevel == PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED) {
                            toWrite += Bundle.getBundle().getString("no");
                        } else {
                            toWrite += Bundle.getBundle().getString("yes");
                        }
                    } catch (IOException ex) {
                        controller.Logger.getLogger().addEntry(ex);
                    }
                    toWrite += newLine + "\t\t";
                    if (sv.getOcspCertificateStatus() == CertificateStatus.OK
                            || sv.getCrlCertificateStatus() == CertificateStatus.OK) {
                        toWrite += (Bundle.getBundle().getString("validationCheck1") + " "
                                + (sv.getOcspCertificateStatus() == CertificateStatus.OK
                                        ? Bundle.getBundle().getString("validationCheck2") + ": "
                                                + CCInstance.getInstance().getCertificateProperty(
                                                        sv.getSignature().getOcsp().getCerts()[0].getSubject(),
                                                        "CN")
                                                + " " + Bundle.getBundle().getString("at") + " "
                                                + df.format(sv.getSignature().getOcsp().getProducedAt())
                                        : (sv.getCrlCertificateStatus() == CertificateStatus.OK ? "CRL" : ""))
                                + (sv.getSignature().getTimeStampToken() != null
                                        ? Bundle.getBundle().getString("validationCheck3") + ": "
                                                + CCInstance.getInstance()
                                                        .getCertificateProperty(sv.getSignature()
                                                                .getTimeStampToken().getSID().getIssuer(), "O")
                                        : ""));
                    } else if (sv.getSignature().getTimeStampToken() != null) {
                        toWrite += (Bundle.getBundle().getString("validationCheck3") + ": "
                                + CCInstance.getInstance().getCertificateProperty(
                                        sv.getSignature().getTimeStampToken().getSID().getIssuer(), "O"));
                    }
                    toWrite += newLine;
                }

                System.out.println(toWrite);
                System.out.println(Bundle.getBundle().getString("validationFinished"));
            }
        } catch (IOException | DocumentException | GeneralSecurityException ex) {
            System.err.println(Bundle.getBundle().getString("validationError"));
            Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex);
        }

    } else {
        // GUI
        CCSignatureSettings defaultSettings = new CCSignatureSettings(false);
        if (SystemUtils.IS_OS_WINDOWS) {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    try {
                        UIManager.setLookAndFeel(info.getClassName());
                    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                            | UnsupportedLookAndFeelException ex) {
                        Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    break;
                }
            }
        } else if (SystemUtils.IS_OS_LINUX) {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    try {
                        UIManager.setLookAndFeel(info.getClassName());
                    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                            | UnsupportedLookAndFeelException ex) {
                        Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    break;
                }
            }
        } else if (SystemUtils.IS_OS_MAC_OSX) {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.mac.MacLookAndFeel");
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                    | UnsupportedLookAndFeelException ex) {
                Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        new SplashScreen().setVisible(true);
    }
}

From source file:DesktopManagerDemo.java

public DesktopManagerDemo() {
    setTitle("Animated DesktopManager");
    m_count = m_tencount = 0;/*  w  ww. java  2 s.  com*/

    JPanel innerListenerPanel = new JPanel(new GridLayout(15, 1));
    JPanel listenerPanel = new JPanel(new BorderLayout());
    m_dmEventCanvas = new DMEventCanvas();

    m_lActivates = new JLabel("activateFrame");
    m_lBegindrags = new JLabel("beginDraggingFrame");
    m_lBeginresizes = new JLabel("beginResizingFrame");
    m_lCloses = new JLabel("closeFrame");
    m_lDeactivates = new JLabel("deactivateFrame");
    m_lDeiconifies = new JLabel("deiconifyFrame");
    m_lDrags = new JLabel("dragFrame");
    m_lEnddrags = new JLabel("endDraggingFrame");
    m_lEndresizes = new JLabel("endResizingFrame");
    m_lIconifies = new JLabel("iconifyFrame");
    m_lMaximizes = new JLabel("maximizeFrame");
    m_lMinimizes = new JLabel("minimizeFrame");
    m_lOpens = new JLabel("openFrame");
    m_lResizes = new JLabel("resizeFrame");
    m_lSetbounds = new JLabel("setBoundsForFrame");

    innerListenerPanel.add(m_lActivates);
    innerListenerPanel.add(m_lBegindrags);
    innerListenerPanel.add(m_lBeginresizes);
    innerListenerPanel.add(m_lCloses);
    innerListenerPanel.add(m_lDeactivates);
    innerListenerPanel.add(m_lDeiconifies);
    innerListenerPanel.add(m_lDrags);
    innerListenerPanel.add(m_lEnddrags);
    innerListenerPanel.add(m_lEndresizes);
    innerListenerPanel.add(m_lIconifies);
    innerListenerPanel.add(m_lMaximizes);
    innerListenerPanel.add(m_lMinimizes);
    innerListenerPanel.add(m_lOpens);
    innerListenerPanel.add(m_lResizes);
    innerListenerPanel.add(m_lSetbounds);

    listenerPanel.add("Center", m_dmEventCanvas);
    listenerPanel.add("West", innerListenerPanel);
    listenerPanel.setOpaque(true);
    listenerPanel.setBackground(Color.white);

    m_myDesktopManager = new MyDesktopManager();
    m_desktop = new JDesktopPane();
    m_desktop.setDesktopManager(m_myDesktopManager);
    m_desktop.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
    m_newFrame = new JButton("New Frame");
    m_newFrame.addActionListener(this);
    m_infos = UIManager.getInstalledLookAndFeels();
    String[] LAFNames = new String[m_infos.length];
    for (int i = 0; i < m_infos.length; i++) {
        LAFNames[i] = m_infos[i].getName();
    }
    m_UIBox = new JComboBox(LAFNames);
    m_UIBox.addActionListener(this);
    JPanel topPanel = new JPanel(true);
    topPanel.setLayout(new FlowLayout());
    topPanel.setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED),
            new CompoundBorder(new EmptyBorder(2, 2, 2, 2), new SoftBevelBorder(BevelBorder.RAISED))));
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add("North", topPanel);
    getContentPane().add("Center", m_desktop);
    getContentPane().add("South", listenerPanel);
    ((JPanel) getContentPane()).setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED),
            new CompoundBorder(new EmptyBorder(1, 1, 1, 1), new SoftBevelBorder(BevelBorder.RAISED))));
    topPanel.add(m_newFrame);
    topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT));
    topPanel.add(m_UIBox);
    setSize(645, 600);
    Dimension dim = getToolkit().getScreenSize();
    setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2);
    setVisible(true);
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);
    m_eventTimer = new Timer(1000, this);
    m_eventTimer.setRepeats(true);
    m_eventTimer.start();
}

From source file:Data.java

/**
 * @param args the command line arguments
 *//*from   w w w .  j  a va  2  s  . c  o m*/
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Data.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Data.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Data.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Data.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                new Data().setVisible(true);
            } catch (ClassNotFoundException | IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
}

From source file:ShowComponent.java

/**
 * This static method queries the system to find out what Pluggable
 * Look-and-Feel (PLAF) implementations are available. Then it creates a
 * JMenu component that lists each of the implementations by name and allows
 * the user to select one of them using JRadioButtonMenuItem components.
 * When the user selects one, the selected menu item traverses the component
 * hierarchy and tells all components to use the new PLAF.
 *//*  www .ja va 2  s.com*/
public static JMenu createPlafMenu(final JFrame frame) {
    // Create the menu
    JMenu plafmenu = new JMenu("Look and Feel");

    // Create an object used for radio button mutual exclusion
    ButtonGroup radiogroup = new ButtonGroup();

    // Look up the available look and feels
    UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels();

    // Loop through the plafs, and add a menu item for each one
    for (int i = 0; i < plafs.length; i++) {
        String plafName = plafs[i].getName();
        final String plafClassName = plafs[i].getClassName();

        // Create the menu item
        JMenuItem item = plafmenu.add(new JRadioButtonMenuItem(plafName));

        // Tell the menu item what to do when it is selected
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    // Set the new look and feel
                    UIManager.setLookAndFeel(plafClassName);
                    // Tell each component to change its look-and-feel
                    SwingUtilities.updateComponentTreeUI(frame);
                    // Tell the frame to resize itself to the its
                    // children's new desired sizes
                    frame.pack();
                } catch (Exception ex) {
                    System.err.println(ex);
                }
            }

        });

        // Only allow one menu item to be selected at once
        radiogroup.add(item);
    }
    return plafmenu;
}

From source file:burlov.ultracipher.swing.SwingGuiApplication.java

static void initLAF() {
    try {/* w  ww. ja v  a  2s. co  m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:net.sf.firemox.Magic.java

/**
 * Creates new form Magic//from   w w w  .  j  a va 2s. c o m
 */
private Magic() {
    super();
    initComponents();

    // list all installed Look&Feel
    UIListener uiListener = new UIListener();
    UIManager.LookAndFeelInfo[] uimTMP = UIManager.getInstalledLookAndFeels();
    final List<Pair<String, String>> lfList = new ArrayList<Pair<String, String>>();
    for (LookAndFeelInfo lookAndFeel : uimTMP) {
        Pair<String, String> info = new Pair<String, String>(lookAndFeel.getName(), lookAndFeel.getClassName());
        if (!lfList.contains(info)) {
            lfList.add(info);
        }
    }

    // list all SkinLF themes
    final File[] themes = MToolKit.getFile("lib").listFiles(new FileFilter() {
        public boolean accept(File f) {
            return f != null && f.getName().endsWith(".zip");
        }
    });

    int maxIndex = Configuration.getConfiguration().getMaxIndex("themes.skinlf.caches.cache");
    List<Pair<String, String>> knownThemes = new ArrayList<Pair<String, String>>();
    for (int i = 0; i < maxIndex + 1; i++) {
        String file = Configuration.getConfiguration()
                .getString("themes.skinlf.caches.cache(" + i + ").[@file]");
        int index = ArrayUtils.indexOf(themes, MToolKit.getFile(file));
        if (index >= 0) {
            themes[index] = null;
            Pair<String, String> skin = new Pair<String, String>(
                    Configuration.getConfiguration().getString("themes.skinlf.caches.cache(" + i + ").[@name]"),
                    file);
            knownThemes.add(skin);
            lfList.add(skin);
        }
    }

    for (File theme : themes) {
        if (theme != null) {
            // a new theme --> will be cached
            try {
                final List<Node> properties = new XmlParser().parse(new ZipResourceLoader(theme.toURI().toURL())
                        .getResourceAsStream("skinlf-themepack.xml")).getNodes("property");
                PROPERTIES: for (int j = 0; j < properties.size(); j++) {
                    if ("skin.name".equals(properties.get(j).getAttribute("name"))) {
                        // skin name found
                        String relativePath = MToolKit.getRelativePath(theme.getCanonicalPath());
                        Pair<String, String> skin = new Pair<String, String>(
                                properties.get(j).getAttribute("value"), "zip:" + relativePath);
                        lfList.add(skin);
                        knownThemes.add(new Pair<String, String>(properties.get(j).getAttribute("value"),
                                relativePath));
                        break PROPERTIES;
                    }
                }
            } catch (Exception e) {
                Log.error("Error in " + theme, e);
            }
        }
    }

    Configuration.getConfiguration().clearProperty("themes.skinlf.caches");
    for (int index = 0; index < knownThemes.size(); index++) {
        Pair<String, String> skin = knownThemes.get(index);
        Configuration.getConfiguration().setProperty("themes.skinlf.caches.cache(" + index + ").[@name]",
                skin.key);
        Configuration.getConfiguration().setProperty("themes.skinlf.caches.cache(" + index + ").[@file]",
                skin.value);
    }

    // create look and feel menu items
    Collections.sort(lfList);
    lookAndFeels = new JRadioButtonMenuItem[lfList.size() + 1];
    ButtonGroup group5 = new ButtonGroup();
    for (int i = 0; i < lfList.size(); i++) {
        final String lfName = lfList.get(i).key;
        final String lfClassName = lfList.get(i).value;
        lookAndFeels[i] = new JRadioButtonMenuItem(lfName);
        if (lookAndFeelName.equalsIgnoreCase(lfClassName)) {
            // this the current l&f
            lookAndFeels[i].setSelected(true);
        }
        if (!SkinLF.isSkinLF(lfClassName)) {
            lookAndFeels[i].setEnabled(MToolKit.isAvailableLookAndFeel(lfClassName));
        }
        group5.add(lookAndFeels[i]);
        lookAndFeels[i].setActionCommand(lfClassName);
        themeMenu.add(lookAndFeels[i], i);
        lookAndFeels[i].addActionListener(uiListener);
    }
    lfList.clear();

    initialdelayMenu.addActionListener(this);
    dismissdelayMenu.addActionListener(this);

    ConnectionManager.enableConnectingTools(false);

    // read auto mana option
    MCommonVars.autoMana = Configuration.getBoolean("automana", true);
    autoManaMenu.setSelected(MCommonVars.autoMana);

    // Force to initialize the TBS settings
    MToolKit.tbsName = null;
    setMdb(Configuration.getString("lastTBS", IdConst.TBS_DEFAULT));

    // set the autoStack mode
    MCommonVars.autoStack = Configuration.getBoolean("autostack", false);
    autoPlayMenu.setSelected(MCommonVars.autoStack);

    // read maximum displayed colored mana in context
    PayMana.thresholdColored = Configuration.getInt("threshold-colored", 6);

    ZoneManager.updateLookAndFeel();

    // pack this frame
    pack();

    // Maximize this frame
    setExtendedState(Frame.MAXIMIZED_BOTH);

    if (batchMode != -1) {

        final String deckFile = Configuration.getString(Configuration.getString("decks.deck(0)"));
        try {
            Deck batchDeck = DeckReader.getDeck(this, deckFile);
            switch (batchMode) {
            case BATCH_SERVER:
                ConnectionManager.server = new Server(batchDeck, null);
                ConnectionManager.server.start();
                break;
            case BATCH_CLIENT:
                ConnectionManager.client = new Client(batchDeck, null);
                ConnectionManager.client.start();
                break;
            default:
            }
        } catch (Throwable e) {
            throw new RuntimeException("Error in batch mode : ", e);
        }
    }
}

From source file:com.googlecode.logVisualizer.LogVisualizer.java

private LogVisualizer() {
    try {/*  w  w  w. j av  a 2 s  .c o  m*/
        final String wantedLaf = Settings.getSettingString("LookAndFeel");
        LookAndFeelInfo usedLaf = null;
        for (final LookAndFeelInfo lafi : UIManager.getInstalledLookAndFeels())
            if (lafi.getName().equals(wantedLaf)) {
                usedLaf = lafi;
                break;
            }

        if (usedLaf != null)
            UIManager.setLookAndFeel(usedLaf.getClassName());
        else
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (final Exception e) {
        e.printStackTrace();
    }

    gui = new LogVisualizerGUI(new LogLoaderListener() {
        public void loadMafiaLog(final File file) {
            loadLog(file, new MafiaLogParser(file, Settings.getSettingBoolean("Include mafia log notes")));
        }

        public void loadPreparsedLog(final File file) {
            loadLog(file, new PreparsedLogParser(file));
        }

        public void loadXMLLog(final File file) {
            try {
                final LogDataHolder logData = XMLLogReader.parseXMLLog(file);
                addLogGUI(file, logData);
            } catch (final FileAccessException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(gui, "A problem occurred while reading the file.",
                        "Error occurred", JOptionPane.ERROR_MESSAGE);
            } catch (final XMLAccessException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(gui, "A problem occurred while parsing the XML.",
                        "Error occurred", JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    gui.setSize(800, 600);
    RefineryUtilities.centerFrameOnScreen(gui);
    gui.setVisible(true);

    if (Settings.getSettingBoolean("First program startup")) {
        final JLabel text = new JLabel(
                "<html>Note that <b>for the purpose of logging your own runs with KolMafia, it is best</b> to "
                        + "turn on all options but <i>Log adventures left instead of adventures used</i> under "
                        + "<i>General->Preferences->Session Logs</i> in KolMafia."
                        + "<br><br><br>This informational popup will only be displayed this once.</html>");
        text.setPreferredSize(new Dimension(550, 100));
        JOptionPane.showMessageDialog(gui, text, "KolMafia logging options", JOptionPane.INFORMATION_MESSAGE);

        Settings.setSettingBoolean("First program startup", false);
    }

    if (Settings.getSettingBoolean("Check Updates"))
        new Thread(new Runnable() {
            public void run() {
                if (ProjectUpdateViewer.isNewerVersionUploaded())
                    EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            UpdateDialog.showDialog(gui);
                        }
                    });
            }
        }).start();
}

From source file:eu.europa.ec.markt.dss.applet.SignatureApplet.java

@Override
public void init() {
    String lang = getParameter("lang");
    if ("nl".equals(lang)) {
        java.util.Locale.setDefault(new java.util.Locale("nl", "NL"));
    } else {/*  www . j av a2 s . c o  m*/
        java.util.Locale.setDefault(new java.util.Locale("en", "EN"));
    }
    BACK_TEXT = getResourceString("BACK");
    NEXT_TEXT = getResourceString("NEXT");
    FINISH_TEXT = getResourceString("FINISH");
    CANCEL_TEXT = getResourceString("CANCEL");

    super.init();

    model.setServiceUrl(getParameter("serviceUrl"));

    if (getParameter("pkcs12File") != null) {
        model.setPkcs12FilePath(getParameter("pkcs12File"));
    }

    if (getParameter("pkcs11Library") != null) {
        model.setPkcs11LibraryPath(getParameter("pkcs11Library"));
    }

    if (getParameter(PRECONFIGURED_TOKEN_TYPE) != null) {
        SignatureTokenType type = SignatureTokenType.valueOf(getParameter(PRECONFIGURED_TOKEN_TYPE));
        model.setTokenType(type);
        model.setPreconfiguredTokenType(true);
    }

    if (getParameter(SIGNATURE_POLICY) != null) {
        String value = getParameter(SIGNATURE_POLICY);
        if (SignaturePolicy.IMPLICIT.equals(value)) {
            model.setSignaturePolicyType(SignaturePolicy.IMPLICIT);
        } else {
            model.setSignaturePolicyType(SignaturePolicy.EXPLICIT);
            model.setSignaturePolicy(value);
            model.setSignaturePolicyAlgo(getParameter(SIGNATURE_POLICY_ALGO));
            model.setSignaturePolicyValue(Base64.decodeBase64(getParameter(SIGNATURE_POLICY_HASH)));
        }
    }

    if (getParameter(STRICT_RFC3370) != null) {
        String value = getParameter(STRICT_RFC3370);
        try {
            model.setStrictRFC3370Compliance(Boolean.parseBoolean(value));
        } catch (Exception ex) {
            LOG.warning(
                    "Invalid value of " + STRICT_RFC3370 + " stick to " + model.isStrictRFC3370Compliance());
        }
    }

    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if (info.getName().equals("Nimbus")) {
                UIManager.setLookAndFeel(info.getClassName());
                SwingUtilities.updateComponentTreeUI(this);
            }
        }
    } catch (Exception exception) {
        LOG.warning("Look and feel Nimbus cannot be installed");
    }

    String usage = getParameter("usage");
    if (usage == null) {
        usage = "all";
    }

    if (usage.equalsIgnoreCase("all")) {
        registerWizardPanel(new ActivityPanel(model));

        registerWizardPanel(new SelectDocumentForSignaturePanel(model));
        registerWizardPanel(new ChooseSignaturePanel(model));
        registerWizardPanel(new SignatureTokenAPIPanel(model));
        registerWizardPanel(new PKCS11ParamsPanel(model));
        registerWizardPanel(new PKCS12ParamsPanel(model));
        registerWizardPanel(new MOCCAParamsPanel(model));
        registerWizardPanel(new ChooseCertificatePanel(model));
        registerWizardPanel(new PersonalDataPanel(model));
        registerWizardPanel(new SaveDocumentPanel(model));
        registerWizardPanel(new WizardFinishedPanel(model));

        registerWizardPanel(new SelectDocumentForVerificationPanel(model));
        registerWizardPanel(new SignatureValidationReportPanel(model));

        registerWizardPanel(new SelectDocumentForExtensionPanel(model));

        setInitialPanel(ActivityPanel.ID);
        setCurrentPanel(ActivityPanel.ID, true);
    } else if (usage.equalsIgnoreCase("sign")) {
        registerWizardPanel(new SelectDocumentForSignaturePanel(model));
        registerWizardPanel(new ChooseSignaturePanel(model));
        registerWizardPanel(new SignatureTokenAPIPanel(model));
        registerWizardPanel(new PKCS11ParamsPanel(model));
        registerWizardPanel(new PKCS12ParamsPanel(model));
        registerWizardPanel(new MOCCAParamsPanel(model));
        registerWizardPanel(new ChooseCertificatePanel(model));
        registerWizardPanel(new PersonalDataPanel(model));
        registerWizardPanel(new SaveDocumentPanel(model));
        registerWizardPanel(new WizardFinishedPanel(model));

        setInitialPanel(SelectDocumentForSignaturePanel.ID);
        setCurrentPanel(SelectDocumentForSignaturePanel.ID, true);

        model.setWizardUsage(WizardUsage.SIGN);
        model.setUsageParameterFound(true);
        setNextFinishButtonEnabled(true);
    } else if (!isUsageParameterValid(usage) || usage.equalsIgnoreCase("verify")) {
        registerWizardPanel(new SelectDocumentForVerificationPanel(model));
        registerWizardPanel(new SignatureValidationReportPanel(model));

        setInitialPanel(SelectDocumentForVerificationPanel.ID);
        setCurrentPanel(SelectDocumentForVerificationPanel.ID, true);

        model.setWizardUsage(WizardUsage.VERIFY);
        model.setUsageParameterFound(true);
        setNextFinishButtonEnabled(true);
    } else if (usage.equalsIgnoreCase("extend")) {
        registerWizardPanel(new SelectDocumentForExtensionPanel(model));

        setInitialPanel(SelectDocumentForExtensionPanel.ID);
        setCurrentPanel(SelectDocumentForExtensionPanel.ID, true);

        model.setWizardUsage(WizardUsage.EXTEND);
        model.setUsageParameterFound(true);
        setNextFinishButtonEnabled(true);
    }

    registerWizardPanel(new ErrorPanel(model));

    setFinishedId(WizardFinishedPanel.ID);

    setErrorPanel(ErrorPanel.ID);
}

From source file:de.codesourcery.eve.skills.ui.Main.java

protected static void setLookAndFeel() {

    LookAndFeelInfo newLandF = null;/*  w ww.j av  a2  s. co m*/
    for (LookAndFeelInfo lf : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(lf.getName())) {
            newLandF = lf;
            break;
        }
    }

    if (newLandF != null) {
        try {
            UIManager.setLookAndFeel(newLandF.getClassName());
        } catch (Exception e) {
            log.error("setLookAndFeel(): Failed to change look and feel", e);
        }
    } else {
        log.info("setLookAndFeel(): L&F 'Nimbus' not available, using default.");
    }
}

From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java

private JMenu createViewMenu() {
    JMenu viewMenu = new JMenu("View");
    viewMenu.setMnemonic('v');

    JMenu lnfMenu = new JMenu("Look and Feel");
    lnfMenu.setMnemonic('f');

    ButtonGroup lnfGroup = new ButtonGroup();
    LookAndFeelInfo lnfs[] = UIManager.getInstalledLookAndFeels();
    String lnfCurrentName = null;
    LookAndFeel lnfCurrent = UIManager.getLookAndFeel();
    if (lnfCurrent != null) {
        lnfCurrentName = lnfCurrent.getClass().getName();
    }/*  w w w.j  a v  a  2s  .  co  m*/
    UISwitcher switcher = new UISwitcher();
    for (int i = 0; i < lnfs.length; i++) {
        JRadioButtonMenuItem lnfItem = new JRadioButtonMenuItem(lnfs[i].getName());
        lnfItem.addActionListener(switcher);
        lnfItem.setActionCommand(lnfs[i].getClassName());
        lnfGroup.add(lnfItem);
        lnfMenu.add(lnfItem);

        if (lnfs[i].getClassName().equals(lnfCurrentName)) {
            lnfGroup.setSelected(lnfItem.getModel(), true);
        }
    }
    viewMenu.add(lnfMenu);

    return viewMenu;
}