Example usage for com.jgoodies.forms.builder PanelBuilder add

List of usage examples for com.jgoodies.forms.builder PanelBuilder add

Introduction

In this page you can find the example usage for com.jgoodies.forms.builder PanelBuilder add.

Prototype

public final Component add(Component component) 

Source Link

Document

Adds a component to the container using the default cell constraints.

Usage

From source file:cz.cuni.mff.peckam.java.origamist.gui.editor.OrigamiPropertiesFrame.java

License:Open Source License

/**
 * Add all components to a layout.//from   w  w w  .  j a  va 2  s  .c  o  m
 */
protected void buildLayout() {
    Configuration conf = ServiceLocator.get(ConfigurationManager.class).get();

    CellConstraints cc = new CellConstraints();

    final JTabbedPane tabPane = new JTabbedPane();
    int tabIndex = 0;

    JPanel basicPanel = new JPanel(new FormLayout("$dmargin,right:pref,$lcgap,pref:grow,$dmargin",
            "$dmargin,pref,$lgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$dmargin"));
    final int basicPanelTabIndex = tabIndex++;
    tabPane.addTab("", basicPanel);
    conf.addAndRunResourceBundleListener(
            new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.basicPanelTitle") {
                @Override
                protected void updateText(String text) {
                    tabPane.setTitleAt(basicPanelTabIndex, text);
                }
            });

    basicPanel.add(nameLabel, cc.xy(2, 2));
    basicPanel.add(name, cc.xy(4, 2));
    basicPanel.add(creationDateLabel, cc.xy(2, 4));
    basicPanel.add(creationDate, cc.xy(4, 4));
    basicPanel.add(authorNameLabel, cc.xy(2, 6));
    basicPanel.add(authorName, cc.xy(4, 6));
    basicPanel.add(authorHomepageLabel, cc.xy(2, 8));
    basicPanel.add(authorHomepage, cc.xy(4, 8));
    basicPanel.add(shortDescLabel, cc.xy(2, 10));
    basicPanel.add(shortDesc, cc.xy(4, 10));
    basicPanel.add(originalLabel, cc.xy(2, 12));
    basicPanel.add(original, cc.xy(4, 12));
    basicPanel.add(description, cc.xywh(2, 14, 3, 1));

    JPanel thumbnailPanel = new JPanel(
            new FormLayout("$dmargin,center:min(pref;50dlu),$ugap,pref,$ugap,pref,$dmargin",
                    "$dmargin,pref,$lgap,pref,$dmargin"));
    final int thumbnailPanelTabIndex = tabIndex++;
    tabPane.addTab("", thumbnailPanel);
    conf.addAndRunResourceBundleListener(
            new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.thumbnailPanelTitle") {
                @Override
                protected void updateText(String text) {
                    tabPane.setTitleAt(thumbnailPanelTabIndex, text);
                }
            });

    thumbnailPanel.add(thumbnailPreviewLabel, cc.xy(2, 2));
    thumbnailPanel.add(thumbnailPreview, cc.xy(2, 4));
    thumbnailPanel.add(thumbnailLoadFromModel, cc.xy(4, 2));
    thumbnailPanel.add(thumbnailLoadFromFile, cc.xy(6, 2));
    thumbnailPanel.add(thumbnailFileInputLabel, cc.xy(4, 4));
    thumbnailPanel.add(thumbnailFileInput, cc.xy(6, 4));

    final JScrollPane licenseContentScrollPane = new JScrollPane(licenseContent,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    JPanel licenseNamePanel = new JPanel(new FormLayout("pref,$lcgap,pref:grow", "pref"));
    licenseNamePanel.add(licenseNameLabel, cc.xy(1, 1));
    licenseNamePanel.add(licenseName, cc.xy(3, 1));

    licenseChooseContent.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                licenseHomepageLabel.setVisible(false);
                licenseContentLabel.setVisible(true);
                licenseContentScrollPane.setVisible(true);
            }
        }
    });
    licenseChooseHomepage.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                licenseContentLabel.setVisible(false);
                licenseHomepageLabel.setVisible(true);
                licenseContentScrollPane.setVisible(false);
            }
        }
    });
    licenseHomepageLabel.setVisible(licenseHomepage.isVisible());
    licenseContentLabel.setVisible(licenseContent.isVisible());
    licenseContentScrollPane.setVisible(licenseContent.isVisible());

    JPanel licenseContentPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    licenseContentPanel.add(licenseChooseContent);
    licenseContentPanel.add(licenseChooseHomepage);

    JPanel licenseHomepagePanel = new JPanel(new FormLayout("pref,$lcgap,pref:grow", "pref"));
    licenseHomepagePanel.add(licenseHomepageLabel, cc.xy(1, 1));
    licenseHomepagePanel.add(licenseHomepage, cc.xy(3, 1));

    JPanel licensePermissionPanel = new JPanel(new GridLayout(0, 1));
    licensePermissionPanel.add(licensePermissionDoNothing);
    licensePermissionPanel.add(licensePermissionEdit);
    licensePermissionPanel.add(licensePermissionExport);
    licensePermissionPanel.add(licensePermissionDistribute);

    JPanel licensePanel = new JPanel(new FormLayout("$dmargin,min(pref;500px):grow,$dmargin",
            "$dmargin,pref,$lgap,pref,$lgap,pref,$rgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$dmargin"));
    final int licensePanelTabIndex = tabIndex++;
    tabPane.addTab("", licensePanel);
    conf.addAndRunResourceBundleListener(
            new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.licensePanelTitle") {
                @Override
                protected void updateText(String text) {
                    tabPane.setTitleAt(licensePanelTabIndex, text);
                }
            });

    JPanel predefinedLicensesPanel = new JPanel(new FormLayout("pref"));
    PanelBuilder builder = new PanelBuilder((FormLayout) predefinedLicensesPanel.getLayout(),
            predefinedLicensesPanel);
    for (JRadioButton b : predefinedLicenses) {
        builder.appendRow("$lgap");
        builder.appendRow("pref");
        builder.nextLine();
        builder.add(b);
        builder.nextLine();
    }

    JLabel licenseChooseLabel = new JLocalizedLabel("application", "OrigamiPropertiesFrame.licenseChooseLabel");

    licensePanel.add(licenseNamePanel, cc.xy(2, 2));
    licensePanel.add(predefinedLicensesPanel, cc.xy(2, 4));
    licensePanel.add(licenseChooseLabel, cc.xy(2, 6));
    licensePanel.add(licenseContentPanel, cc.xy(2, 8));
    licensePanel.add(licenseContentLabel, cc.xy(2, 10));
    licensePanel.add(licenseContentScrollPane, cc.xy(2, 12));
    licensePanel.add(licenseHomepagePanel, cc.xy(2, 14));
    licensePanel.add(licensePermissionPanel, cc.xy(2, 16));

    final int diagramPaperTabIndex = tabIndex++;
    JPanel diagramPaperPanel = new JPanel(
            new FormLayout("$dmargin,default,$dmargin", "$dmargin,default,$dmargin"));
    diagramPaperPanel.add(diagramPaper, cc.xy(2, 2));
    tabPane.addTab("", diagramPaperPanel);
    conf.addAndRunResourceBundleListener(
            new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.diagramPaperLabel") {
                @Override
                protected void updateText(String text) {
                    tabPane.setTitleAt(diagramPaperTabIndex, text);
                }
            });

    final int modelPaperTabIndex = tabIndex++;
    JPanel modelPaperPanel = new JPanel(
            new FormLayout("$dmargin,default,$dmargin", "$dmargin,default,$dmargin"));
    modelPaperPanel.add(modelPaper, cc.xy(2, 2));
    tabPane.addTab("", modelPaperPanel);
    conf.addAndRunResourceBundleListener(
            new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.modelPaperLabel") {
                @Override
                protected void updateText(String text) {
                    tabPane.setTitleAt(modelPaperTabIndex, text);
                }
            });

    JPanel dialogButtonsPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    dialogButtonsPanel.add(cancelButton);
    dialogButtonsPanel.add(okButton);

    setLayout(new FormLayout("default", "default,$lgap,default"));
    add(tabPane, cc.xy(1, 1));
    add(dialogButtonsPanel, cc.xy(1, 3));

    pack();
}

