Example usage for javax.swing JTextPane setOpaque

List of usage examples for javax.swing JTextPane setOpaque

Introduction

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

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:edu.scripps.fl.pubchem.xmltool.gui.GUIComponent.java

public JTextPane createJTextPane(String text) {
    JTextPane jtp = new JTextPane();
    jtp.setText(text);/*from  ww  w  .  j ava 2  s .c  o  m*/
    SimpleAttributeSet underline = new SimpleAttributeSet();
    StyleConstants.setUnderline(underline, true);
    jtp.getStyledDocument().setCharacterAttributes(0, text.length(), underline, true);
    jtp.setEditable(false);
    jtp.setOpaque(false);
    jtp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
    jtp.setBorder(BorderFactory.createEmptyBorder());
    jtp.setForeground(Color.blue);
    jtp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return jtp;
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.GUIComponent.java

public JTextPane createJTextPane() {
    String newline = "\n";
    String[] description = { "PubChem XML Tool (Version: " + version + ")" + newline,
            "By: S. Canny (scanny@scripps.edu) and M. Southern (southern@scripps.edu)" + newline, "" + newline,
            "PubChem XML Tool main functions:" + newline,
            "1. Create a PubChem XML that can include Assay, Result TIDs, Xrefs, Panel, and Categorized Comments."
                    + newline,/*  w w w.ja v a 2s . com*/
            "2. Extract Assay, Result TID, Xref, Panel, and Categorized Comment information from a PubChem XML."
                    + newline,
            "3. Create a report from an Excel workbook or PubChem XMLs." + newline, "" + newline,
            "Other features:" + newline,
            "1. Automatically adds reference section to description of PubChem XML or a report if placeholder is used."
                    + newline,
            "2. Checks proteins, genes, omims, and taxonomies for connections when creating PubChem XML or a report."
                    + newline,
            "3. Can retrieve on-hold and newly deposited assays from deposition system to extract or create report."
                    + newline,
            "" + newline, "\t\t\t(c) 2010, The Scripps Research Institute- Florida" };
    String[] styles = { "bold", "regular", "regular", "regular", "regular", "regular", "regular", "regular",
            "regular", "regular", "regular", "regular", "regular", "regular", "right" };

    JTextPane jtp = new JTextPane();
    StyledDocument doc = jtp.getStyledDocument();
    addStylesToDocument(doc);

    try {
        for (int ii = 0; ii < description.length; ii++)
            doc.insertString(doc.getLength(), description[ii], doc.getStyle(styles[ii]));
    } catch (BadLocationException ble) {
        log.error(ble.getMessage(), ble);
    }
    jtp.setOpaque(false);
    jtp.setEditable(false);
    jtp.setPreferredSize(new Dimension(640, 230));

    return jtp;
}

From source file:ome.formats.importer.gui.GuiCommonElements.java

/**
 * Add a text pane to the parent container
 * // w ww.  j  a  v a  2s .  c om
 * @param container - parent container
 * @param text - text for new Text Pane
 * @param placement - TableLayout placement within the parent container
 * @param debug - turn on/off red debug borders
 * @return new JTextPane
 */
public static synchronized JTextPane addTextPane(Container container, String text, String placement,
        boolean debug) {
    StyleContext context = new StyleContext();
    StyledDocument document = new DefaultStyledDocument(context);

    Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
    StyleConstants.setAlignment(style, StyleConstants.ALIGN_LEFT);

    try {
        document.insertString(document.getLength(), text, null);
    } catch (BadLocationException e) {
        log.error("BadLocationException inserting text to document.");
    }

    JTextPane textPane = new JTextPane(document);
    textPane.setOpaque(false);
    textPane.setEditable(false);
    textPane.setFocusable(false);
    container.add(textPane, placement);

    if (debug == true)
        textPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                textPane.getBorder()));

    return textPane;
}

From source file:ome.formats.importer.gui.GuiCommonElements.java

