Example usage for javax.swing JSeparator setPreferredSize

List of usage examples for javax.swing JSeparator setPreferredSize

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:org.tinymediamanager.ui.dialogs.ImageChooserDialog.java

/**
 * Instantiates a new image chooser dialog.
 * /*from   w  ww  .  j a v a  2s. c  o m*/
 * @param ids
 *          the ids
 * @param type
 *          the type
 * @param artworkScrapers
 *          the artwork providers
 * @param imageLabel
 *          the image label
 * @param extraThumbs
 *          the extra thumbs
 * @param extraFanarts
 *          the extra fanarts
 * @param mediaType
 *          the media for for which artwork has to be chosen
 */
public ImageChooserDialog(final HashMap<String, Object> ids, ImageType type, List<MediaScraper> artworkScrapers,
        ImageLabel imageLabel, List<String> extraThumbs, List<String> extraFanarts, MediaType mediaType) {
    super("", "imageChooser");
    this.imageLabel = imageLabel;
    this.type = type;
    this.mediaType = mediaType;
    this.artworkScrapers = artworkScrapers;
    this.extraThumbs = extraThumbs;
    this.extraFanarts = extraFanarts;

    switch (type) {
    case FANART:
        setTitle(BUNDLE.getString("image.choose.fanart")); //$NON-NLS-1$
        break;

    case POSTER:
        setTitle(BUNDLE.getString("image.choose.poster")); //$NON-NLS-1$
        break;

    case BANNER:
        setTitle(BUNDLE.getString("image.choose.banner")); //$NON-NLS-1$
        break;

    case SEASON:
        Object season = ids.get("tvShowSeason");
        if (season != null) {
            setTitle(BUNDLE.getString("image.choose.season") + " - " + BUNDLE.getString("metatag.season") + " " //$NON-NLS-1$
                    + season);
        } else {
            setTitle(BUNDLE.getString("image.choose.season")); //$NON-NLS-1$
        }
        break;

    case CLEARART:
        setTitle(BUNDLE.getString("image.choose.clearart")); //$NON-NLS-1$
        break;

    case DISC:
        setTitle(BUNDLE.getString("image.choose.disc")); //$NON-NLS-1$
        break;

    case LOGO:
        setTitle(BUNDLE.getString("image.choose.logo")); //$NON-NLS-1$
        break;

    case CLEARLOGO:
        setTitle(BUNDLE.getString("image.choose.clearlogo")); //$NON-NLS-1$
        break;

    case THUMB:
        setTitle(BUNDLE.getString("image.choose.thumb")); //$NON-NLS-1$
        break;
    }

    setBounds(5, 5, 1000, 590);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("258px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.LABEL_COMPONENT_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("fill:266px:grow"),
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));
    {
        scrollPane = new JScrollPane();
        scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        contentPanel.add(scrollPane, "2, 2, 3, 1, fill, fill");
        {
            panelImages = new JPanel();
            scrollPane.setViewportView(panelImages);
            scrollPane.getVerticalScrollBar().setUnitIncrement(16);
            panelImages.setLayout(new WrapLayout(FlowLayout.LEFT));
        }
    }
    {
        tfImageUrl = new EnhancedTextField(BUNDLE.getString("image.inserturl")); //$NON-NLS-1$
        contentPanel.add(tfImageUrl, "2, 4, fill, default");
        tfImageUrl.setColumns(10);
        JButton btnAddImage = new JButton(BUNDLE.getString("image.downloadimage")); //$NON-NLS-1$
        btnAddImage.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (StringUtils.isNotBlank(tfImageUrl.getText())) {
                    downloadAndPreviewImage(tfImageUrl.getText());
                }
            }
        });
        contentPanel.add(btnAddImage, "4, 4");

    }
    {
        JPanel bottomPane = new JPanel();
        getContentPane().add(bottomPane, BorderLayout.SOUTH);
        bottomPane.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.NARROW_LINE_GAP_ROWSPEC, RowSpec.decode("23px:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));
        {
            if (type == ImageType.FANART && extraFanarts != null && extraThumbs != null) {
                JPanel panelExtraButtons = new JPanel();
                bottomPane.add(panelExtraButtons, "2, 2, fill, bottom");
                panelExtraButtons.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
                {
                    if (mediaType == MediaType.MOVIE
                            && MovieModuleManager.MOVIE_SETTINGS.isImageExtraThumbs()) {
                        JLabel labelThumbs = new JLabel("Extrathumbs:");
                        panelExtraButtons.add(labelThumbs);
                        JButton btnMarkExtrathumbs = new JButton("");
                        btnMarkExtrathumbs.setMargin(new Insets(0, 0, 0, 0));
                        btnMarkExtrathumbs.setIcon(IconManager.CHECK_ALL);
                        btnMarkExtrathumbs.setToolTipText(BUNDLE.getString("image.extrathumbs.markall")); //$NON-NLS-1$
                        btnMarkExtrathumbs.addActionListener(new ActionListener() {

                            @Override
                            public void actionPerformed(ActionEvent arg0) {
                                for (JToggleButton button : buttons) {
                                    if (button
                                            .getClientProperty("MediaArtworkExtrathumb") instanceof JCheckBox) {
                                        JCheckBox chkbx = (JCheckBox) button
                                                .getClientProperty("MediaArtworkExtrathumb");
                                        chkbx.setSelected(true);
                                    }
                                }
                            }
                        });
                        panelExtraButtons.add(btnMarkExtrathumbs);
                        JButton btnUnMarkExtrathumbs = new JButton("");
                        btnUnMarkExtrathumbs.setMargin(new Insets(0, 0, 0, 0));
                        btnUnMarkExtrathumbs.setIcon(IconManager.UNCHECK_ALL);
                        btnUnMarkExtrathumbs.setToolTipText(BUNDLE.getString("image.extrathumbs.unmarkall")); //$NON-NLS-1$
                        btnUnMarkExtrathumbs.addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent arg0) {
                                for (JToggleButton button : buttons) {
                                    if (button
                                            .getClientProperty("MediaArtworkExtrathumb") instanceof JCheckBox) {
                                        JCheckBox chkbx = (JCheckBox) button
                                                .getClientProperty("MediaArtworkExtrathumb");
                                        chkbx.setSelected(false);
                                    }
                                }
                            }
                        });
                        panelExtraButtons.add(btnUnMarkExtrathumbs);
                    }
                    if (mediaType == MediaType.MOVIE && MovieModuleManager.MOVIE_SETTINGS.isImageExtraThumbs()
                            && MovieModuleManager.MOVIE_SETTINGS.isImageExtraFanart())

                    {
                        JSeparator separator = new JSeparator(SwingConstants.VERTICAL);
                        separator.setPreferredSize(new Dimension(2, 16));
                        panelExtraButtons.add(separator);
                    }
                    if (mediaType == MediaType.MOVIE && MovieModuleManager.MOVIE_SETTINGS.isImageExtraFanart())

                    {
                        JLabel labelFanart = new JLabel("Extrafanart:");
                        panelExtraButtons.add(labelFanart);
                        JButton btnMarkExtrafanart = new JButton("");
                        btnMarkExtrafanart.setMargin(new Insets(0, 0, 0, 0));
                        btnMarkExtrafanart.setIcon(IconManager.CHECK_ALL);
                        btnMarkExtrafanart.setToolTipText(BUNDLE.getString("image.extrafanart.markall")); //$NON-NLS-1$
                        btnMarkExtrafanart.addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent arg0) {
                                for (JToggleButton button : buttons) {
                                    if (button.getClientProperty(
                                            "MediaArtworkExtrafanart") instanceof JCheckBox) {
                                        JCheckBox chkbx = (JCheckBox) button
                                                .getClientProperty("MediaArtworkExtrafanart");
                                        chkbx.setSelected(true);
                                    }
                                }
                            }
                        });
                        panelExtraButtons.add(btnMarkExtrafanart);
                        JButton btnUnMarkExtrafanart = new JButton("");
                        btnUnMarkExtrafanart.setMargin(new Insets(0, 0, 0, 0));
                        btnUnMarkExtrafanart.setIcon(IconManager.UNCHECK_ALL);
                        btnUnMarkExtrafanart.setToolTipText(BUNDLE.getString("image.extrafanart.unmarkall")); //$NON-NLS-1$
                        btnUnMarkExtrafanart.addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent arg0) {
                                for (JToggleButton button : buttons) {
                                    if (button.getClientProperty(
                                            "MediaArtworkExtrafanart") instanceof JCheckBox) {
                                        JCheckBox chkbx = (JCheckBox) button
                                                .getClientProperty("MediaArtworkExtrafanart");
                                        chkbx.setSelected(false);
                                    }
                                }
                            }
                        });
                        panelExtraButtons.add(btnUnMarkExtrafanart);
                    }
                }
            }
        }

        {
            progressBar = new JProgressBar();
            bottomPane.add(progressBar, "2, 4");
        }
        {
            lblProgressAction = new JLabel("");
            bottomPane.add(lblProgressAction, "4, 4");
        }
        {

            JPanel buttonPane = new JPanel();
            EqualsLayout layout = new EqualsLayout(5);
            buttonPane.setLayout(layout);
            layout.setMinWidth(100);
            bottomPane.add(buttonPane, "6, 4, fill, top");
            JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
            okButton.setAction(actionOK);
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);

            getRootPane().setDefaultButton(okButton);

            JButton btnAddFile = new JButton(BUNDLE.getString("Button.addfile")); //$NON-NLS-1$
            btnAddFile.setAction(actionLocalFile);
            buttonPane.add(btnAddFile);

            JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
            cancelButton.setAction(actionCancel);
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }

    }

    task = new DownloadTask(ids, this.artworkScrapers);
    task.execute();
}