Example usage for com.jgoodies.forms.layout CellConstraints TOP

List of usage examples for com.jgoodies.forms.layout CellConstraints TOP

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints TOP.

Prototype

Alignment TOP

To view the source code for com.jgoodies.forms.layout CellConstraints TOP.

Click Source Link

Document

Put the component in the top.

Usage

From source file:tvpearlplugin.TVPearlProgramPanel.java

License:Open Source License

private void createUI() {
    Color color = mTextColor;/*from w  w w . j  a v a 2 s.c  o  m*/
    final Calendar now = Calendar.getInstance();

    if ((mProgram != null && mProgram.isExpired()) || mPearlProgram.getStart().before(now)) {
        color = Color.gray;
    }

    setLayout(new FormLayout("pref, pref, fill:min:grow, pref", "pref, pref"));
    CellConstraints cc = new CellConstraints();
    setOpaque(true);
    JLabel label = new JLabel(TVPearlPlugin.getInstance().getProgramIcon(mProgram != null));
    label.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
    add(label, cc.xywh(1, 1, 1, 2));

    label = new JLabel(getHeader());
    label.setForeground(color);
    label.setFont(mHeaderFont);
    add(label, cc.xy(2, 1));

    label = new JLabel(getAuthor());
    label.setForeground(color);
    label.setFont(mHeaderFont);
    label.setAlignmentX(Component.RIGHT_ALIGNMENT);
    add(label, cc.xyw(3, 1, 2, CellConstraints.RIGHT, CellConstraints.TOP));

    label = new JLabel(getBody());
    label.setForeground(color);
    label.setFont(mBodyFont);
    add(label, cc.xyw(2, 2, 2));

    if (mIconList != null) {
        JPanel iconPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 1, 1));
        iconPanel.setOpaque(false);
        iconPanel.setAlignmentX(Component.RIGHT_ALIGNMENT);
        add(iconPanel, cc.xy(4, 2));
        for (int i = 0; i < mIconList.length; i++) {
            label = new JLabel(mIconList[i]);
            label.setOpaque(false);
            iconPanel.add(label);
        }
    }

}

From source file:wirschauenplugin.CreateOmdbAbstractDialog.java

License:Open Source License

/**
 * creates an application modal dialog to input an abstract.
 *
 * @param parent the parent window of this dialog
 * @param program the program, which the abstract is for (to display some data, e.g. the name of the program)
 * @param wirSchauenEvent the WirSchauenEvent corresponding to the program (to display the omdb-link and film/series)
 * @param oldOmdbAbstract the old abstract for the program (init value for the input field)
 */// w w w .ja v  a2s .  co m
