Example usage for javax.swing JTextPane JTextPane

List of usage examples for javax.swing JTextPane JTextPane

Introduction

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

Prototype

public JTextPane() 

Source Link

Document

Creates a new JTextPane.

Usage

From source file:org.interreg.docexplore.ServerConfigPanel.java

public ServerConfigPanel(final File config, final File serverDir) throws Exception {
    super(new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));

    this.serverDir = serverDir;
    this.books = new Vector<Book>();
    this.bookList = new JList(new DefaultListModel());

    JPanel listPanel = new JPanel(new BorderLayout());
    listPanel.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBooksLabel")));
    bookList.setOpaque(false);/*from w  ww.j  a  va  2s .  co m*/
    bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    bookList.setCellRenderer(new ListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            Book book = (Book) value;
            JLabel label = new JLabel("<html><b>" + book.name + "</b> - " + book.nPages + " pages</html>");
            label.setOpaque(true);
            if (isSelected) {
                label.setBackground(TextToolbar.styleHighLightedBackground);
                label.setForeground(Color.white);
            }
            if (book.deleted)
                label.setForeground(Color.red);
            else if (!book.used)
                label.setForeground(Color.gray);
            return label;
        }
    });
    bookList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting())
                return;
            setFields((Book) bookList.getSelectedValue());
        }
    });
    JScrollPane scrollPane = new JScrollPane(bookList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    listPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel importPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    importPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgImportLabel")) {
        public void actionPerformed(ActionEvent e) {
            final File inFile = DocExploreTool.getFileDialogs().openFile(DocExploreTool.getIBookCategory());
            if (inFile == null)
                return;

            try {
                final File tmpDir = new File(serverDir, "tmp");
                tmpDir.mkdir();

                GuiUtils.blockUntilComplete(new ProgressRunnable() {
                    float[] progress = { 0 };

                    public void run() {
                        try {
                            ZipUtils.unzip(inFile, tmpDir, progress);
                        } catch (Exception ex) {
                            ErrorHandler.defaultHandler.submit(ex);
                        }
                    }

                    public float getProgress() {
                        return (float) progress[0];
                    }
                }, ServerConfigPanel.this);

                File tmpFile = new File(tmpDir, "index.tmp");
                ObjectInputStream input = new ObjectInputStream(new FileInputStream(tmpFile));
                String bookFile = input.readUTF();
                String bookName = input.readUTF();
                String bookDesc = input.readUTF();
                input.close();

                new PresentationImporter().doImport(ServerConfigPanel.this, bookName, bookDesc,
                        new File(tmpDir, bookFile));
                FileUtils.cleanDirectory(tmpDir);
                FileUtils.deleteDirectory(tmpDir);
                updateBooks();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    }));
    listPanel.add(importPanel, BorderLayout.SOUTH);
    add(listPanel);

    JPanel setupPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));
    setupPanel.setBorder(
            BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBookInfoLabel")));
    usedBox = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseLabel"));
    usedBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book != null) {
                book.used = usedBox.isSelected();
                bookList.repaint();
            }
        }
    });
    setupPanel.add(usedBox);

    JPanel fieldPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT,
            SwingConstants.TOP, true, false));
    fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTitleLabel")));
    nameField = new JTextField(50);
    nameField.getDocument().addDocumentListener(new DocumentListener() {
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void changedUpdate(DocumentEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.name = nameField.getText();
            bookList.repaint();
        }
    });
    fieldPanel.add(nameField);

    fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDescriptionLabel")));
    descField = new JTextPane();
    //descField.setWrapStyleWord(true);
    descField.getDocument().addDocumentListener(new DocumentListener() {
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void changedUpdate(DocumentEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.desc = descField.getText();
        }
    });
    scrollPane = new JScrollPane(descField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(420, 50));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    fieldPanel.add(scrollPane);

    setupPanel.add(fieldPanel);

    exportButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgExportLabel")) {
        public void actionPerformed(ActionEvent e) {
            File file = DocExploreTool.getFileDialogs().saveFile(DocExploreTool.getIBookCategory());
            if (file == null)
                return;
            final Book book = (Book) bookList.getSelectedValue();
            final File indexFile = new File(serverDir, "index.tmp");
            try {
                final File outFile = file;
                ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(indexFile));
                out.writeUTF(book.bookFile.getName());
                out.writeUTF(book.name);
                out.writeUTF(book.desc);
                out.close();

                GuiUtils.blockUntilComplete(new ProgressRunnable() {
                    float[] progress = { 0 };

                    public void run() {
                        try {
                            ZipUtils.zip(serverDir, new File[] { indexFile, book.bookFile, book.bookDir },
                                    outFile, progress, 0, 1, 9);
                        } catch (Exception ex) {
                            ErrorHandler.defaultHandler.submit(ex);
                        }
                    }

                    public float getProgress() {
                        return (float) progress[0];
                    }
                }, ServerConfigPanel.this);
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
            if (indexFile.exists())
                indexFile.delete();
        }
    });
    deleteButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgDeleteRestoreLabel")) {
        public void actionPerformed(ActionEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.deleted = !book.deleted;
            bookList.repaint();
        }
    });

    JPanel actionsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    actionsPanel.add(exportButton);
    actionsPanel.add(deleteButton);
    setupPanel.add(actionsPanel);

    add(setupPanel);

    JPanel optionsPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT,
            SwingConstants.TOP, true, false));
    optionsPanel
            .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgOptionsLabel")));
    JPanel timeoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    timeoutField = new JTextField(5);
    timeoutPanel.add(timeoutField);
    timeoutPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTimeoutLabel")));
    optionsPanel.add(timeoutPanel);
    add(optionsPanel);

    updateBooks();
    setFields(null);

    final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>";
    String idle = StringUtils.getTagContent(xml, "idle");
    if (idle != null)
        try {
            timeoutField.setText("" + Integer.parseInt(idle));
        } catch (Throwable e) {
        }
}