/**
 * A version of addTextPane that lets you add a style and context
 * /*from  ww w  . j  a  v  a 2  s  .c  o  m*/
 * @param container - parent container
 * @param text - text for new Text Pane
 * @param placement - TableLayout placement within the parent container
 * @param context - context for new text pane
 * @param style - style to apply to new text pane
 * @param debug - turn on/off red debug borders
 * @return new JTextPane
 */
public static synchronized JTextPane addTextPane(Container container, String text, String placement,
        StyleContext context, Style style, boolean debug) {
    StyledDocument document = new DefaultStyledDocument(context);

    try {
        document.insertString(document.getLength(), text, style);
    } catch (BadLocationException e) {
        log.error("BadLocationException inserting text to document.");
    }

    JTextPane textPane = new JTextPane(document);
    textPane.setOpaque(false);
    textPane.setEditable(false);
    textPane.setFocusable(false);
    container.add(textPane, placement);

    if (debug == true)
        textPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                textPane.getBorder()));

    return textPane;
}

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);//from w w  w.j a va2  s .  c o  m
    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.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Formats the text and displays it in a {@link JTextPane}.
 * /*from  w w w .  j  a  v  a 2 s.c om*/
 * @param text          The text to display.
 * @param foreground   The foreground color.
 * @return See above.
 */