public CreateOmdbAbstractDialog(final Window parent, final Program program,
        final WirSchauenEvent wirSchauenEvent, final String oldOmdbAbstract) {
    //create the window
    super(parent,
            WirSchauenPlugin.LOCALIZER.msg("CreateOmdbAbstractDialog.DialogTitle", "Description for OMDB.org"),
            ModalityType.APPLICATION_MODAL);
    UiUtilities.registerForClosing(this); //register esc-button
    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(Borders.DLU4_BORDER);
    contentPane.setLayout(new FormLayout("pref, 3dlu, pref:grow, pref",
            "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, fill:50dlu:grow, 3dlu, pref"));
    CellConstraints cellConstraints = new CellConstraints();
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent e) {
            close();
        }
    });

    //labels for movie and episode titles (not changeable)
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Title", "Title")),
            cellConstraints.xy(1, 1));
    contentPane.add(DialogUtil.createReadOnlySelectAllTextField(program.getTitle()),
            cellConstraints.xyw(3, 1, 2));
    //if there is no episode title, take the episode number
    String episodeTitle = program.getTextField(ProgramFieldType.EPISODE_TYPE);
    if (episodeTitle == null || episodeTitle.length() == 0) {
        episodeTitle = program.getIntFieldAsString(ProgramFieldType.EPISODE_NUMBER_TYPE);
    }
    //if any episode id (title or number) was found, display it
    if (episodeTitle != null && episodeTitle.length() > 0) {
        contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Episode", "Episode")),
                cellConstraints.xy(1, 3));
        contentPane.add(DialogUtil.createReadOnlySelectAllTextField(episodeTitle),
                cellConstraints.xyw(3, 3, 2));
    }

    //omdb-link (not changeable)
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.OmdbUrl", "URL")),
            cellConstraints.xy(1, 5));
    contentPane.add(DialogUtil.createReadOnlySelectAllTextField(wirSchauenEvent.getOmdbUrl()),
            cellConstraints.xy(3, 5));
    //this buttons opens the omdb-page for this program
    contentPane.add(
            DialogUtil.createUrlButton(wirSchauenEvent.getOmdbUrl(),
                    WirSchauenPlugin.LOCALIZER.msg("OmdbButton", "Open OMDB in Browser")),
            cellConstraints.xy(4, 5));

    //category (movie or series, not changeable)
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Category", "Category")),
            cellConstraints.xy(1, 7));
    contentPane.add(
            DialogUtil.createReadOnlySelectAllTextField(mapCategoryToString(wirSchauenEvent.getCategory())),
            cellConstraints.xyw(3, 7, 2));

    //description/abstract (changeable)
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Description", "Description")),
            cellConstraints.xy(1, 9, CellConstraints.DEFAULT, CellConstraints.TOP));
    final DescriptionInputField descriptionInputField = new DescriptionInputField(
            CreateOmdbAbstractDialog.MAX_CHARS_IN_ABSTRACT, oldOmdbAbstract,
            WirSchauenPlugin.LOCALIZER.msg("RemainingChars", "%s Characters remaining"));
    contentPane.add(descriptionInputField, cellConstraints.xyw(3, 9, 2));

    //buttons (ok, cancel)
    JButton okButton = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    okButton.setEnabled(false);
    //the ok-button is controlled by the input field (eg deactivated when no input). therefore the DocumentButtonController.
    descriptionInputField.addDocumentListener(new DocumentButtonController(okButton, oldOmdbAbstract));
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            //provide the input and close the dialog
            mOmdbAbstractInput = descriptionInputField.getText();
            setVisible(false);
            dispose();
        }
    });
    final JButton cancelButton = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            close();
        }
    });
    final ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addGlue();
    builder.addGriddedButtons(new JButton[] { okButton, cancelButton });
    contentPane.add(builder.getPanel(), cellConstraints.xyw(1, 11, 4));

    pack();
}

From source file:wirschauenplugin.CreateWirSchauenDataDialog.java

License:Open Source License

/**
 * creates an application modal dialog to input the wirschauen data.
 *
 * @param parent the parent window of this dialog
 * @param program the program, which the data is for
 * @param wirSchauenEvent the (old) wirschauen data loaded from the server
 */// www.j a  v a  2s  .c om