From source file:org.languagetool.gui.Main.java

private void createGUI() {
    loadRecentFiles();//  ww  w  . ja  v a2s. c o  m
    frame = new JFrame("LanguageTool " + JLanguageTool.VERSION);

    setLookAndFeel();
    openAction = new OpenAction();
    saveAction = new SaveAction();
    saveAsAction = new SaveAsAction();
    checkAction = new CheckAction();
    autoCheckAction = new AutoCheckAction(true);
    showResultAction = new ShowResultAction(true);

    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new CloseListener());
    URL iconUrl = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(TRAY_ICON);
    frame.setIconImage(new ImageIcon(iconUrl).getImage());

    textArea = new JTextArea();
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.addKeyListener(new ControlReturnTextCheckingListener());

    textLineNumber = new TextLineNumber(textArea, 2);
    numberedTextAreaPane = new JScrollPane(textArea);
    numberedTextAreaPane.setRowHeaderView(textLineNumber);

    resultArea = new JTextPane();
    undoRedo = new UndoRedoSupport(this.textArea, messages);
    frame.setJMenuBar(createMenuBar());

    GridBagConstraints buttonCons = new GridBagConstraints();

    JPanel insidePanel = new JPanel();
    insidePanel.setOpaque(false);
    insidePanel.setLayout(new GridBagLayout());

    buttonCons.gridx = 0;
    buttonCons.gridy = 0;
    buttonCons.anchor = GridBagConstraints.LINE_START;
    insidePanel.add(new JLabel(messages.getString("textLanguage") + " "), buttonCons);

    //create a ComboBox with flags, do not include hidden languages
    languageBox = LanguageComboBox.create(messages, EXTERNAL_LANGUAGE_SUFFIX, true, false);
    buttonCons.gridx = 1;
    buttonCons.gridy = 0;
    buttonCons.anchor = GridBagConstraints.LINE_START;
    insidePanel.add(languageBox, buttonCons);

    JCheckBox autoDetectBox = new JCheckBox(messages.getString("atd"));
    buttonCons.gridx = 2;
    buttonCons.gridy = 0;
    buttonCons.gridwidth = GridBagConstraints.REMAINDER;
    buttonCons.anchor = GridBagConstraints.LINE_START;
    insidePanel.add(autoDetectBox, buttonCons);

    buttonCons.gridx = 0;
    buttonCons.gridy = 1;
    buttonCons.gridwidth = GridBagConstraints.REMAINDER;
    buttonCons.fill = GridBagConstraints.HORIZONTAL;
    buttonCons.anchor = GridBagConstraints.LINE_END;
    buttonCons.weightx = 1.0;
    insidePanel.add(statusLabel, buttonCons);

    Container contentPane = frame.getContentPane();
    GridBagLayout gridLayout = new GridBagLayout();
    contentPane.setLayout(gridLayout);
    GridBagConstraints cons = new GridBagConstraints();

    cons.gridx = 0;
    cons.gridy = 1;
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.anchor = GridBagConstraints.FIRST_LINE_START;
    JToolBar toolbar = new JToolBar("Toolbar", JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    contentPane.add(toolbar, cons);

    JButton openButton = new JButton(openAction);
    openButton.setHideActionText(true);
    openButton.setFocusable(false);
    toolbar.add(openButton);

    JButton saveButton = new JButton(saveAction);
    saveButton.setHideActionText(true);
    saveButton.setFocusable(false);
    toolbar.add(saveButton);

    JButton saveAsButton = new JButton(saveAsAction);
    saveAsButton.setHideActionText(true);
    saveAsButton.setFocusable(false);
    toolbar.add(saveAsButton);

    JButton spellButton = new JButton(this.checkAction);
    spellButton.setHideActionText(true);
    spellButton.setFocusable(false);
    toolbar.add(spellButton);

    JToggleButton autoSpellButton = new JToggleButton(autoCheckAction);
    autoSpellButton.setHideActionText(true);
    autoSpellButton.setFocusable(false);
    toolbar.add(autoSpellButton);

    JButton clearTextButton = new JButton(new ClearTextAction());
    clearTextButton.setHideActionText(true);
    clearTextButton.setFocusable(false);
    toolbar.add(clearTextButton);

    cons.insets = new Insets(5, 5, 5, 5);
    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.gridx = 0;
    cons.gridy = 2;
    cons.weighty = 5.0f;
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, numberedTextAreaPane, new JScrollPane(resultArea));
    mainPanel.setLayout(new GridLayout(0, 1));
    contentPane.add(mainPanel, cons);
    mainPanel.add(splitPane);

    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.gridx = 0;
    cons.gridy = 3;
    cons.weightx = 1.0f;
    cons.weighty = 0.0f;
    cons.insets = new Insets(4, 12, 4, 12);
    contentPane.add(insidePanel, cons);

    ltSupport = new LanguageToolSupport(this.frame, this.textArea, this.undoRedo);
    ResultAreaHelper.install(messages, ltSupport, resultArea);
    languageBox.selectLanguage(ltSupport.getLanguage());
    languageBox.setEnabled(!ltSupport.getConfig().getAutoDetect());
    autoDetectBox.setSelected(ltSupport.getConfig().getAutoDetect());
    taggerShowsDisambigLog = ltSupport.getConfig().getTaggerShowsDisambigLog();

    languageBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                // we cannot re-use the existing LT object anymore
                frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
                Language lang = languageBox.getSelectedLanguage();
                ComponentOrientation componentOrientation = ComponentOrientation
                        .getOrientation(lang.getLocale());
                textArea.applyComponentOrientation(componentOrientation);
                resultArea.applyComponentOrientation(componentOrientation);
                ltSupport.setLanguage(lang);
            }
        }
    });
    autoDetectBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            languageBox.setEnabled(!selected);
            ltSupport.getConfig().setAutoDetect(selected);
            if (selected) {
                Language detected = ltSupport.autoDetectLanguage(textArea.getText());
                languageBox.selectLanguage(detected);
            }
        }
    });
    ltSupport.addLanguageToolListener(new LanguageToolListener() {
        @Override
        public void languageToolEventOccurred(LanguageToolEvent event) {
            if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) {
                String msg = org.languagetool.tools.Tools.i18n(messages, "checkStart");
                statusLabel.setText(msg);
                if (event.getCaller() == getFrame()) {
                    setWaitCursor();
                    checkAction.setEnabled(false);
                }
            } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) {
                if (event.getCaller() == getFrame()) {
                    checkAction.setEnabled(true);
                    unsetWaitCursor();
                }
                String msg = org.languagetool.tools.Tools.i18n(messages, "checkDone",
                        event.getSource().getMatches().size(), event.getElapsedTime());
                statusLabel.setText(msg);
            } else if (event.getType() == LanguageToolEvent.Type.LANGUAGE_CHANGED) {
                languageBox.selectLanguage(ltSupport.getLanguage());
            } else if (event.getType() == LanguageToolEvent.Type.RULE_ENABLED) {
                //this will trigger a check and the result will be updated by
                //the CHECKING_FINISHED event
            } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED) {
                String msg = org.languagetool.tools.Tools.i18n(messages, "checkDoneNoTime",
                        event.getSource().getMatches().size());
                statusLabel.setText(msg);
            }
        }
    });
    frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
    Language lang = ltSupport.getLanguage();
    ComponentOrientation componentOrientation = ComponentOrientation.getOrientation(lang.getLocale());
    textArea.applyComponentOrientation(componentOrientation);
    resultArea.applyComponentOrientation(componentOrientation);

    ResourceBundle textLanguageMessageBundle = JLanguageTool.getMessageBundle(ltSupport.getLanguage());
    textArea.setText(textLanguageMessageBundle.getString("guiDemoText"));

    Configuration config = ltSupport.getConfig();
    if (config.getFontName() != null || config.getFontStyle() != Configuration.FONT_STYLE_INVALID
            || config.getFontSize() != Configuration.FONT_SIZE_INVALID) {
        String fontName = config.getFontName();
        if (fontName == null) {
            fontName = textArea.getFont().getFamily();
        }
        int fontSize = config.getFontSize();
        if (fontSize == Configuration.FONT_SIZE_INVALID) {
            fontSize = textArea.getFont().getSize();
        }
        Font font = new Font(fontName, config.getFontStyle(), fontSize);
        textArea.setFont(font);
    }

    frame.pack();
    frame.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    frame.setLocationByPlatform(true);
    splitPane.setDividerLocation(200);
    MainWindowStateBean state = localStorage.loadProperty("gui.state", MainWindowStateBean.class);
    if (state != null) {
        if (state.getBounds() != null) {
            frame.setBounds(state.getBounds());
            ResizeComponentListener.setBoundsProperty(frame, state.getBounds());
        }
        if (state.getDividerLocation() != null) {
            splitPane.setDividerLocation(state.getDividerLocation());
        }
        if (state.getState() != null) {
            frame.setExtendedState(state.getState());
        }
    }
    ResizeComponentListener.attachToWindow(frame);
    maybeStartServer();
}

