Example usage for com.jgoodies.forms.layout Sizes dialogUnitYAsPixel

List of usage examples for com.jgoodies.forms.layout Sizes dialogUnitYAsPixel

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout Sizes dialogUnitYAsPixel.

Prototype

public static int dialogUnitYAsPixel(int dluY, Component component) 

Source Link

Document

Converts vertical dialog units and returns pixels.

Usage

From source file:tvbrowser.ui.settings.looksSettings.SkinLNFSettings.java

License:Open Source License

/**
 * Create the GUI/*from   ww  w. ja va2 s  .co  m*/
 */
private void createGui() {
    JPanel content = (JPanel) getContentPane();

    content.setLayout(new FormLayout("5dlu, fill:50dlu:grow, 3dlu",
            "pref, 5dlu, pref, 5dlu, pref, 5dlu, pref, fill:3dlu:grow, pref"));
    content.setBorder(Borders.DLU4_BORDER);

    CellConstraints cc = new CellConstraints();

    content.add(DefaultComponentFactory.getInstance()
            .createSeparator(Localizer.getLocalization(Localizer.I18N_HELP)), cc.xyw(1, 1, 3));

    content.add(
            UiUtilities.createHtmlHelpTextArea(
                    mLocalizer.msg("skinLFInfo", "Skin Info", "http://tvbrowser.org/themepacks.php")),
            cc.xyw(2, 3, 2));

    String temp = Settings.propSkinLFThemepack.getString();
    temp = StringUtils.substringAfterLast(temp, File.separator);

    String[] skins = getThemePacks();

    mThemePack = new JComboBox(skins);
    mThemePack.setSelectedItem(temp);

    content.add(DefaultComponentFactory.getInstance()
            .createSeparator(mLocalizer.msg("chooseThemepack", "Choose Themepack")), cc.xyw(1, 5, 3));
    content.add(mThemePack, cc.xy(2, 7));

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });

    JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            cancelPressed();
        }
    });

    ButtonBarBuilder2 bar = new ButtonBarBuilder2();
    bar.addButton(new JButton[] { ok, cancel });

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    panel.add(bar.getPanel());
    content.add(panel, cc.xyw(1, 9, 3));

    UiUtilities.registerForClosing(this);

    setPreferredSize(new Dimension(Sizes.dialogUnitXAsPixel(270, this), Sizes.dialogUnitYAsPixel(180, this)));
    pack();
}

From source file:twitterplugin.TwitterDialog.java

License:Open Source License

private void createGui(final Program program, final String format) {
    final JPanel panel = (JPanel) getContentPane();
    panel.setBorder(Borders.DLU4_BORDER);
    final FormLayout layout = new FormLayout("3dlu, fill:min:grow, 3dlu");
    panel.setLayout(layout);// w  w w.  j av a2 s  .  c  om

    int currentRow = 1;

    layout.appendRow(RowSpec.decode("pref"));
    layout.appendRow(RowSpec.decode("5dlu"));

    final CellConstraints cc = new CellConstraints();
    panel.add(
            DefaultComponentFactory.getInstance().createSeparator(mLocalizer.msg("message", "Twitter Message")),
            cc.xyw(1, currentRow, 3));

    layout.appendRow(RowSpec.decode("fill:pref:grow"));
    layout.appendRow(RowSpec.decode("5dlu"));

    mMessage = new JTextArea();
    mMessage.setLineWrap(true);
    mMessage.setWrapStyleWord(true);
    panel.add(new JScrollPane(mMessage), cc.xy(2, currentRow += 2));

    layout.appendRow(RowSpec.decode("pref"));
    layout.appendRow(RowSpec.decode("5dlu"));

    final JLabel warningCounter = new JLabel("");
    panel.add(warningCounter, cc.xy(2, currentRow += 2));

    final ButtonBarBuilder buttonBar = new ButtonBarBuilder();
    buttonBar.addGlue();

    final JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            okPressed();
        }
    });
    final JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            close();
        }
    });

    buttonBar.addGriddedButtons(new JButton[] { ok, cancel });

    layout.appendRow(RowSpec.decode("pref"));
    layout.appendRow(RowSpec.decode("5dlu"));

    panel.add(buttonBar.getPanel(), cc.xyw(1, currentRow += 2, 3));

    setSize(Sizes.dialogUnitXAsPixel(200, this), Sizes.dialogUnitYAsPixel(200, this));

    UiUtilities.registerForClosing(this);
    getRootPane().setDefaultButton(cancel);

    mMessage.getDocument().addDocumentListener(new DocumentListener() {
        public void insertUpdate(final DocumentEvent e) {
            updateWarning();
        }

        public void removeUpdate(final DocumentEvent e) {
            updateWarning();
        }

        public void changedUpdate(final DocumentEvent e) {
            updateWarning();
        }

        private void updateWarning() {
            final int num = TWEET_MAX_CHARS - mMessage.getText().trim().length();
            warningCounter.setText(mLocalizer.msg("counter", "{0} chars left", num));
            if (num < 0) {
                warningCounter.setForeground(Color.RED);
            } else {
                warningCounter.setForeground(new JLabel().getForeground());
            }
            ok.setEnabled(num >= 0 && num != TWEET_MAX_CHARS);
        }

    });
    mMessage.setText(new ParamParser().analyse(format, program));
}