public static JTextPane buildTextPane(String text, Color foreground) {
    if (text == null)
        text = "";
    StyleContext context = new StyleContext();
    StyledDocument document = new DefaultStyledDocument(context);

    Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
    StyleConstants.setAlignment(style, StyleConstants.ALIGN_LEFT);
    if (foreground != null)
        StyleConstants.setForeground(style, foreground);
    try {
        document.insertString(document.getLength(), text, style);
    } catch (BadLocationException e) {
    }

    JTextPane textPane = new JTextPane(document);
    textPane.setOpaque(false);
    textPane.setEditable(false);
    textPane.setFocusable(false);
    return textPane;
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/** Builds the UI component displaying the exception.*/
public static JTextPane buildExceptionArea() {
    StyleContext context = new StyleContext();
    StyledDocument document = new DefaultStyledDocument(context);

    JTextPane textPane = new JTextPane(document);
    textPane.setOpaque(false);
    textPane.setEditable(false);//from www .  j ava  2s .c om

    // Create one of each type of tab stop
    List<TabStop> list = new ArrayList<TabStop>();

    // Create a left-aligned tab stop at 100 pixels from the left margin
    float pos = 15;
    int align = TabStop.ALIGN_LEFT;
    int leader = TabStop.LEAD_NONE;
    TabStop tstop = new TabStop(pos, align, leader);
    list.add(tstop);

    // Create a right-aligned tab stop at 200 pixels from the left margin
    pos = 15;
    align = TabStop.ALIGN_RIGHT;
    leader = TabStop.LEAD_NONE;
    tstop = new TabStop(pos, align, leader);
    list.add(tstop);

    // Create a center-aligned tab stop at 300 pixels from the left margin
    pos = 15;
    align = TabStop.ALIGN_CENTER;
    leader = TabStop.LEAD_NONE;
    tstop = new TabStop(pos, align, leader);
    list.add(tstop);

    // Create a decimal-aligned tab stop at 400 pixels from the left margin
    pos = 15;
    align = TabStop.ALIGN_DECIMAL;
    leader = TabStop.LEAD_NONE;
    tstop = new TabStop(pos, align, leader);
    list.add(tstop);

    // Create a tab set from the tab stops
    TabSet tabs = new TabSet(list.toArray(new TabStop[0]));

    // Add the tab set to the logical style;
    // the logical style is inherited by all paragraphs
    Style style = textPane.getLogicalStyle();
    StyleConstants.setTabSet(style, tabs);
    textPane.setLogicalStyle(style);
    Style debugStyle = document.addStyle("StyleName", null);
    StyleConstants.setForeground(debugStyle, Color.BLACK);
    StyleConstants.setFontFamily(debugStyle, "SansSerif");
    StyleConstants.setFontSize(debugStyle, 12);
    StyleConstants.setBold(debugStyle, false);
    return textPane;
}

From source file:org.tinymediamanager.ui.movies.settings.MovieRenamerSettingsPanel.java

public MovieRenamerSettingsPanel() {
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default"),
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, }));
    // the panel renamer
    JPanel panelRenamer = new JPanel();
    panelRenamer.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.renamer.title"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelRenamer, "2, 2, fill, fill");
    panelRenamer.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("75dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow(3)"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    chckbxSpaceSubstitution = new JCheckBox(BUNDLE.getString("Settings.movie.renamer.spacesubstitution")); //$NON-NLS-1$
    chckbxSpaceSubstitution.addActionListener(actionCreateRenamerExample);

    tfMoviePath = new JTextField();
    tfMoviePath.getDocument().addDocumentListener(new DocumentListener() {
        @Override//  w w  w. j  a v a 2s .  com
        public void removeUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }

        @Override
        public void insertUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }

        @Override
        public void changedUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }
    });

    JLabel lblMoviePath = new JLabel(BUNDLE.getString("Settings.renamer.folder")); //$NON-NLS-1$
    panelRenamer.add(lblMoviePath, "2, 4, right, default");
    panelRenamer.add(tfMoviePath, "4, 4, fill, default");
    tfMoviePath.setColumns(10);
    panelRenamer.add(chckbxSpaceSubstitution, "8, 4");

    cbSeparator = new JComboBox(separators.toArray());
    panelRenamer.add(cbSeparator, "10, 4, fill, default");
    cbSeparator.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            checkChanges();
            createRenamerExample();
        }
    });

    lblDefault1T = new JLabel(BUNDLE.getString("Settings.default"));
    TmmFontHelper.changeFont(lblDefault1T, 0.833);
    panelRenamer.add(lblDefault1T, "2, 6, right, top");

    lblDefaultFolderPattern = new JLabel(MovieSettings.DEFAULT_RENAMER_FOLDER_PATTERN);
    TmmFontHelper.changeFont(lblDefaultFolderPattern, 0.833);
    panelRenamer.add(lblDefaultFolderPattern, "4, 6, default, top");

    chckbxMoviesetSingleMovie = new JCheckBox(BUNDLE.getString("Settings.renamer.moviesetsinglemovie")); //$NON-NLS-1$
    chckbxMoviesetSingleMovie.addActionListener(actionCreateRenamerExample);
    panelRenamer.add(chckbxMoviesetSingleMovie, "8, 6, 5, 1, fill, default");

    lblMMDWarning = new JLabel(BUNDLE.getString("Settings.renamer.folder.warning")); //$NON-NLS-1$
    panelRenamer.add(lblMMDWarning, "2, 8, 11, 1");

    JLabel lblMovieFilename = new JLabel(BUNDLE.getString("Settings.renamer.file")); //$NON-NLS-1$
    panelRenamer.add(lblMovieFilename, "2, 10, right, fill");

    tfMovieFilename = new JTextField();
    tfMovieFilename.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }

        @Override
        public void insertUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }

        @Override
        public void changedUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }
    });
    panelRenamer.add(tfMovieFilename, "4, 10, fill, default");
    tfMovieFilename.setColumns(10);
    lblMovieFilename.setLabelFor(tfMovieFilename);

    chckbxAsciiReplacement = new JCheckBox(BUNDLE.getString("Settings.renamer.asciireplacement")); //$NON-NLS-1$
    chckbxAsciiReplacement.addActionListener(actionCreateRenamerExample);
    panelRenamer.add(chckbxAsciiReplacement, "8, 10, 5, 1");

    lblDefault2T = new JLabel(BUNDLE.getString("Settings.default"));
    TmmFontHelper.changeFont(lblDefault2T, 0.833);
    panelRenamer.add(lblDefault2T, "2, 12, right, top");

    lblDefaultFilePattern = new JLabel(MovieSettings.DEFAULT_RENAMER_FILE_PATTERN);
    TmmFontHelper.changeFont(lblDefaultFilePattern, 0.833);
    panelRenamer.add(lblDefaultFilePattern, "4, 12, default, top");

    JTextPane txtpntAsciiHint = new JTextPane();
    txtpntAsciiHint.setOpaque(false);
    txtpntAsciiHint.setEditable(false);
    txtpntAsciiHint.setText(BUNDLE.getString("Settings.renamer.asciireplacement.hint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(txtpntAsciiHint, 0.833);
    txtpntAsciiHint.setBackground(UIManager.getColor("Panel.background"));
    panelRenamer.add(txtpntAsciiHint, "8, 12, 5, 1, fill, fill");

    JTextPane txtrChooseAFolder = new JTextPane();
    txtrChooseAFolder.setOpaque(false);
    txtrChooseAFolder.setEditable(false);
    TmmFontHelper.changeFont(txtrChooseAFolder, 0.833);
    txtrChooseAFolder.setText(BUNDLE.getString("Settings.movie.renamer.example")); //$NON-NLS-1$
    txtrChooseAFolder.setBackground(UIManager.getColor("Panel.background"));
    panelRenamer.add(txtrChooseAFolder, "2, 14, 3, 3, fill, top");

    chckbxRemoveOtherNfos = new JCheckBox(BUNDLE.getString("Settings.renamer.removenfo")); //$NON-NLS-1$
    panelRenamer.add(chckbxRemoveOtherNfos, "8, 14, 5, 1");

    lblSubtitleLanguage = new JLabel(BUNDLE.getString("Settings.renamer.language")); //$NON-NLS-1$
    panelRenamer.add(lblSubtitleLanguage, "8, 16, right, default");

    cbSubtitleLanguage = new JComboBox(LanguageStyle.values());
    panelRenamer.add(cbSubtitleLanguage, "10, 16, 3, 1, fill, default");

    exampleEventList = GlazedLists.threadSafeList(new ObservableElementList<>(
            new BasicEventList<MovieRenamerExample>(), GlazedLists.beanConnector(MovieRenamerExample.class)));
    DefaultEventTableModel<MovieRenamerExample> exampleTableModel = new DefaultEventTableModel<>(
            GlazedListsSwing.swingThreadProxyList(exampleEventList), new MovieRenamerExampleTableFormat());

    panelExample = new JPanel();
    panelExample.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.example"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelExample, "2, 4, fill, fill");
    panelExample.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("50dlu:grow"),
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    JLabel lblExampleT = new JLabel(BUNDLE.getString("tmm.movie")); //$NON-NLS-1$
    panelExample.add(lblExampleT, "2, 2");

    cbMovieForPreview = new JComboBox();
    panelExample.add(cbMovieForPreview, "4, 2");

    lblExample = new JLabel("");
    panelExample.add(lblExample, "2, 4, 3, 1");
    TmmFontHelper.changeFont(lblExample, 0.916, Font.BOLD);
    tableExamples = new ZebraJTable(exampleTableModel);
    scrollPane = ZebraJTable.createStripedJScrollPane(tableExamples);
    scrollPane.setViewportView(tableExamples);
    panelExample.add(scrollPane, "2, 6, 3, 1, fill, fill");

    JTextPane txtpntTitle = new JTextPane();
    txtpntTitle.setOpaque(false);
    panelExample.add(txtpntTitle, "2, 8, 3, 1");
    TmmFontHelper.changeFont(txtpntTitle, 0.833);
    txtpntTitle.setBackground(UIManager.getColor("Panel.background"));
    txtpntTitle.setText(BUNDLE.getString("Settings.movie.renamer.optional")); //$NON-NLS-1$
    txtpntTitle.setEditable(false);
    cbMovieForPreview.addActionListener(actionCreateRenamerExample);

    initDataBindings();

    // space separator
    String replacement = settings.getMovieRenamerSpaceReplacement();
    int index = separators.indexOf(replacement);
    if (index >= 0) {
        cbSeparator.setSelectedIndex(index);
    }

    // language style
    cbSubtitleLanguage.setSelectedItem(settings.getMovieRenamerLanguageStyle());

    // examples
    exampleEventList.add(new MovieRenamerExample("$T"));
    exampleEventList.add(new MovieRenamerExample("$O"));
    exampleEventList.add(new MovieRenamerExample("$1"));
    exampleEventList.add(new MovieRenamerExample("$E"));
    exampleEventList.add(new MovieRenamerExample("$2"));
    exampleEventList.add(new MovieRenamerExample("$Y"));
    exampleEventList.add(new MovieRenamerExample("$M"));
    exampleEventList.add(new MovieRenamerExample("$N"));
    exampleEventList.add(new MovieRenamerExample("$I"));
    exampleEventList.add(new MovieRenamerExample("$C"));
    exampleEventList.add(new MovieRenamerExample("$D"));
    exampleEventList.add(new MovieRenamerExample("$G"));
    exampleEventList.add(new MovieRenamerExample("$L"));
    exampleEventList.add(new MovieRenamerExample("$R"));
    exampleEventList.add(new MovieRenamerExample("$A"));
    exampleEventList.add(new MovieRenamerExample("$V"));
    exampleEventList.add(new MovieRenamerExample("$F"));
    exampleEventList.add(new MovieRenamerExample("$S"));
    exampleEventList.add(new MovieRenamerExample("$#"));
    exampleEventList.add(new MovieRenamerExample("$3"));
    exampleEventList.add(new MovieRenamerExample("$U"));
}

From source file:org.tinymediamanager.ui.settings.GeneralSettingsPanel.java

/**
 * Instantiates a new general settings panel.
 *//*  w ww. ja v a 2s .  c o  m*/
public GeneralSettingsPanel() {
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min):grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default):grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelUI = new JPanel();
    panelUI.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.ui"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelUI, "2, 2, 3, 1, fill, fill");
    panelUI.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));
    LocaleComboBox actualLocale = null;
    // cbLanguage = new JComboBox(Utils.getLanguages().toArray());
    Locale settingsLang = Utils.getLocaleFromLanguage(Globals.settings.getLanguage());
    for (Locale l : Utils.getLanguages()) {
        LocaleComboBox localeComboBox = new LocaleComboBox(l);
        locales.add(localeComboBox);
        if (l.equals(settingsLang)) {
            actualLocale = localeComboBox;
        }
    }

    JLabel lblUiLanguage = new JLabel(BUNDLE.getString("Settings.language"));
    panelUI.add(lblUiLanguage, "2, 2");
    cbLanguage = new JComboBox(locales.toArray());
    panelUI.add(cbLanguage, "4, 2");

    if (actualLocale != null) {
        cbLanguage.setSelectedItem(actualLocale);
    }

    JSeparator separator = new JSeparator();
    separator.setOrientation(SwingConstants.VERTICAL);
    panelUI.add(separator, "8, 2, 1, 7");

    JLabel lblFontFamily = new JLabel(BUNDLE.getString("Settings.fontfamily")); //$NON-NLS-1$
    panelUI.add(lblFontFamily, "10, 2, right, default");
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    cbFontFamily = new JComboBox(env.getAvailableFontFamilyNames());
    cbFontFamily.setSelectedItem(Globals.settings.getFontFamily());
    int index = cbFontFamily.getSelectedIndex();
    if (index < 0) {
        cbFontFamily.setSelectedItem("Dialog");
        index = cbFontFamily.getSelectedIndex();
    }
    if (index < 0) {
        cbFontFamily.setSelectedIndex(0);
    }
    panelUI.add(cbFontFamily, "12, 2, fill, default");

    JLabel lblFontSize = new JLabel(BUNDLE.getString("Settings.fontsize")); //$NON-NLS-1$
    panelUI.add(lblFontSize, "10, 4, right, default");

    cbFontSize = new JComboBox(DEFAULT_FONT_SIZES);
    cbFontSize.setSelectedItem(Globals.settings.getFontSize());
    index = cbFontSize.getSelectedIndex();
    if (index < 0) {
        cbFontSize.setSelectedIndex(0);
    }

    panelUI.add(cbFontSize, "12, 4, fill, default");

    JPanel panel = new JPanel();
    panelUI.add(panel, "2, 6, 5, 1, fill, fill");
    panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
            ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));

    JLabel lblMissingTranslation = new JLabel(BUNDLE.getString("tmm.helptranslate"));
    panel.add(lblMissingTranslation, "1, 1, 5, 1");

    lblLinkTransifex = new LinkLabel("https://www.transifex.com/projects/p/tinymediamanager/");
    panel.add(lblLinkTransifex, "1, 3, 5, 1");
    lblLinkTransifex.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                TmmUIHelper.browseUrl(lblLinkTransifex.getNormalText());
            } catch (Exception e) {
                LOGGER.error(e.getMessage());
                MessageManager.instance
                        .pushMessage(new Message(MessageLevel.ERROR, lblLinkTransifex.getNormalText(),
                                "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() }));//$NON-NLS-2$
            }
        }
    });

    tpFontHint = new JTextPane();
    tpFontHint.setOpaque(false);
    TmmFontHelper.changeFont(tpFontHint, 0.833);
    tpFontHint.setText(BUNDLE.getString("Settings.fonts.hint")); //$NON-NLS-1$
    panelUI.add(tpFontHint, "10, 6, 5, 1");

    lblLanguageHint = new JLabel("");
    TmmFontHelper.changeFont(lblLanguageHint, Font.BOLD);
    panelUI.add(lblLanguageHint, "2, 8, 5, 1");

    lblFontChangeHint = new JLabel("");
    TmmFontHelper.changeFont(lblFontChangeHint, Font.BOLD);
    panelUI.add(lblFontChangeHint, "10, 8, 5, 1");

    JPanel panelMemory = new JPanel();
    panelMemory.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.memoryborder"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelMemory, "2, 4, fill, fill");
    panelMemory.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow(4)"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(20dlu;default)"),
                    ColumnSpec.decode("left:default:grow(5)"), },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, }));

    JLabel lblMemoryT = new JLabel(BUNDLE.getString("Settings.memory")); //$NON-NLS-1$
    panelMemory.add(lblMemoryT, "2, 1");

    sliderMemory = new JSlider();
    sliderMemory.setPaintLabels(true);
    sliderMemory.setPaintTicks(true);
    sliderMemory.setSnapToTicks(true);
    sliderMemory.setMajorTickSpacing(512);
    sliderMemory.setMinorTickSpacing(128);
    sliderMemory.setMinimum(256);
    sliderMemory.setMaximum(1536);
    sliderMemory.setValue(512);
    panelMemory.add(sliderMemory, "4, 1, fill, default");

    lblMemory = new JLabel("512"); //$NON-NLS-1$
    panelMemory.add(lblMemory, "6, 1, right, default");

    JLabel lblMb = new JLabel("MB");
    panelMemory.add(lblMb, "7, 1, left, default");

    tpMemoryHint = new JTextPane();
    tpMemoryHint.setOpaque(false);
    tpMemoryHint.setText(BUNDLE.getString("Settings.memory.hint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(tpMemoryHint, 0.833);
    panelMemory.add(tpMemoryHint, "2, 3, 6, 1, fill, fill");

    JPanel panelProxySettings = new JPanel();
    panelProxySettings.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.proxy"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelProxySettings, "4, 4, fill, fill");
    panelProxySettings.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    JLabel lblProxyHost = new JLabel(BUNDLE.getString("Settings.proxyhost")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyHost, "2, 2, right, default");

    tfProxyHost = new JTextField();
    lblProxyHost.setLabelFor(tfProxyHost);
    panelProxySettings.add(tfProxyHost, "4, 2, fill, default");
    tfProxyHost.setColumns(10);

    JLabel lblProxyPort = new JLabel(BUNDLE.getString("Settings.proxyport")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyPort, "2, 4, right, default");

    tfProxyPort = new JTextField();
    lblProxyPort.setLabelFor(tfProxyPort);
    panelProxySettings.add(tfProxyPort, "4, 4, fill, default");
    tfProxyPort.setColumns(10);

    JLabel lblProxyUser = new JLabel(BUNDLE.getString("Settings.proxyuser")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyUser, "2, 6, right, default");

    tfProxyUsername = new JTextField();
    lblProxyUser.setLabelFor(tfProxyUsername);
    panelProxySettings.add(tfProxyUsername, "4, 6, fill, default");
    tfProxyUsername.setColumns(10);

    JLabel lblProxyPassword = new JLabel(BUNDLE.getString("Settings.proxypass")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyPassword, "2, 8, right, default");

    tfProxyPassword = new JPasswordField();
    lblProxyPassword.setLabelFor(tfProxyPassword);
    panelProxySettings.add(tfProxyPassword, "4, 8, fill, default");

    JPanel panelMediaPlayer = new JPanel();
    panelMediaPlayer.setBorder(
            new TitledBorder(null, "MediaPlayer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelMediaPlayer, "2, 6, fill, fill");
    panelMediaPlayer.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    tpMediaPlayer = new JTextPane();
    tpMediaPlayer.setOpaque(false);
    TmmFontHelper.changeFont(tpMediaPlayer, 0.833);
    tpMediaPlayer.setText(BUNDLE.getString("Settings.mediaplayer.hint")); //$NON-NLS-1$
    panelMediaPlayer.add(tpMediaPlayer, "2, 2, 3, 1, fill, fill");

    tfMediaPlayer = new JTextField();
    panelMediaPlayer.add(tfMediaPlayer, "2, 4, fill, default");
    tfMediaPlayer.setColumns(10);

    btnSearchMediaPlayer = new JButton(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$
    btnSearchMediaPlayer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path file = TmmUIHelper.selectFile(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$
            if (file != null && Utils.isRegularFile(file) || Platform.isMac()) {
                tfMediaPlayer.setText(file.toAbsolutePath().toString());
            }
        }
    });
    panelMediaPlayer.add(btnSearchMediaPlayer, "4, 4");

    JPanel panelCache = new JPanel();
    panelCache.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.cache"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelCache, "4, 6, fill, fill");
    panelCache.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecache"));//$NON-NLS-1$
    panelCache.add(chckbxImageCache, "2, 2, 3, 1");

    JLabel lblImageCacheQuality = new JLabel(BUNDLE.getString("Settings.imagecachetype"));//$NON-NLS-1$
    panelCache.add(lblImageCacheQuality, "2, 4, right, default");

    cbImageCacheQuality = new JComboBox(ImageCache.CacheType.values());
    panelCache.add(cbImageCacheQuality, "4, 4, fill, default");

    JPanel panelAnalytics = new JPanel();
    panelAnalytics.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.analytics.border"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelAnalytics, "2, 8, fill, fill");
    panelAnalytics.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, }));

    chckbxAnalytics = new JCheckBox(BUNDLE.getString("Settings.analytics"));//$NON-NLS-1$
    panelAnalytics.add(chckbxAnalytics, "2, 2");

    JTextPane tpAnalyticsDescription = new JTextPane();
    tpAnalyticsDescription.setText(BUNDLE.getString("Settings.analytics.desc"));//$NON-NLS-1$
    tpAnalyticsDescription.setOpaque(false);
    panelAnalytics.add(tpAnalyticsDescription, "2, 4, fill, fill");

    JPanel panelMisc = new JPanel();
    panelMisc.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.misc"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelMisc, "4, 8, fill, fill");
    panelMisc.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    chckbxDeleteTrash = new JCheckBox(BUNDLE.getString("Settings.deletetrash"));
    panelMisc.add(chckbxDeleteTrash, "2, 2, 3, 1");

    initDataBindings();

    initMemorySlider();

    // listen to changes of the combo box
    ItemListener listener = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            checkChanges();
        }
    };

    cbLanguage.addItemListener(listener);
    cbFontSize.addItemListener(listener);
    cbFontFamily.addItemListener(listener);
}