From source file:org.languagetool.gui.Main.java

private void tagTextAndDisplayResults() {
    JLanguageTool langTool = ltSupport.getLanguageTool();
    // tag text//from   w  w w  . j ava 2 s  .c  o m
    List<String> sentences = langTool.sentenceTokenize(textArea.getText());
    StringBuilder sb = new StringBuilder();
    if (taggerShowsDisambigLog) {
        sb.append("<table>");
        sb.append("<tr>");
        sb.append("<td><b>");
        sb.append(messages.getString("token"));
        sb.append("</b></td>");
        sb.append("<td><b>");
        sb.append(messages.getString("disambiguatorLog"));
        sb.append("</b></td>");
        sb.append("</tr>");
        boolean odd = true;
        try {
            for (String sent : sentences) {
                AnalyzedSentence analyzed = langTool.getAnalyzedSentence(sent);
                odd = appendTagsWithDisambigLog(sb, analyzed, odd);
            }
        } catch (Exception e) {
            sb.append(getStackTraceAsHtml(e));
        }
        sb.append("</table>");
    } else {
        try {
            for (String sent : sentences) {
                AnalyzedSentence analyzed = langTool.getAnalyzedSentence(sent);
                String analyzedString = StringTools.escapeHTML(analyzed.toString(","))
                        .replace("&lt;S&gt;", "&lt;S&gt;<br>").replace("[", "<font color='" + TAG_COLOR + "'>[")
                        .replace("]", "]</font><br>");
                sb.append(analyzedString).append('\n');
            }
        } catch (Exception e) {
            sb.append(getStackTraceAsHtml(e));
        }
    }
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (taggerDialog == null) {
                taggerDialog = new JDialog(frame);
                taggerDialog.setTitle(messages.getString("taggerWindowTitle"));
                taggerDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
                taggerDialog.setResizable(true);
                taggerDialog.setSize(640, 480);
                taggerDialog.setLocationRelativeTo(frame);
                KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
                ActionListener actionListener = actionEvent -> taggerDialog.setVisible(false);
                taggerDialog.getRootPane().registerKeyboardAction(actionListener, stroke,
                        JComponent.WHEN_IN_FOCUSED_WINDOW);
                JPanel panel = new JPanel(new GridBagLayout());
                taggerDialog.add(panel);
                taggerArea = new JTextPane();
                taggerArea.setContentType("text/html");
                taggerArea.setEditable(false);
                GridBagConstraints c = new GridBagConstraints();
                c.gridx = 0;
                c.gridwidth = 2;
                c.gridy = 0;
                c.weightx = 1.0;
                c.weighty = 1.0;
                c.insets = new Insets(8, 8, 4, 8);
                c.fill = GridBagConstraints.BOTH;
                panel.add(new JScrollPane(taggerArea), c);
                c.gridwidth = 1;
                c.gridx = 0;
                c.gridy = 1;
                c.weightx = 0.0;
                c.weighty = 0.0;
                c.insets = new Insets(4, 8, 8, 8);
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.EAST;
                JCheckBox showDisAmbig = new JCheckBox(messages.getString("ShowDisambiguatorLog"));
                showDisAmbig.setSelected(taggerShowsDisambigLog);
                showDisAmbig.addItemListener((ItemEvent e) -> {
                    taggerShowsDisambigLog = e.getStateChange() == ItemEvent.SELECTED;
                    ltSupport.getConfig().setTaggerShowsDisambigLog(taggerShowsDisambigLog);
                });
                panel.add(showDisAmbig, c);
                c.gridx = 1;
                JButton closeButton = new JButton(messages.getString("guiCloseButton"));
                closeButton.addActionListener(actionListener);
                panel.add(closeButton, c);
            }
            // orientation each time should be set as language may is changed
            taggerDialog.applyComponentOrientation(
                    ComponentOrientation.getOrientation(languageBox.getSelectedLanguage().getLocale()));

            taggerDialog.setVisible(true);
            taggerArea.setText(HTML_FONT_START + sb + HTML_FONT_END);
        }
    });
}

