Example usage for java.awt Font getSize

List of usage examples for java.awt Font getSize

Introduction

In this page you can find the example usage for java.awt Font getSize.

Prototype

public int getSize() 

Source Link

Document

Returns the point size of this Font , rounded to an integer.

Usage

From source file:ca.sqlpower.architect.swingui.TestPlayPen.java

/**
 * Returns a new value that is not equal to oldVal. The
 * returned object will be a new instance compatible with oldVal.  
 * //from  w w w  .j  a  v a2  s . com
 * @param property The property that should be modified.
 * @param oldVal The existing value of the property to modify.  The returned value
 * will not equal this one at the time this method was first called.
 */
private Object getNewDifferentValue(PropertyDescriptor property, Object oldVal) {
    Object newVal; // don't init here so compiler can warn if the
    // following code doesn't always give it a value
    if (property.getPropertyType() == String.class) {
        newVal = "new " + oldVal;
    } else if (property.getPropertyType() == Boolean.class || property.getPropertyType() == Boolean.TYPE) {
        if (oldVal == null) {
            newVal = new Boolean(false);
        } else {
            newVal = new Boolean(!((Boolean) oldVal).booleanValue());
        }
    } else if (property.getPropertyType() == Double.class || property.getPropertyType() == Double.TYPE) {
        if (oldVal == null) {
            newVal = new Double(0);
        } else {
            newVal = new Double(((Double) oldVal).doubleValue() + 1);
        }
    } else if (property.getPropertyType() == Integer.class || property.getPropertyType() == Integer.TYPE) {
        if (oldVal == null) {
            newVal = new Integer(0);
        } else {
            newVal = new Integer(((Integer) oldVal).intValue() + 1);
        }
    } else if (property.getPropertyType() == Color.class) {
        if (oldVal == null) {
            newVal = new Color(0xFAC157);
        } else {
            Color oldColor = (Color) oldVal;
            newVal = new Color((oldColor.getRGB() + 0xF00) % 0x1000000);
        }
    } else if (property.getPropertyType() == Font.class) {
        if (oldVal == null) {
            newVal = FontManager.getDefaultPhysicalFont();
        } else {
            Font oldFont = (Font) oldVal;
            newVal = new Font(oldFont.getFontName(), oldFont.getSize() + 2, oldFont.getStyle());
        }
    } else if (property.getPropertyType() == Set.class) {
        newVal = new HashSet();
        ((Set) newVal).add("test");
    } else if (property.getPropertyType() == List.class) {
        newVal = new ArrayList();
        ((List) newVal).add("test");
    } else if (property.getPropertyType() == Point.class) {
        newVal = new Point(1, 3);
    } else {
        throw new RuntimeException("This test case lacks a value for " + property.getName() + " (type "
                + property.getPropertyType().getName() + ") in getNewDifferentValue()");
    }

    return newVal;
}

From source file:com.itemanalysis.jmetrik.gui.JmetrikPreferencesManager.java

public void setFont(Font f) {
    p.put(OUTPUT_FONT, f.getFontName());
    p.putInt(OUTPUT_FONT_STYLE, f.getStyle());
    p.putInt(OUTPUT_FONT_SIZE, f.getSize());
}

From source file:org.ecoinformatics.seek.ecogrid.EcogridPreferencesTab.java