public CreateWirSchauenDataDialog(final Window parent, final Program program,
        final WirSchauenEvent wirSchauenEvent) {
    //create the window
    super(parent, WirSchauenPlugin.LOCALIZER.msg("CreateWirSchauenDataDialog.DialogTitle",
            "Description for WirSchauen.de"), ModalityType.APPLICATION_MODAL);
    UiUtilities.registerForClosing(this);
    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(Borders.DLU4_BORDER);
    contentPane.setLayout(new FormLayout("pref, 3dlu, pref:grow",
            "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, fill:50dlu:grow, 3dlu, pref, pref, pref, 3dlu, pref"));
    CellConstraints cellConstraints = new CellConstraints();
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent e) {
            close();
        }
    });

    //labels for movie and episode titles
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Title", "Title")),
            cellConstraints.xy(1, 1));
    contentPane.add(DialogUtil.createReadOnlySelectAllTextField(program.getTitle()), cellConstraints.xy(3, 1));
    //if there is no episode title, take the episode number
    String episodeTitle = program.getTextField(ProgramFieldType.EPISODE_TYPE);
    if (episodeTitle == null || episodeTitle.length() == 0) {
        episodeTitle = program.getIntFieldAsString(ProgramFieldType.EPISODE_NUMBER_TYPE);
    }
    //if any episode id (title or number) was found, display it
    if (episodeTitle != null && episodeTitle.length() > 0) {
        contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Episode", "Episode")),
                cellConstraints.xy(1, 3));
        contentPane.add(DialogUtil.createReadOnlySelectAllTextField(episodeTitle), cellConstraints.xy(3, 3));
    }

    //dropdown category (movie or series)
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Category", "Category")),
            cellConstraints.xy(1, 5));
    final JComboBox categoryDropdown = DialogUtil.createUneditableDropdown(
            new String[] { WirSchauenPlugin.LOCALIZER.msg("Category.NotSet", "not yet set"),
                    WirSchauenPlugin.LOCALIZER.msg("Category.Movie", "Movie"),
                    WirSchauenPlugin.LOCALIZER.msg("Category.Series", "Series"),
                    WirSchauenPlugin.LOCALIZER.msg("Category.Other", "Other") });
    contentPane.add(categoryDropdown, cellConstraints.xy(3, 5));

    //dropdown genre
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Genre", "Genre")),
            cellConstraints.xy(1, 7));
    final JComboBox genreComboBox = DialogUtil.createEditableDropdown(loadGenres());
    contentPane.add(genreComboBox, cellConstraints.xy(3, 7));

    //description/abstract
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Description", "Description")),
            cellConstraints.xy(1, 9, CellConstraints.DEFAULT, CellConstraints.TOP));
    final DescriptionInputField descriptionInputField = new DescriptionInputField(
            CreateWirSchauenDataDialog.MAX_CHARS_IN_ABSTRACT, "",
            WirSchauenPlugin.LOCALIZER.msg("RemainingChars", "%s characters remaining"));
    contentPane.add(descriptionInputField, cellConstraints.xy(3, 9));

    // format information
    contentPane.add(new JLabel(WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Format", "Format")),
            cellConstraints.xy(1, 11));
    final JCheckBox subtitleCheckBox = new JCheckBox(
            WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Subtitles", "Subtitles"));
    final JCheckBox owsCheckBox = new JCheckBox(
            WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.OwS", "Original with subtitles"));
    final JCheckBox premiereCheckBox = new JCheckBox(
            WirSchauenPlugin.LOCALIZER.msg("PropertyLabels.Premiere", "TV Premiere"));
    contentPane.add(subtitleCheckBox, cellConstraints.xy(3, 11));
    contentPane.add(owsCheckBox, cellConstraints.xy(3, 12));
    contentPane.add(premiereCheckBox, cellConstraints.xy(3, 13));

    //buttons (ok, cancel)
    JButton okButton = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    okButton.setEnabled(false);
    //the ok-button is controlled by the abstract-input (i.e. deactivated if no input) and by the
    //category-dropdown (i.e. deactivated if no category selected)
    DocumentAndItemButtonController buttonController = new DocumentAndItemButtonController(okButton);
    categoryDropdown.addItemListener(buttonController);
    descriptionInputField.addDocumentListener(buttonController);
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            //provide the input and close the dialog
            setVisible(false);
            mWirSchauenInput = new WirSchauenEvent();
            if (categoryDropdown.getSelectedIndex() == 1) {
                mWirSchauenInput.setCategory(WirSchauenEvent.CATEGORY_MOVIE);
            } else if (categoryDropdown.getSelectedIndex() == 2) {
                mWirSchauenInput.setCategory(WirSchauenEvent.CATEGORY_SERIES);
            } else {
                mWirSchauenInput.setCategory(WirSchauenEvent.CATEGORY_OTHER);
            }
            mWirSchauenInput.setDesc(descriptionInputField.getText());
            mWirSchauenInput.setGenre((String) genreComboBox.getSelectedItem());
            mWirSchauenInput.setOmu(owsCheckBox.isSelected());
            mWirSchauenInput.setPremiere(premiereCheckBox.isSelected());
            mWirSchauenInput.setSubtitles(subtitleCheckBox.isSelected());
            dispose();
        }
    });
    final JButton cancelButton = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            close();
        }
    });
    final ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addGlue();
    builder.addGriddedButtons(new JButton[] { okButton, cancelButton });

    contentPane.add(builder.getPanel(), cellConstraints.xyw(1, 15, 3));

    pack();
}