From source file:org.languagetool.gui.Tools.java

static void showRuleInfoDialog(Component parent, String title, String message, Rule rule, URL matchUrl,
        ResourceBundle messages, String lang) {
    int dialogWidth = 320;
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);/*  w ww  . j ava2s . com*/
    textPane.setContentType("text/html");
    textPane.setBorder(BorderFactory.createEmptyBorder());
    textPane.setOpaque(false);
    textPane.setBackground(new Color(0, 0, 0, 0));
    Tools.addHyperlinkListener(textPane);
    textPane.setSize(dialogWidth, Short.MAX_VALUE);
    String messageWithBold = message.replaceAll("<suggestion>", "<b>").replaceAll("</suggestion>", "</b>");
    String exampleSentences = getExampleSentences(rule, messages);
    String url = "http://community.languagetool.org/rule/show/" + encodeUrl(rule) + "?lang=" + lang
            + "&amp;ref=standalone-gui";
    boolean isExternal = rule.getCategory().getLocation() == Category.Location.EXTERNAL;
    String ruleDetailLink = rule instanceof FalseFriendPatternRule || isExternal ? ""
            : "<a href='" + url + "'>" + messages.getString("ruleDetailsLink") + "</a>";
    textPane.setText("<html>" + messageWithBold + exampleSentences + formatURL(matchUrl) + "<br><br>"
            + ruleDetailLink + "</html>");
    JScrollPane scrollPane = new JScrollPane(textPane);
    scrollPane.setPreferredSize(new Dimension(dialogWidth, textPane.getPreferredSize().height));
    scrollPane.setBorder(BorderFactory.createEmptyBorder());

    String cleanTitle = title.replace("<suggestion>", "'").replace("</suggestion>", "'");
    JOptionPane.showMessageDialog(parent, scrollPane, cleanTitle, JOptionPane.INFORMATION_MESSAGE);
}

From source file:org.mbs3.juniuploader.gui.pnlSettings.java