private void initButtonPanel() {

    // remember default button font
    final Font defaultUIMgrButtonFont = (Font) UIManager.get("Button.font");

    // now set our custom size, provided it's smaller than the default:
    int buttonFontSize = (defaultUIMgrButtonFont.getSize() < BUTTON_FONT_SIZE)
            ? defaultUIMgrButtonFont.getSize()
            : BUTTON_FONT_SIZE;// w w w. jav  a  2s.  c o  m

    final Font BUTTON_FONT = new Font(defaultUIMgrButtonFont.getFontName(), defaultUIMgrButtonFont.getStyle(),
            buttonFontSize);

    UIManager.put("Button.font", BUTTON_FONT);

    refreshButton = new JButton(new ServicesRefreshAction(
            StaticResources.getDisplayString("preferences.data.refresh", "Refresh"), this));
    refreshButton.setMinimumSize(EcogridPreferencesTab.BUTTONDIMENSION);
    refreshButton.setPreferredSize(EcogridPreferencesTab.BUTTONDIMENSION);
    refreshButton.setSize(EcogridPreferencesTab.BUTTONDIMENSION);
    // setMaximumSize was truncating label on osX. I don't know why. 
    // It seems about the same as how SearchUIJPanel does things. -derik
    //refreshButton.setMaximumSize(EcogridPreferencesTab.BUTTONDIMENSION);

    keepExistingCheckbox = new JCheckBox(
            StaticResources.getDisplayString("preferences.data.keepExistingSources", "Keep existing sources"));
    keepExistingCheckbox.setSelected(false);

    JPanel bottomPanel = new JPanel();

    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
    bottomPanel.add(refreshButton);
    bottomPanel.add(keepExistingCheckbox);

    newButtonPanel = new JPanel();
    newButtonPanel.setLayout(new BorderLayout());
    newButtonPanel.add(Box.createVerticalStrut(EcogridPreferencesTab.MARGINGSIZE), BorderLayout.NORTH);
    newButtonPanel.add(bottomPanel, BorderLayout.SOUTH);
    setButtonPanel(newButtonPanel);

    // restore default button font
    if (defaultUIMgrButtonFont != null) {
        UIManager.put("Button.font", defaultUIMgrButtonFont);
    }
}

From source file:com.tascape.qa.th.android.driver.App.java

/**
 * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting
 * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction.
 *
 * @param timeoutMinutes timeout in minutes to fail the manual steps
 *
 * @throws Exception if case of error//w  w w  . j a v  a 2  s  .  c o m
 */