From source file:twitterplugin.TwitterLoginDialog.java

License:Open Source License

/**
 * Create Gui/*from  w  ww  .  ja  va 2s  . c  o m*/
 */
private void createGui() {
    setTitle(mLocalizer.msg("login", "Login"));

    UiUtilities.registerForClosing(this);

    PanelBuilder content = new PanelBuilder(
            new FormLayout("5dlu, pref:grow(0.5), 3dlu, 100dlu, fill:pref:grow(0.5), 5dlu"));

    CellConstraints cc = new CellConstraints();

    final Twitter twitter = new TwitterFactory().getInstance();
    twitter.setOAuthConsumer(mSettings.getConsumerKey(), mSettings.getConsumerSecret());
    try {
        mRequestToken = twitter.getOAuthRequestToken();
        mAuthorizationUrl = mRequestToken.getAuthorizationURL();
    } catch (TwitterException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    content.appendRow("3dlu");
    content.appendRow("pref");
    mLabelBrowser = new JLabel("1. " + mLocalizer.msg("step1", "Open authentication page on Twitter"));
    content.add(mLabelBrowser, cc.xy(2, content.getRowCount()));
    mUrlButton = new JButton(mLocalizer.msg("openBrowser", "Open browser"));
    mUrlButton.setToolTipText(mAuthorizationUrl);
    content.add(mUrlButton, cc.xy(4, content.getRowCount()));
    mUrlButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Launch.openURL(mAuthorizationUrl);
        }
    });

    content.appendRow("3dlu");
    content.appendRow("pref");
    mLabelPin = new JLabel("2. " + mLocalizer.msg("step2", "Enter PIN from web page"));
    content.add(mLabelPin, cc.xy(2, content.getRowCount()));
    mPIN = new JTextField();
    content.add(mPIN, cc.xy(4, content.getRowCount()));

    ButtonBarBuilder builder = new ButtonBarBuilder();
    builder.addGlue();

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));

    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            mReturnValue = JOptionPane.OK_OPTION;
            AccessToken accessToken = null;
            try {
                String pin = mPIN.getText().trim();
                if (pin.length() > 0) {
                    accessToken = twitter.getOAuthAccessToken(mRequestToken, pin);
                } else {
                    accessToken = twitter.getOAuthAccessToken();
                }
            } catch (TwitterException te) {
                if (401 == te.getStatusCode()) {
                    System.out.println("Unable to get the access token.");
                } else {
                    te.printStackTrace();
                }
            }
            try {
                twitter.verifyCredentials().getId();
                mSettings.setAccessToken(accessToken);
            } catch (TwitterException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            setVisible(false);
        }
    });

    getRootPane().setDefaultButton(ok);

    JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));

    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            close();
        }
    });

    builder.addGriddedButtons(new JButton[] { ok, cancel });

    content.appendRow("fill:pref:grow");
    content.appendRow("pref");
    content.add(builder.getPanel(), cc.xyw(1, content.getRowCount(), 4));

    content.appendRow("5dlu");
    content.setBorder(Borders.DIALOG_BORDER);
    getContentPane().add(content.getPanel());

    UiUtilities.setSize(this, Sizes.dialogUnitXAsPixel(200, this), Sizes.dialogUnitYAsPixel(140, this));
}