private void initGUI() {
    try {/*from ww w . j  av a2 s.c om*/
        GridBagLayout thisLayout = new GridBagLayout();
        thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                0.0, 0.0, 0.0, 0.0 };
        thisLayout.rowHeights = new int[] { 11, 20, 18, 22, 22, 23, 23, 20, 18, 23, 22, 24, 6, 26, 4, 30, 8 };
        thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.columnWidths = new int[] { 10, 106, 90, 20, 20, 7, 100, 20, 7 };
        this.setLayout(thisLayout);
        this.setPreferredSize(new java.awt.Dimension(659, 349));
        {
            {
                grpMain = new ButtonGroup();
            }
            {
                grpGUI = new ButtonGroup();
            }
            {
                grpObjects = new ButtonGroup();
            }
            {
                grpHTTP = new ButtonGroup();
            }
            {
            }
            {
            }
            lblGUI = new JLabel();
            this.add(lblGUI, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblGUI.setText("Graphical Interface");
        }
        {
            lblMain = new JLabel();
            this.add(lblMain, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblMain.setText("Main Program");
        }
        {
            lblObj = new JLabel();
            this.add(lblObj, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblObj.setText("Object Messages");
        }
        {
            lblLObj = new JLabel();
            this.add(lblLObj, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblLObj.setText("HTTP Messages");
        }
        {
            lblFatal = new JLabel();
            this.add(lblFatal, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblFatal.setText("Fatal Messages");
        }
        {
            lblError = new JLabel();
            this.add(lblError, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblError.setText("Errors");
        }
        {
            lblWarn = new JLabel();
            this.add(lblWarn, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblWarn.setText("Warnings");
        }
        {
            lblInfo = new JLabel();
            this.add(lblInfo, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblInfo.setText("Info Messages");
        }
        {
            lblDebug = new JLabel();
            this.add(lblDebug, new GridBagConstraints(6, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblDebug.setText("Debug Messages");
        }
        {
            lblTrace = new JLabel();
            this.add(lblTrace, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblTrace.setText("Trace Execution");
        }
        {
            btnMainFatal = new JRadioButton();
            this.add(btnMainFatal, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
        grpMain.add(btnMainFatal);
        btnMainFatal.setActionCommand("fatal");
        btnMainFatal.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                logLevelBtnAction(evt);
            }
        });
        {
            btnMainError = new JRadioButton();
            this.add(btnMainError, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainError);
            btnMainError.setActionCommand("error");
            btnMainError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainWarn = new JRadioButton();
            this.add(btnMainWarn, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainWarn);
            btnMainWarn.setActionCommand("warn");
            btnMainWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainInfo = new JRadioButton();
            this.add(btnMainInfo, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainInfo);
            btnMainInfo.setActionCommand("info");
            btnMainInfo.setSelected(true);
            btnMainInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainDebug = new JRadioButton();
            this.add(btnMainDebug, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainDebug);
            btnMainDebug.setActionCommand("debug");
            btnMainDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainTrace = new JRadioButton();
            this.add(btnMainTrace, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainTrace);
            btnMainTrace.setActionCommand("trace");
            btnMainTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIFatal = new JRadioButton();
            this.add(btnGUIFatal, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIFatal);
            btnGUIFatal.setActionCommand("fatal");
            btnGUIFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIError = new JRadioButton();
            this.add(btnGUIError, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIError);
            btnGUIError.setActionCommand("error");
            btnGUIError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIWarn = new JRadioButton();
            this.add(btnGUIWarn, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIWarn);
            btnGUIWarn.setActionCommand("warn");
            btnGUIWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIInfo = new JRadioButton();
            this.add(btnGUIInfo, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIInfo);
            btnGUIInfo.setActionCommand("info");
            btnGUIInfo.setSelected(true);
            btnGUIInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIDebug = new JRadioButton();
            this.add(btnGUIDebug, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIDebug);
            btnGUIDebug.setActionCommand("debug");
            btnGUIDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUITrace = new JRadioButton();
            this.add(btnGUITrace, new GridBagConstraints(7, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUITrace);
            btnGUITrace.setActionCommand("trace");
            btnGUITrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjFatal = new JRadioButton();
            this.add(btnObjFatal, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjFatal);
            btnObjFatal.setActionCommand("fatal");
            btnObjFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjError = new JRadioButton();
            this.add(btnObjError, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjError);
            btnObjError.setActionCommand("error");
            btnObjError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjWarn = new JRadioButton();
            this.add(btnObjWarn, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjWarn);
            btnObjWarn.setActionCommand("warn");
            btnObjWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjInfo = new JRadioButton();
            this.add(btnObjInfo, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjInfo);
            btnObjInfo.setActionCommand("info");
            btnObjInfo.setSelected(true);
            btnObjInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjDebug = new JRadioButton();
            this.add(btnObjDebug, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjDebug);
            btnObjDebug.setActionCommand("debug");
            btnObjDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjTrace = new JRadioButton();
            this.add(btnObjTrace, new GridBagConstraints(7, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjTrace);
            btnObjTrace.setActionCommand("trace");
            btnObjTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPFatal = new JRadioButton();
            this.add(btnHTTPFatal, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPFatal);
            btnHTTPFatal.setActionCommand("fatal");
            btnHTTPFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPError = new JRadioButton();
            this.add(btnHTTPError, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPError);
            btnHTTPError.setActionCommand("error");
            btnHTTPError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPWarn = new JRadioButton();
            this.add(btnHTTPWarn, new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPWarn);
            btnHTTPWarn.setActionCommand("warn");
            btnHTTPWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPInfo = new JRadioButton();
            this.add(btnHTTPInfo, new GridBagConstraints(5, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPInfo);
            btnHTTPInfo.setActionCommand("info");
            btnHTTPInfo.setSelected(true);
            btnHTTPInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPDebug = new JRadioButton();
            this.add(btnHTTPDebug, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPDebug);
            btnHTTPDebug.setActionCommand("debug");
            btnHTTPDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPTrace = new JRadioButton();
            this.add(btnHTTPTrace, new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPTrace);
            btnHTTPTrace.setActionCommand("trace");
            btnHTTPTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            lblLogLevel = new JLabel();
            this.add(lblLogLevel, new GridBagConstraints(1, 1, 7, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblLogLevel.setText("Set the level of logging for different parts of this application:");
        }
        {
            lblDeLF = new JLabel();
            this.add(lblDeLF, new GridBagConstraints(1, 8, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblDeLF.setText("Set the look and feel for the GUI of this application:");
        }
        {
            LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels();
            LookAndFeel lf = UIManager.getLookAndFeel();
            DefaultComboBoxModel cmbLFModel = new DefaultComboBoxModel();
            for (int i = 0; i < lfs.length; i++) {
                String n = lfs[i].getName();
                cmbLFModel.addElement(n);
                if (lf.getName().equals(lfs[i].getName()))
                    cmbLFModel.setSelectedItem(n);
            }
            cmbLF = new JComboBox();
            this.add(cmbLF, new GridBagConstraints(1, 9, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            cmbLF.setModel(cmbLFModel);
            cmbLF.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent evt) {
                    cmbLFItemStateChanged(evt);
                }
            });
        }
        {
            tfUserAgent = new JTextField(Util.getUserAgent());
            this.add(tfUserAgent, new GridBagConstraints(1, 11, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            tfUserAgent.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent evt) {
                    tfUserAgentKeyReleased(evt);
                }
            });
        }
        {
            lblUserAgent = new JLabel();
            this.add(lblUserAgent, new GridBagConstraints(1, 10, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblUserAgent.setText("User Agent");
        }
        {
            btnExport = new JToggleButton();
            this.add(btnExport, new GridBagConstraints(1, 15, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            btnExport.setText("Export All Settings and Data to File");
            btnExport.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnExportActionPerformed(evt);
                }
            });
        }
        {
            txtWarn = new JTextPane();
            this.add(txtWarn, new GridBagConstraints(4, 15, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            txtWarn.setText(
                    "Note: This includes rules, form variables, sites, and ANYTHING else this program can remember from run to run.");
            txtWarn.setEditable(false);
            txtWarn.setBackground(new java.awt.Color(255, 255, 255));
            txtWarn.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0)));
        }

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

From source file:org.n52.ifgicopter.spf.output.FileWriterPlugin.java

@Override
public void init() throws Exception {
    String time = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH_mm_ss").print(System.currentTimeMillis());
    this.file = new File("csv-logger-" + time + ".csv");
    boolean b = this.file.createNewFile();
    if (!b)/*from   w  w w.j a  v  a  2s . c o  m*/
        this.log.warn("File already exists!");

    this.firstRun = true;

    synchronized (this) {
        this.fos = new FileOutputStream(this.file);
    }

    this.gui = new ModuleGUI();
    this.panel = new JPanel(new BorderLayout());
    this.gui.setGui(this.panel);

    this.scrollLock = new JCheckBox("Scroll lock");
    this.scrollLock.setSelected(true);

    this.console = new JTextPane() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean getScrollableTracksViewportWidth() {
            return false;
        }
    };
    this.consoleDoc = this.console.getStyledDocument();

    this.console.setFont(Font.getFont(Font.MONOSPACED));
    this.console.setEditable(false);
    this.console.setBackground(Color.WHITE);

    JScrollPane jsp = new JScrollPane(this.console);

    jsp.setBackground(Color.white);

    this.panel.add(jsp);
    this.panel.add(this.scrollLock, BorderLayout.NORTH);
    this.panel.add(new JLabel("Writing to file '" + this.file.getAbsolutePath() + "'."), BorderLayout.SOUTH);
}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * Setup General (Control Center) Tab/*from  w w w . j av  a 2s. c o m*/
 * 
 * @return JPanel for Control Center
 */
private JPanel setupGeneral() {

    JPanel generalPanel = new JPanel();
    generalPanel.setLayout(new BorderLayout());

    /* -- Stats Panel -- */
    JPanel statsPanel = new JPanel();
    generalPanel.add(statsPanel, BorderLayout.NORTH);

    statsPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JPanel eastPanel = new JPanel();
    statsPanel.add(eastPanel, BorderLayout.EAST);
    eastPanel.setLayout(new BorderLayout());

    JPanel westPanel = new JPanel();
    statsPanel.add(westPanel, BorderLayout.WEST);
    westPanel.setLayout(new BorderLayout());

    // Grid Information Panel
    JPanel gridInfoPanel = new JPanel();
    eastPanel.add(gridInfoPanel, BorderLayout.NORTH);

    gridInfoPanel.setBorder(BorderFactory.createTitledBorder("Grid Information"));
    gridInfoPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JLabel nodeIdLabel = new JLabel("Node ID :");
    gridInfoPanel.add(nodeIdLabel);
    JLabel nodeId = new JLabel("#nodeid#");
    gridInfoPanel.add(nodeId);
    addUIElement("general.stats.nodeid", nodeId); // Add to components map

    JLabel nodeIpLabel = new JLabel("Node IP :");
    gridInfoPanel.add(nodeIpLabel);
    JLabel nodeIp = new JLabel("#nodeip#");
    gridInfoPanel.add(nodeIp);
    addUIElement("general.stats.nodeip", nodeIp); // Add to components map

    JLabel clusterIdLabel = new JLabel("Cluster ID :");
    gridInfoPanel.add(clusterIdLabel);
    JLabel clusterId = new JLabel("#clusterid#");
    gridInfoPanel.add(clusterId);
    addUIElement("general.stats.clusterid", clusterId); // Add to components map

    JLabel clusterServiceLabel = new JLabel("Cluster Service :");
    gridInfoPanel.add(clusterServiceLabel);
    JLabel clusterService = new JLabel("#clusterservice#");
    gridInfoPanel.add(clusterService);
    addUIElement("general.stats.clusterservice", clusterService); // Add to components map

    // Node Status Panel 
    JPanel nodeStatusPanel = new JPanel();
    eastPanel.add(nodeStatusPanel, BorderLayout.SOUTH);

    nodeStatusPanel.setBorder(BorderFactory.createTitledBorder("GridNode Status"));
    nodeStatusPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JLabel statusLabel = new JLabel("Status :");
    nodeStatusPanel.add(statusLabel);
    JLabel status = new JLabel("#status#");
    nodeStatusPanel.add(status);
    addUIElement("general.stats.status", status); // Add to components map

    JLabel uptimeLabel = new JLabel("Node Up Time :");
    nodeStatusPanel.add(uptimeLabel);
    JLabel uptime = new JLabel("#uptime#");
    nodeStatusPanel.add(uptime);
    addUIElement("general.stats.uptime", uptime); // Add to components map

    JLabel execTimeLabel = new JLabel("Execution Time :");
    nodeStatusPanel.add(execTimeLabel);
    JLabel execTime = new JLabel("#exectime#");
    nodeStatusPanel.add(execTime);
    addUIElement("general.stats.exectime", execTime); // Add to components map

    // Execution Statistics Panel
    JPanel execStatsPanel = new JPanel();
    westPanel.add(execStatsPanel, BorderLayout.NORTH);

    execStatsPanel.setLayout(new GridLayout(0, 2, 10, 10));
    execStatsPanel.setBorder(BorderFactory.createTitledBorder("Execution Statistics"));

    JLabel totalJobsLabel = new JLabel("Total Jobs :");
    execStatsPanel.add(totalJobsLabel);
    JLabel totalJobs = new JLabel("0");
    execStatsPanel.add(totalJobs);
    addUIElement("general.stats.totaljobs", totalJobs); // Add to components map

    JLabel totalTasksLabel = new JLabel("Total Tasks :");
    execStatsPanel.add(totalTasksLabel);
    JLabel totalTasks = new JLabel("0");
    execStatsPanel.add(totalTasks);
    addUIElement("general.stats.totaltasks", totalTasks); // Add to components map

    JLabel totalBansLabel = new JLabel("Banments :");
    execStatsPanel.add(totalBansLabel);
    JLabel totalBans = new JLabel("0");
    execStatsPanel.add(totalBans);
    addUIElement("general.stats.totalbans", totalBans); // Add to components map

    // Execution Active Job Panel
    JPanel activeJobPanel = new JPanel();
    westPanel.add(activeJobPanel, BorderLayout.SOUTH);

    activeJobPanel.setLayout(new GridLayout(0, 2, 10, 10));
    activeJobPanel.setBorder(BorderFactory.createTitledBorder("Active Job"));

    JLabel jobNameLabel = new JLabel("GridJob Name :");
    activeJobPanel.add(jobNameLabel);
    JLabel jobName = new JLabel("#jobname#");
    activeJobPanel.add(jobName);
    addUIElement("general.stats.jobname", jobName); // Add to components map

    JLabel durationLabel = new JLabel("Duration :");
    activeJobPanel.add(durationLabel);
    JLabel duration = new JLabel("#duration#");
    activeJobPanel.add(duration);
    addUIElement("general.stats.duration", duration); // Add to components map

    JLabel tasksLabel = new JLabel("Tasks Executed :");
    activeJobPanel.add(tasksLabel);
    JLabel tasks = new JLabel("#xyz#");
    activeJobPanel.add(tasks);
    addUIElement("general.stats.tasks", tasks); // Add to components map

    JLabel failuresLabel = new JLabel("Failures :");
    activeJobPanel.add(failuresLabel);
    JLabel failures = new JLabel("#failures#");
    activeJobPanel.add(failures);
    addUIElement("general.stats.failures", failures); // Add to components map

    /* -- Log Panel -- */
    JPanel logPanel = new JPanel();
    generalPanel.add(logPanel, BorderLayout.CENTER);

    logPanel.setLayout(new BorderLayout());
    logPanel.setBorder(BorderFactory.createTitledBorder("Log Output"));
    JTextPane logTextPane = new JTextPane();
    logTextPane.setEditable(false);
    logTextPane.setBackground(Color.BLACK);
    logTextPane.setForeground(Color.WHITE);

    logPanel.add(new JScrollPane(logTextPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    addUIElement("general.log", logTextPane); // Add to component map

    JPanel logOptionsPanel = new JPanel();
    logPanel.add(logOptionsPanel, BorderLayout.SOUTH);
    logOptionsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox logScrollCheckbox = new JCheckBox("Auto-Scroll Log");
    logScrollCheckbox.setSelected(true);
    logScrollCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JTextPaneAppender.setAutoScroll(logScrollCheckbox.isSelected());
        }

    });
    logOptionsPanel.add(logScrollCheckbox);

    // Enable Logging
    JTextPaneAppender.setTextPane(logTextPane);

    /* -- Buttons Panel -- */
    JPanel buttonsPanel = new JPanel();
    generalPanel.add(buttonsPanel, BorderLayout.SOUTH);

    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    // Shutdown Button
    JButton shutdownButton = new JButton("Shutdown");
    buttonsPanel.add(shutdownButton);
    shutdownButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            doShutdownNode();
        }

    });

    // Start Up time Thread
    Thread t = new Thread(new Runnable() {
        public void run() {

            long start = System.currentTimeMillis();

            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    log.warn("Interrupted Exception in Up Time Thread", e);
                }

                final String uptime = TimeUtils.timeDifference(start);

                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        JLabel upTime = getUIElement("general.stats.uptime");
                        upTime.setText(uptime);
                    }

                });
            }

        }
    });
    t.setDaemon(true);
    t.start();

    // Auto-Discovery Thread
    Thread autoDiscovery = new Thread(new Runnable() {
        public void run() {

            while (true) {
                try {

                    // Attempt every 30 seconds
                    Thread.sleep(30000);

                } catch (InterruptedException e) {
                    log.warn("Interrupted Exception in Up Time Thread", e);
                }

                if (autodiscover && (!Grid.isNode())) {
                    // 30 Second Intervals
                    doDiscover(true);
                }

            }
        }
    });
    autoDiscovery.setDaemon(true);
    autoDiscovery.start();

    return generalPanel;
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java

/**
 * Creates the component hosting the debug text.
 * /*from w w  w.  j  av a 2s  .co  m*/
 * @return See above.
 */
private JComponent createDebugTab() {
    debugTextPane = new JTextPane();
    debugTextPane.setEditable(false);
    StyledDocument doc = (StyledDocument) debugTextPane.getDocument();

    Style style = doc.addStyle(STYLE, null);
    StyleConstants.setForeground(style, Color.black);
    StyleConstants.setFontFamily(style, "SansSerif");
    StyleConstants.setFontSize(style, 12);
    StyleConstants.setBold(style, false);

    JScrollPane sp = new JScrollPane(debugTextPane);
    sp.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent e) {
            try {
                debugTextPane.setCaretPosition(debugTextPane.getDocument().getLength());
            } catch (IllegalArgumentException ex) {
                //
            }
        }
    });
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(sp, BorderLayout.CENTER);
    return panel;
}

From source file:org.openpnp.gui.AboutDialog.java

public AboutDialog(Frame frame) {
    super(frame, true);
    setTitle("About OpenPnP");
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 347, 360);/*  ww w  .  ja  v a  2  s  . co m*/
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
    JLabel lblOpenpnp = new JLabel("OpenPnP");
    lblOpenpnp.setAlignmentX(Component.CENTER_ALIGNMENT);
    lblOpenpnp.setFont(new Font("Lucida Grande", Font.BOLD, 32));
    contentPanel.add(lblOpenpnp);
    JLabel lblCopyright = new JLabel("Copyright  2011 - 2016 Jason von Nieda");
    lblCopyright.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
    lblCopyright.setAlignmentX(Component.CENTER_ALIGNMENT);
    contentPanel.add(lblCopyright);
    JLabel lblVersion = new JLabel("Version: " + Main.getVersion());
    lblVersion.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
    lblVersion.setAlignmentX(Component.CENTER_ALIGNMENT);
    contentPanel.add(lblVersion);

    textPane = new JTextPane();
    textPane.setEditable(false);
    contentPanel.add(new JScrollPane(textPane));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
        }
    });
    okButton.setActionCommand("OK");
    buttonPane.add(okButton);
    getRootPane().setDefaultButton(okButton);

    try {
        String s = FileUtils.readFileToString(new File("CHANGES.md"));
        textPane.setText(s);
        textPane.setCaretPosition(0);
    } catch (Exception e) {

    }
}

From source file:org.openstatic.placebo.plugins.KeyStore.java

public boolean startup(CoreServer core, String mount_location) {
    System.err.println("KeyStore: Initializing Keystore");
    store = new JSONObject();

    if (core.isSwingOk()) {
        json_box = new JTextPane();
        json_box.setContentType("text/html");
        Font font = new Font("Monospaced", Font.BOLD, 12);
        json_box.setFont(font);//from ww w . java2 s . co  m
        JScrollPane scroller = new JScrollPane(json_box);
        scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        core.addPanel("Keystore [" + mount_location + "]", scroller);
        this.swing_mode = true;
    } else {
        this.swing_mode = false;
    }
    return true;
}