From source file:de.htwk_leipzig.naoteam.motion.editor.gui.action.ActionCreateCalcKeyFrame.java

License:Open Source License

private void createUI(final NaoFrame[] frames, final int srcPos, final int toPos) {
    final JDialog dialog = new JDialog(app.getMainWindow(), "Select Frame", true);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    final JSlider slider = new JSlider(0, frames.length - 1);
    slider.setValue(0);/*from   w  w  w .j av  a 2 s. c  om*/
    slider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            try {
                comm.playFrame(frames[slider.getValue()]);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    final JButton btnOk = new JButton("Ok");
    btnOk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            app.getFrameList().add(toPos, frames[slider.getValue()]);
            dialog.setVisible(false);
            dialog.dispose();
        }
    });

    final JButton btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            dialog.dispose();
        }
    });

    FormLayout layout = new FormLayout("left:pref, $lcgap, fill:640px:grow", "pref, $lgap, pref");
    PanelBuilder builder = new PanelBuilder(layout /*, new FormDebugPanel() */);
    builder.addLabel("Frame:");
    builder.nextColumn(2);
    builder.add(slider);
    builder.nextRow(2);
    builder.add(ButtonBarFactory.buildOKCancelBar(btnOk, btnCancel));
    builder.setDefaultDialogBorder();

    dialog.add(builder.getPanel());
    dialog.pack();

    final Dimension paneSize = dialog.getSize();
    final Dimension screenSize = dialog.getToolkit().getScreenSize();
    dialog.setLocation((screenSize.width - paneSize.width) / 2,
            (int) ((screenSize.height - paneSize.height) * 0.45));

    dialog.setVisible(true);
}

From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatSingleDlg.java

License:Open Source License

@Override
public void createUI() {
    super.createUI();

    //CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("p", "p")/*, new FormDebugPanel()*/);

    // format editing panel (single format only)
    DataObjSwitchFormatterContainerIface fmtContainer = new DataObjSwitchFormatterSingleContainer(formatter);
    fmtSingleEditingPanel = new DataObjFieldFormatSinglePanel(tableInfo, fmtContainer,
            dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, this, getOkBtn());
    pb.add(fmtSingleEditingPanel);
    pb.setDefaultDialogBorder();/*w ww . j a v  a 2  s  .co m*/

    contentPanel = pb.getPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);

    okBtn.setEnabled(false);

    pack();
}