From source file:uk.ac.ebi.mnb.view.DropdownDialog.java

License:Open Source License

/**
 * Sets the default layout of the dialog. Class wishing to use Default layout
 * should overrider getDescription and getForm. In addition to adding
 * values to the ActionProperties file./*ww w. j  a  v a2 s. com*/
 */
public void setDefaultLayout() {

    Box box = Box.createVerticalBox();

    box.setBorder(Borders.DLU7_BORDER);

    JLabel label = getDescription();
    JPanel form = getForm();
    JPanel nav = getNavigation();

    // make sure all is aligned to the left
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    form.setAlignmentX(Component.LEFT_ALIGNMENT);
    nav.setAlignmentX(Component.LEFT_ALIGNMENT);

    int paddingPixels = Sizes.dialogUnitYAsPixel(4, box);

    box.add(Box.createVerticalStrut(paddingPixels));

    box.add(label);

    box.add(Box.createVerticalStrut(paddingPixels));
    box.add(new JSeparator(SwingConstants.HORIZONTAL));
    box.add(Box.createVerticalStrut(paddingPixels));

    box.add(form);

    box.add(Box.createVerticalStrut(paddingPixels));
    box.add(new JSeparator(SwingConstants.HORIZONTAL));
    box.add(Box.createVerticalStrut(paddingPixels));

    box.add(nav);

    this.setContentPane(box);

    getRootPane().setDefaultButton(active);

}

From source file:util.ui.login.LoginDialog.java

License:Open Source License

/**
 * Create Gui//from   ww  w .  jav  a 2 s. com
 */
private void createGui() {
    setTitle(mLocalizer.msg("login", "Login"));

    UiUtilities.registerForClosing(this);

    JPanel content = (JPanel) getContentPane();

    content.setLayout(new FormLayout("5dlu, pref, 3dlu, fill:100dlu:grow(0.5), pref, 5dlu",
            "30dlu, 5dlu, pref, 3dlu, pref, 3dlu, pref, fill:pref:grow, pref, 5dlu"));

    CellConstraints cc = new CellConstraints();

    JPanel panel = new JPanel(new FormLayout("7dlu, pref, fill:pref:grow", "7dlu, center:21dlu, 2dlu, 1px"));
    panel.setOpaque(true);
    panel.setBackground(Color.WHITE);
    panel.setForeground(Color.BLACK);

    JLabel top = new JLabel(mLocalizer.msg("title", "Login"));
    top.setFont(top.getFont().deriveFont(Font.BOLD, 20));

    panel.add(top, cc.xy(2, 2));
    JPanel black = new JPanel();
    black.setBackground(Color.BLACK);
    panel.add(black, cc.xyw(1, 4, 3));

    content.add(panel, cc.xyw(1, 1, 6));

    JLabel name = new JLabel(mLocalizer.msg("user", "Username") + ":");
    content.add(name, cc.xy(2, 3));

    mNameField = new JTextField();
    content.add(mNameField, cc.xy(4, 3));

    mNameField.setText(mUsername);

    JLabel password = new JLabel(mLocalizer.msg("password", "Password") + ":");
    content.add(password, cc.xy(2, 5));

    mPasswordField = new JPasswordField();
    content.add(mPasswordField, cc.xy(4, 5));

    mPasswordField.setText(mPassword);

    mStorePassword = new JCheckBox(mLocalizer.msg("storePassword", "Store Password"));
    content.add(mStorePassword, cc.xy(4, 7));

    mStorePassword.setSelected(mStore);

    ButtonBarBuilder2 builder = new ButtonBarBuilder2();
    builder.addGlue();

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));

    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            mReturnValue = JOptionPane.OK_OPTION;
            setVisible(false);
        }
    });

    getRootPane().setDefaultButton(ok);

    JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));

    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            close();
        }
    });

    builder.addButton(new JButton[] { ok, cancel });

    content.add(builder.getPanel(), cc.xyw(1, 9, 5));

    setSize(Sizes.dialogUnitXAsPixel(200, this), Sizes.dialogUnitYAsPixel(140, this));
}