public void interactManually(int timeoutMinutes) throws Exception {
    LOG.info("Start manual UI interaction");
    long end = System.currentTimeMillis() + timeoutMinutes * 60000L;

    AtomicBoolean visible = new AtomicBoolean(true);
    AtomicBoolean pass = new AtomicBoolean(false);
    String tName = Thread.currentThread().getName() + "m";
    SwingUtilities.invokeLater(() -> {
        JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail());
        jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

        JPanel jpContent = new JPanel(new BorderLayout());
        jd.setContentPane(jpContent);
        jpContent.setPreferredSize(new Dimension(1088, 828));
        jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

        JPanel jpInfo = new JPanel();
        jpContent.add(jpInfo, BorderLayout.PAGE_START);
        jpInfo.setLayout(new BorderLayout());
        {
            JButton jb = new JButton("PASS");
            jb.setForeground(Color.green.darker());
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_START);
            jb.addActionListener(event -> {
                pass.set(true);
                jd.dispose();
                visible.set(false);
            });
        }
        {
            JButton jb = new JButton("FAIL");
            jb.setForeground(Color.red);
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_END);
            jb.addActionListener(event -> {
                pass.set(false);
                jd.dispose();
                visible.set(false);
            });
        }

        JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        new SwingWorker<Long, Long>() {
            @Override
            protected Long doInBackground() throws Exception {
                while (System.currentTimeMillis() < end) {
                    Thread.sleep(1000);
                    long left = (end - System.currentTimeMillis()) / 1000;
                    this.publish(left);
                }
                return 0L;
            }

            @Override
            protected void process(List<Long> chunks) {
                Long l = chunks.get(chunks.size() - 1);
                jlTimeout.setText(l + " seconds left");
                if (l < 850) {
                    jlTimeout.setForeground(Color.red);
                }
            }
        }.execute();

        JPanel jpResponse = new JPanel(new BorderLayout());
        JPanel jpProgress = new JPanel(new BorderLayout());
        jpResponse.add(jpProgress, BorderLayout.PAGE_START);

        JTextArea jtaJson = new JTextArea();
        jtaJson.setEditable(false);
        jtaJson.setTabSize(4);
        Font font = jtaJson.getFont();
        jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize()));

        JTree jtView = new JTree();

        JTabbedPane jtp = new JTabbedPane();
        jtp.add("tree", new JScrollPane(jtView));
        jtp.add("json", new JScrollPane(jtaJson));

        jpResponse.add(jtp, BorderLayout.CENTER);

        JPanel jpScreen = new JPanel();
        jpScreen.setMinimumSize(new Dimension(200, 200));
        jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS));
        JScrollPane jsp1 = new JScrollPane(jpScreen);
        jpResponse.add(jsp1, BorderLayout.LINE_START);

        JPanel jpJs = new JPanel(new BorderLayout());
        JTextArea jtaJs = new JTextArea();
        jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER);

        JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs);
        jSplitPane.setResizeWeight(0.88);
        jpContent.add(jSplitPane, BorderLayout.CENTER);

        JPanel jpLog = new JPanel();
        jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS));

        JCheckBox jcbTap = new JCheckBox("Enable Click", null, false);
        jpLog.add(jcbTap);
        jpLog.add(Box.createHorizontalStrut(8));

        JButton jbLogUi = new JButton("Log Screen");
        jpResponse.add(jpLog, BorderLayout.PAGE_END);
        {
            jpLog.add(jbLogUi);
            jbLogUi.addActionListener((ActionEvent event) -> {
                jtaJson.setText("waiting for screenshot...");
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        LOG.debug("\n\n");
                        try {
                            WindowHierarchy wh = device.loadWindowHierarchy();
                            jtView.setModel(getModel(wh));

                            jtaJson.setText("");
                            jtaJson.append(wh.root.toJson().toString(2));
                            jtaJson.append("\n");

                            File png = device.takeDeviceScreenshot();
                            BufferedImage image = ImageIO.read(png);

                            int w = device.getDisplayWidth();
                            int h = device.getDisplayHeight();

                            BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                            Graphics2D g2 = resizedImg.createGraphics();
                            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                            g2.drawImage(image, 0, 0, w, h, null);
                            g2.dispose();

                            JLabel jLabel = new JLabel(new ImageIcon(resizedImg));
                            jpScreen.removeAll();
                            jsp1.setPreferredSize(new Dimension(w + 30, h));
                            jpScreen.add(jLabel);

                            jLabel.addMouseListener(new MouseAdapter() {
                                @Override
                                public void mouseClicked(MouseEvent e) {
                                    LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY());
                                    if (jcbTap.isSelected()) {
                                        device.click(e.getPoint().x, e.getPoint().y);
                                        device.waitForIdle();
                                        jbLogUi.doClick();
                                    }
                                }
                            });
                        } catch (Exception ex) {
                            LOG.error("Cannot log screen", ex);
                            jtaJson.append("Cannot log screen");
                        }
                        jtaJson.append("\n\n\n");
                        LOG.debug("\n\n");

                        jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1);
                        jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1);
                    }
                };
                t.start();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbLogMsg = new JButton("Log Message");
            jpLog.add(jbLogMsg);
            JTextField jtMsg = new JTextField(10);
            jpLog.add(jtMsg);
            jtMsg.addFocusListener(new FocusListener() {
                @Override
                public void focusLost(final FocusEvent pE) {
                }

                @Override
                public void focusGained(final FocusEvent pE) {
                    jtMsg.selectAll();
                }
            });
            jtMsg.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(java.awt.event.KeyEvent e) {
                    if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
                        jbLogMsg.doClick();
                    }
                }
            });
            jbLogMsg.addActionListener(event -> {
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        String msg = jtMsg.getText();
                        if (StringUtils.isNotBlank(msg)) {
                            LOG.info("{}", msg);
                            jtMsg.selectAll();
                        }
                    }
                };
                t.start();
                try {
                    t.join();
                } catch (InterruptedException ex) {
                    LOG.error("Cannot take screenshot", ex);
                }
                jtMsg.requestFocus();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbClear = new JButton("Clear");
            jpLog.add(jbClear);
            jbClear.addActionListener(event -> {
                jtaJson.setText("");
            });
        }

        JPanel jpAction = new JPanel();
        jpContent.add(jpAction, BorderLayout.PAGE_END);
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jpJs.add(jpAction, BorderLayout.PAGE_END);

        jd.pack();
        jd.setVisible(true);
        jd.setLocationRelativeTo(null);

        jbLogUi.doClick();
    });

    while (visible.get()) {
        if (System.currentTimeMillis() > end) {
            LOG.error("Manual UI interaction timeout");
            break;
        }
        Thread.sleep(500);
    }

    if (pass.get()) {
        LOG.info("Manual UI Interaction returns PASS");
    } else {
        Assert.fail("Manual UI Interaction returns FAIL");
    }
}

From source file:storybook.SbApp.java

public void setDefaultFont(Font font) {
    if (font == null) {
        return;//from  ww w.java  2  s .  c o m
    }
    defaultFont = font;
    resetUiFont();
    PrefUtil.set(PreferenceKey.DEFAULT_FONT_NAME, font.getName());
    PrefUtil.set(PreferenceKey.DEFAULT_FONT_SIZE, font.getSize());
    PrefUtil.set(PreferenceKey.DEFAULT_FONT_STYLE, font.getStyle());
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.ChannelAcquisitionComponent.java

/**
 * Transforms the detector metadata.//from w ww  .  j  ava  2s  . c om
 * 
 * @param details The value to transform.
 */
private void transformGeneralSource(Map<String, Object> details) {
    DataComponent comp;
    JLabel label;
    JComponent area;
    String key;
    Object value;
    label = new JLabel();
    Font font = label.getFont();
    int sizeLabel = font.getSize() - 2;
    Object selected;
    List notSet = (List) details.get(EditorUtil.NOT_SET);
    details.remove(EditorUtil.NOT_SET);
    if (notSet.size() > 0 && unsetGeneral == null) {
        unsetGeneral = parent.formatUnsetFieldsControl();
        unsetGeneral.setActionID(GENERAL);
        unsetGeneral.addPropertyChangeListener(this);
    }

    Set entrySet = details.entrySet();
    Entry entry;
    Iterator i = entrySet.iterator();
    boolean set;
    while (i.hasNext()) {
        entry = (Entry) i.next();
        key = (String) entry.getKey();
        set = !notSet.contains(key);
        value = entry.getValue();
        label = UIUtilities.setTextFont(key, Font.BOLD, sizeLabel);
        label.setBackground(UIUtilities.BACKGROUND_COLOR);
        if (EditorUtil.ILLUMINATION.equals(key)) {
            selected = model.getChannelEnumerationSelected(Editor.ILLUMINATION_TYPE, (String) value);
            if (selected != null)
                illuminationBox.setSelectedItem(selected);
            else {
                set = false;
                illuminationBox.setSelectedIndex(illuminationBox.getItemCount() - 1);
            }

            illuminationBox.setEditedColor(UIUtilities.EDITED_COLOR);
            area = illuminationBox;//parent.replaceCombobox(illuminationBox);
        } else if (EditorUtil.CONTRAST_METHOD.equals(key)) {
            selected = model.getChannelEnumerationSelected(Editor.ILLUMINATION_TYPE, (String) value);
            if (selected != null)
                contrastMethodBox.setSelectedItem(selected);
            else {
                set = false;
                contrastMethodBox.setSelectedIndex(contrastMethodBox.getItemCount() - 1);
            }

            contrastMethodBox.setEditedColor(UIUtilities.EDITED_COLOR);
            area = contrastMethodBox;//parent.replaceCombobox(contrastMethodBox);
        } else if (EditorUtil.MODE.equals(key)) {
            selected = model.getChannelEnumerationSelected(Editor.MODE, (String) value);
            if (selected != null)
                modeBox.setSelectedItem(selected);
            else {
                set = false;
                modeBox.setSelectedIndex(modeBox.getItemCount() - 1);
            }
            modeBox.setEditedColor(UIUtilities.EDITED_COLOR);
            area = modeBox;//parent.replaceCombobox(modeBox);
        } else {
            if (value instanceof Number) {
                area = UIUtilities.createComponent(NumericalTextField.class, null);
                String v = "";
                if (value instanceof Double) {
                    v = "" + UIUtilities.roundTwoDecimals(((Number) value).doubleValue());
                    ((NumericalTextField) area).setNumberType(Double.class);
                } else if (value instanceof Float) {
                    v = "" + UIUtilities.roundTwoDecimals(((Number) value).doubleValue());
                    ((NumericalTextField) area).setNumberType(Float.class);
                } else
                    v = "" + value;
                ((NumericalTextField) area).setText(v);
                ((NumericalTextField) area).setEditedColor(UIUtilities.EDITED_COLOR);
            } else {
                area = UIUtilities.createComponent(OMETextArea.class, null);
                if (value == null || value.equals("")) {
                    set = false;
                    value = AnnotationUI.DEFAULT_TEXT;
                }
                ((OMETextArea) area).setEditable(false);
                ((OMETextArea) area).setText((String) value);
                ((OMETextArea) area).setEditedColor(UIUtilities.EDITED_COLOR);
            }
        }
        area.setEnabled(!set);
        comp = new DataComponent(label, area);
        comp.setEnabled(false);
        comp.setSetField(!notSet.contains(key));
        fieldsGeneral.put(key, comp);
    }
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

/**
 * Appends a heading with bold text that streches from the default label column to the end of the form
 *
 * @param text The text of the heading/*  w w  w. java 2  s.c o m*/
 */
public void appendHeading(String text) {
    JLabel label = new JLabel(text);
    Font font = label.getFont();
    Font fontBold = new Font(font.getName(), Font.BOLD, font.getSize());
    label.setFont(fontBold);
    append(null, null, label, null, DEFAULT_LABEL_COLUMN, getColumnSpanToTheEnd(DEFAULT_LABEL_COLUMN));
}

From source file:FontChooser.java

public void setCurrentFont(Font font) {
    if (font == null) {
        font = jSample.getFont();/*from  w ww . j a va 2s . co  m*/
    }

    jFont.setText(font.getName());
    jFontActionPerformed(null);

    jStyle.setText(styleToString(font.getStyle()));
    jStyleActionPerformed(null);

    jSize.setText(Integer.toString(font.getSize()));
    jSizeActionPerformed(null);
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public void appendHeadingAndHelpButton(String text, String helpUrl) {
    JLabel label = new JLabel(text);
    Font font = label.getFont();
    Font fontBold = new Font(font.getName(), Font.BOLD, font.getSize());
    label.setFont(fontBold);//w w w  .j a v a 2s  .  co  m
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
    innerPanel.add(label);
    innerPanel.add(Box.createHorizontalGlue());
    innerPanel.add(UISupport.createFormButton(new ShowOnlineHelpAction(helpUrl)));
    append(null, null, innerPanel, null, DEFAULT_LABEL_COLUMN, getColumnSpanToTheEnd(DEFAULT_LABEL_COLUMN));
}

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

/**
 * Instantiates a new movie scraper settings panel.
 *//*from w  ww  . j a  va2  s.  c o  m*/
public MovieScraperSettingsPanel() {
    // data init
    MediaScraper defaultMediaScraper = MovieList.getInstance().getDefaultMediaScraper();
    int selectedIndex = 0;
    int counter = 0;
    for (MediaScraper scraper : MovieList.getInstance().getAvailableMediaScrapers()) {
        MovieScraper movieScraper = new MovieScraper(scraper);
        if (scraper.equals(defaultMediaScraper)) {
            movieScraper.defaultScraper = true;
            selectedIndex = counter;
        }
        scrapers.add(movieScraper);
        counter++;
    }
    // UI init
    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,
                    RowSpec.decode("default:grow"), }));
    JPanel panelMovieScrapers = new JPanel();
    panelMovieScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.metadata"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelMovieScrapers, "2, 2, 3, 1, fill, fill");
    panelMovieScrapers.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC,
            FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50dlu:grow"),
            FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("150dlu:grow"),
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));

    scrollPaneScraper = new JScrollPane();
    panelMovieScrapers.add(scrollPaneScraper, "2, 2, 3, 1, fill, fill");

    tableScraper = new JTable() {
        private static final long serialVersionUID = -144223066269069772L;

        @Override
        public java.awt.Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
            java.awt.Component comp = super.prepareRenderer(renderer, row, col);
            String value = getModel().getValueAt(row, 2).toString();
            if (!Globals.isDonator() && value.startsWith("Kodi")) { // FIXME: use scraper.isEnabled() somehow?
                comp.setBackground(Color.lightGray);
                comp.setEnabled(false);
            } else {
                comp.setBackground(Color.white);
                comp.setEnabled(true);
            }
            return comp;
        }
    };
    tableScraper.setRowHeight(29);
    scrollPaneScraper.setViewportView(tableScraper);

    scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(null);
    panelMovieScrapers.add(scrollPane, "6, 1, 1, 7, fill, fill");

    panelScraperDetails = new ScrollablePanel();
    scrollPane.setViewportView(panelScraperDetails);
    panelScraperDetails
            .setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] {
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";

        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, default, top");
    }

    panelScraperOptions = new JPanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JSeparator separator = new JSeparator();
    panelMovieScrapers.add(separator, "2, 4, 3, 1");

    JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$
    panelMovieScrapers.add(lblScraperLanguage, "2, 5, right, default");

    cbScraperLanguage = new JComboBox(MediaLanguages.values());
    panelMovieScrapers.add(cbScraperLanguage, "4, 5");

    JLabel lblCountry = new JLabel(BUNDLE.getString("Settings.certificationCountry")); //$NON-NLS-1$
    panelMovieScrapers.add(lblCountry, "2, 7, right, default");

    cbCertificationCountry = new JComboBox(CountryCode.values());
    panelMovieScrapers.add(cbCertificationCountry, "4, 7, fill, default");
    panelMovieScrapers.add(new JSeparator(), "2, 8, 5, 1");

    chckbxScraperFallback = new JCheckBox(BUNDLE.getString("Settings.scraperfallback")); //$NON-NLS-1$
    panelMovieScrapers.add(chckbxScraperFallback, "2, 9, 5, 1");

    panelScraperMetadataContainer = new JPanel();
    panelScraperMetadataContainer.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, //$NON-NLS-1$
            new Color(51, 51, 51)));
    add(panelScraperMetadataContainer, "2, 4, fill, fill");
    panelScraperMetadataContainer.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("10dlu"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, }));

    panelScraperMetadata = new MovieScraperMetadataPanel(
            Settings.getInstance().getMovieScraperMetadataConfig());
    panelScraperMetadataContainer.add(panelScraperMetadata, "1, 1, 4, 1, fill, default");

    chckbxAutomaticallyScrapeImages = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape")); //$NON-NLS-1$
    panelScraperMetadataContainer.add(chckbxAutomaticallyScrapeImages, "2, 3, 3, 1");

    chckbxImageLanguage = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape.language"));//$NON-NLS-1$
    panelScraperMetadataContainer.add(chckbxImageLanguage, "4, 5");

    panelAutomaticScraper = new JPanel();
    panelAutomaticScraper.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.automaticscraper"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelAutomaticScraper, "4, 4, fill, fill");
    panelAutomaticScraper.setLayout(new FormLayout(
            new ColumnSpec[] { 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, }));

    JLabel lblScraperTreshold = new JLabel(BUNDLE.getString("Settings.scraperTreshold")); //$NON-NLS-1$
    panelAutomaticScraper.add(lblScraperTreshold, "1, 2, default, top");

    sliderThreshold = new JSlider();
    sliderThreshold.setMinorTickSpacing(5);
    sliderThreshold.setMajorTickSpacing(10);
    sliderThreshold.setPaintTicks(true);
    sliderThreshold.setPaintLabels(true);
    sliderThreshold.setValue((int) (settings.getScraperThreshold() * 100));

    Hashtable<Integer, JLabel> labelTable = new java.util.Hashtable<>();
    labelTable.put(100, new JLabel("1.0"));
    labelTable.put(75, new JLabel("0.75"));
    labelTable.put(50, new JLabel("0.50"));
    labelTable.put(25, new JLabel("0.25"));
    labelTable.put(0, new JLabel("0.0"));
    sliderThreshold.setLabelTable(labelTable);
    sliderThreshold.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent arg0) {
            settings.setScraperThreshold(sliderThreshold.getValue() / 100.0);
        }
    });
    panelAutomaticScraper.add(sliderThreshold, "3, 2");

    lblScraperThresholdHint = new JTextPane();
    panelAutomaticScraper.add(lblScraperThresholdHint, "1, 6, 3, 1");
    lblScraperThresholdHint.setOpaque(false);
    TmmFontHelper.changeFont(lblScraperThresholdHint, 0.833);
    lblScraperThresholdHint.setText(BUNDLE.getString("Settings.scraperTreshold.hint")); //$NON-NLS-1$

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

    // implement listener to simulate button group
    tableScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                MovieScraper changedScraper = scrapers.get(row);
                // if flag default scraper was changed, change all other flags
                if (changedScraper.getDefaultScraper()) {
                    settings.setMovieScraper(changedScraper.getScraperId());
                    for (MovieScraper scraper : scrapers) {
                        if (scraper != changedScraper) {
                            scraper.setDefaultScraper(Boolean.FALSE);
                        }
                    }
                }
            }
        }
    });

    // implement selection listener to load settings
    tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default movie scraper
    if (counter > 0) {
        tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}