Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

In this page you can find the example usage for java.awt GridBagConstraints HORIZONTAL.

Prototype

int HORIZONTAL

To view the source code for java.awt GridBagConstraints HORIZONTAL.

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

From source file:io.github.tavernaextras.biocatalogue.ui.search_results.ServiceListCellRenderer.java

/**
 * @return Final state of the {@link GridBagConstraints} instance
 *         that was used to lay out components in the panel.
 *///from   w w  w.j a  v  a2 s.c  o m
private GridBagConstraints arrangeLayout(boolean showActionButtons) {
    // POPULATE PANEL WITH PREPARED COMPONENTS
    this.setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.HORIZONTAL;

    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.insets = new Insets(10, 6, 6, 3);
    this.add(jlTypeIcon, c);

    c.gridx++;
    c.insets = new Insets(10, 3, 6, 3);
    this.add(jlItemStatus, c);

    c.gridx++;
    c.weightx = 1.0;
    c.insets = new Insets(10, 3, 6, 3);
    this.add(jlItemTitle, c);

    if (showActionButtons) {
        c.gridx++;
        c.gridheight = 3;
        c.weightx = 0;
        c.weighty = 1.0;
        jlExpand = new JLabel(ResourceManager.getImageIcon(ResourceManager.FOLD_ICON));
        this.add(jlExpand, c);
    }

    c.gridx = 2;
    c.gridy++;
    c.gridheight = 1;
    c.weightx = 1.0;
    c.weighty = 0;
    c.insets = new Insets(3, 3, 3, 3);
    this.add(jlDescription, c);

    return (c);
}

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

/** Builds and lays out the UI. */
private void buildGUI() {
    removeAll();//from  w  ww. j  a v  a 2  s  .co  m

    bgColor = UIUtilities.BACKGROUND_COLOUR_ODD;

    constraints = new GridBagConstraints();
    constraints.insets = new Insets(2, 0, 2, 0);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 1;
    constraints.weighty = 1;
    add(pane, constraints);
    constraints.gridy++;

    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.WEST;
    add(addButton, constraints);
    constraints.gridy++;

    constraints.weightx = 1;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.NORTHWEST;
}

From source file:com.smart.aqimonitor.client.AqiSettingDialog.java

/**
 * Create the dialog.//from  ww w .  ja  v  a  2 s  .c  om
 */
public AqiSettingDialog(Frame owner, final AbstractAqiParser aqiParser) {
    super(owner);
    this.aqiParser = aqiParser;
    setTitle("\u8BBE\u7F6E");
    setResizable(false);
    setBounds(100, 100, 450, 135);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    GridBagLayout gbl_contentPanel = new GridBagLayout();
    gbl_contentPanel.columnWidths = new int[] { 33, 48, 66, 41, 48, 66, 0, 0 };
    gbl_contentPanel.rowHeights = new int[] { 21, 0, 0 };
    gbl_contentPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    contentPanel.setLayout(gbl_contentPanel);
    {
        JLabel lblRetryTimes = new JLabel("\u91CD\u8BD5\u6B21\u6570\uFF1A");
        GridBagConstraints gbc_lblRetryTimes = new GridBagConstraints();
        gbc_lblRetryTimes.anchor = GridBagConstraints.WEST;
        gbc_lblRetryTimes.insets = new Insets(0, 0, 5, 5);
        gbc_lblRetryTimes.gridx = 1;
        gbc_lblRetryTimes.gridy = 0;
        contentPanel.add(lblRetryTimes, gbc_lblRetryTimes);
    }
    {
        tfRetryTimes = new JTextField();
        tfRetryTimes.setPreferredSize(new Dimension(6, 29));
        tfRetryTimes.setMinimumSize(new Dimension(60, 29));
        GridBagConstraints gbc_tfRetryTimes = new GridBagConstraints();
        gbc_tfRetryTimes.anchor = GridBagConstraints.NORTHWEST;
        gbc_tfRetryTimes.insets = new Insets(0, 0, 5, 5);
        gbc_tfRetryTimes.gridx = 2;
        gbc_tfRetryTimes.gridy = 0;
        contentPanel.add(tfRetryTimes, gbc_tfRetryTimes);
        tfRetryTimes.setColumns(10);
    }
    {
        JLabel lblRetryGap = new JLabel("\u91CD\u8BD5\u95F4\u9694\uFF1A");
        GridBagConstraints gbc_lblRetryGap = new GridBagConstraints();
        gbc_lblRetryGap.anchor = GridBagConstraints.WEST;
        gbc_lblRetryGap.insets = new Insets(0, 0, 5, 5);
        gbc_lblRetryGap.gridx = 4;
        gbc_lblRetryGap.gridy = 0;
        contentPanel.add(lblRetryGap, gbc_lblRetryGap);
    }
    {
        tfRetryGap = new JTextField();
        tfRetryGap.setMinimumSize(new Dimension(60, 29));
        tfRetryGap.setPreferredSize(new Dimension(60, 29));
        GridBagConstraints gbc_tfRetryGap = new GridBagConstraints();
        gbc_tfRetryGap.insets = new Insets(0, 0, 5, 5);
        gbc_tfRetryGap.anchor = GridBagConstraints.NORTHWEST;
        gbc_tfRetryGap.gridx = 5;
        gbc_tfRetryGap.gridy = 0;
        contentPanel.add(tfRetryGap, gbc_tfRetryGap);
        tfRetryGap.setColumns(10);
    }
    {
        JLabel label = new JLabel("\u5206\u949F");
        GridBagConstraints gbc_label = new GridBagConstraints();
        gbc_label.insets = new Insets(0, 0, 5, 0);
        gbc_label.gridx = 6;
        gbc_label.gridy = 0;
        contentPanel.add(label, gbc_label);
    }
    {
        JLabel lblExportPath = new JLabel("\u8F93\u51FA\u8DEF\u5F84\uFF1A");
        GridBagConstraints gbc_lblExportPath = new GridBagConstraints();
        gbc_lblExportPath.anchor = GridBagConstraints.EAST;
        gbc_lblExportPath.insets = new Insets(0, 0, 0, 5);
        gbc_lblExportPath.gridx = 1;
        gbc_lblExportPath.gridy = 1;
        contentPanel.add(lblExportPath, gbc_lblExportPath);
    }
    {
        tfExportPath = new JTextField();
        tfExportPath.setEditable(false);
        tfExportPath.setPreferredSize(new Dimension(180, 29));
        tfExportPath.setMinimumSize(new Dimension(180, 29));
        GridBagConstraints gbc_tfExportPath = new GridBagConstraints();
        gbc_tfExportPath.gridwidth = 4;
        gbc_tfExportPath.insets = new Insets(0, 0, 0, 5);
        gbc_tfExportPath.fill = GridBagConstraints.HORIZONTAL;
        gbc_tfExportPath.gridx = 2;
        gbc_tfExportPath.gridy = 1;
        contentPanel.add(tfExportPath, gbc_tfExportPath);
        tfExportPath.setColumns(10);
    }
    {
        JButton button = new JButton("...");
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                fDialog = new JFileChooser(); // 
                fDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                int result = fDialog.showOpenDialog(contentPanel);
                if (result == JFileChooser.APPROVE_OPTION) {
                    tfExportPath.setText(fDialog.getSelectedFile().getAbsolutePath());
                }
            }
        });
        GridBagConstraints gbc_button = new GridBagConstraints();
        gbc_button.gridx = 6;
        gbc_button.gridy = 1;
        contentPanel.add(button, gbc_button);
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton okButton = new JButton("\u786E\u5B9A");
            okButton.setName("settingOk");
            okButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {

                    String retryTimes = tfRetryTimes.getText();
                    if (StringUtils.isEmpty(retryTimes) || !isNumeric(retryTimes)) {
                        JOptionPane.showMessageDialog(contentPanel, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                    String retryGap = tfRetryGap.getText();
                    if (StringUtils.isEmpty(retryGap) || !isNumeric(retryGap)) {
                        JOptionPane.showMessageDialog(contentPanel, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                    String exportPath = tfExportPath.getText();
                    if (StringUtils.isEmpty(exportPath)) {
                        JOptionPane.showMessageDialog(contentPanel, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    File testFile = new File(exportPath);
                    if (!testFile.exists()) {
                        JOptionPane.showMessageDialog(contentPanel, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                    props.put("query.retryTimes", retryTimes);
                    props.put("query.retryGap", retryGap);
                    props.put("result.path", exportPath);

                    try {
                        props.store(new FileOutputStream(propertiesResource.getFile()), "");
                        aqiParser.setRetryTimes(Integer.parseInt(retryTimes));
                        aqiParser.setRetryGap(Integer.parseInt(retryGap));
                        aqiParser.setFilePath(exportPath);
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    } finally {
                        dispose();
                    }
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("\u53D6\u6D88");
            cancelButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    dispose();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.StartupDialog.java

/**
 * Initialises all GUI elements.//  ww w . j  av a  2 s .c o m
 */
private void initGui() {
    this.setResizable(false);
    this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);

    cancelButton = new JButton("Don't log in");
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);
    storeCredentialsButton = new JButton("Store Credentials");
    storeCredentialsButton.setActionCommand("StoreCredentials");
    storeCredentialsButton.addActionListener(this);
    okButton = new JButton("Log in");
    okButton.setActionCommand("LogIn");
    okButton.addActionListener(this);

    // Set default ENTER and ESCAPE buttons.
    this.getRootPane().setDefaultButton(okButton);
    this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),
            "ESCAPE");
    this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() {
        private static final long serialVersionUID = -1742280851624947873L;

        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    });

    JPanel buttonsPanel = new JPanel(new GridBagLayout());
    buttonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    buttonsPanel.add(storeCredentialsButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    buttonsPanel.add(okButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsZero, 0, 0));

    loginPassphrasePanel = new LoginPassphrasePanel(hyperlinkListener);
    loginLocalFolderPanel = new LoginLocalFolderPanel(ownerFrame, hyperlinkListener);
    loginCredentialsPanel = new LoginCredentialsPanel(false, hyperlinkListener);

    // Tabbed Pane.
    tabbedPane = new JTabbedPane();
    tabbedPane.addChangeListener(this);
    tabbedPane.add(loginPassphrasePanel, "S3 Online");
    tabbedPane.add(loginLocalFolderPanel, "Local Folder");
    tabbedPane.add(loginCredentialsPanel, "Direct Login");

    int row = 0;
    this.getContentPane().setLayout(new GridBagLayout());
    this.getContentPane().add(tabbedPane, new GridBagConstraints(0, row++, 2, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
    this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 2, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    this.pack();
    this.setSize(500, 400);
    this.setLocationRelativeTo(this.getOwner());
}

From source file:com.vgi.mafscaling.Rescale.java

private void createControlPanel(JPanel dataPanel) {
    JPanel cntlPanel = new JPanel();
    GridBagConstraints gbl_ctrlPanel = new GridBagConstraints();
    gbl_ctrlPanel.insets = insets3;//www.  ja  v a 2 s  .  c om
    gbl_ctrlPanel.anchor = GridBagConstraints.PAGE_START;
    gbl_ctrlPanel.fill = GridBagConstraints.HORIZONTAL;
    gbl_ctrlPanel.weightx = 1.0;
    gbl_ctrlPanel.gridx = 0;
    gbl_ctrlPanel.gridy = 0;
    dataPanel.add(cntlPanel, gbl_ctrlPanel);

    GridBagLayout gbl_cntlPanel = new GridBagLayout();
    gbl_cntlPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_cntlPanel.rowHeights = new int[] { 0, 0 };
    gbl_cntlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
    gbl_cntlPanel.rowWeights = new double[] { 0 };
    cntlPanel.setLayout(gbl_cntlPanel);

    NumberFormat doubleFmt = NumberFormat.getNumberInstance();
    doubleFmt.setGroupingUsed(false);
    doubleFmt.setMaximumIntegerDigits(1);
    doubleFmt.setMinimumIntegerDigits(1);
    doubleFmt.setMaximumFractionDigits(3);
    doubleFmt.setMinimumFractionDigits(1);
    doubleFmt.setRoundingMode(RoundingMode.HALF_UP);

    NumberFormat scaleDoubleFmt = NumberFormat.getNumberInstance();
    scaleDoubleFmt.setGroupingUsed(false);
    scaleDoubleFmt.setMaximumIntegerDigits(1);
    scaleDoubleFmt.setMinimumIntegerDigits(1);
    scaleDoubleFmt.setMaximumFractionDigits(8);
    scaleDoubleFmt.setMinimumFractionDigits(1);
    scaleDoubleFmt.setRoundingMode(RoundingMode.HALF_UP);

    GridBagConstraints gbc_cntlPanelLabel = new GridBagConstraints();
    gbc_cntlPanelLabel.anchor = GridBagConstraints.EAST;
    gbc_cntlPanelLabel.insets = new Insets(2, 3, 2, 1);
    gbc_cntlPanelLabel.gridx = 0;
    gbc_cntlPanelLabel.gridy = 0;

    GridBagConstraints gbc_cntlPanelInput = new GridBagConstraints();
    gbc_cntlPanelInput.anchor = GridBagConstraints.WEST;
    gbc_cntlPanelInput.insets = new Insets(2, 1, 2, 3);
    gbc_cntlPanelInput.gridx = 1;
    gbc_cntlPanelInput.gridy = 0;

    cntlPanel.add(new JLabel("New Max V"), gbc_cntlPanelLabel);

    newMaxVFmtTextBox = new JFormattedTextField(doubleFmt);
    newMaxVFmtTextBox.setColumns(7);
    newMaxVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == newMaxVFmtTextBox)
                updateNewMafScale();
        }
    });
    cntlPanel.add(newMaxVFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Min V"), gbc_cntlPanelLabel);

    minVFmtTextBox = new JFormattedTextField(doubleFmt);
    minVFmtTextBox.setColumns(7);
    minVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == minVFmtTextBox)
                updateNewMafScale();
        }
    });
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(minVFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Max Unchanged"), gbc_cntlPanelLabel);

    maxVUnchangedFmtTextBox = new JFormattedTextField(doubleFmt);
    maxVUnchangedFmtTextBox.setColumns(7);
    maxVUnchangedFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == maxVUnchangedFmtTextBox)
                updateNewMafScale();
        }
    });
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(maxVUnchangedFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Mode deltaV"), gbc_cntlPanelLabel);

    modeDeltaVFmtTextBox = new JFormattedTextField(scaleDoubleFmt);
    modeDeltaVFmtTextBox.setColumns(7);
    modeDeltaVFmtTextBox.setEditable(false);
    modeDeltaVFmtTextBox.setBackground(new Color(210, 210, 210));
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(modeDeltaVFmtTextBox, gbc_cntlPanelInput);
}

From source file:com.intel.stl.ui.main.view.StaDetailsPanel.java

/**
 * Description://from  w  w w  .ja v  a2 s.  c  o m
 * 
 * @param sourceName
 */
protected void initComponent() {
    setLayout(new BorderLayout(0, 10));
    setOpaque(false);
    setBorder(BorderFactory.createTitledBorder((Border) null));

    JPanel titlePanel = new JPanel(new BorderLayout(5, 1));
    titlePanel.setOpaque(false);
    numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    numberLabel.setHorizontalAlignment(JLabel.RIGHT);
    titlePanel.add(numberLabel, BorderLayout.CENTER);
    nameLabel = ComponentFactory.getH3Label("", Font.PLAIN);
    nameLabel.setHorizontalAlignment(JLabel.LEFT);
    nameLabel.setVerticalAlignment(JLabel.BOTTOM);
    titlePanel.add(nameLabel, BorderLayout.EAST);
    add(titlePanel, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setOpaque(false);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    GridBagLayout gridBag = new GridBagLayout();
    mainPanel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.insets = new Insets(2, 2, 2, 2);
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.weighty = 0;
    failedChartPanel = new ChartPanel(null);
    failedChartPanel.setPreferredSize(new Dimension(60, 20));
    mainPanel.add(failedChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 0;
    failedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD);
    failedNumberLabel.setForeground(UIConstants.INTEL_DARK_RED);
    failedNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    mainPanel.add(failedNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    failedNameLabel = ComponentFactory.getH5Label(STLConstants.K0020_FAILED.getValue(), Font.PLAIN);
    failedNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    mainPanel.add(failedNameLabel, gc);

    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    gc.gridwidth = 1;
    skippedChartPanel = new ChartPanel(null);
    skippedChartPanel.setPreferredSize(new Dimension(60, 20));
    mainPanel.add(skippedChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 0;
    skippedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD);
    skippedNumberLabel.setForeground(UIConstants.INTEL_DARK_ORANGE);
    skippedNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    mainPanel.add(skippedNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    skippedNameLabel = ComponentFactory.getH5Label(STLConstants.K0021_SKIPPED.getValue(), Font.PLAIN);
    skippedNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    mainPanel.add(skippedNameLabel, gc);

    gc.weighty = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.insets = new Insets(8, 2, 2, 2);
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.gridheight = types.length;
    typeChartPanel = new ChartPanel(null);
    typeChartPanel.setPreferredSize(new Dimension(80, 60));
    mainPanel.add(typeChartPanel, gc);

    typeNumberLabels = new JLabel[types.length];
    typeNameLabels = new JLabel[types.length];
    gc.fill = GridBagConstraints.BOTH;
    gc.gridheight = 1;
    gc.insets = new Insets(12, 2, 2, 2);
    for (int i = 0; i < types.length; i++) {
        if (i == 1) {
            gc.insets = new Insets(2, 2, 2, 2);
        }

        gc.weightx = 0;
        gc.gridwidth = 1;
        typeNumberLabels[i] = createNumberLabel();
        mainPanel.add(typeNumberLabels[i], gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        typeNameLabels[i] = createNameLabel(types[i].getName());
        mainPanel.add(typeNameLabels[i], gc);
    }

    gc.fill = GridBagConstraints.BOTH;
    mainPanel.add(Box.createGlue(), gc);

    add(mainPanel, BorderLayout.CENTER);
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.ADAP3DecompositionV1_5SetupDialog.java

@Override
protected void addDialogComponents() {
    super.addDialogComponents();

    comboPeakList = new JComboBox<>();
    comboClustersModel = new DefaultComboBoxModel<>();
    comboClusters = new JComboBox<>(comboClustersModel);
    retTimeMZPlot = new SimpleScatterPlot("Retention time", "m/z");
    retTimeIntensityPlot = new EICPlot();

    PeakList[] peakLists = MZmineCore.getDesktop().getSelectedPeakLists();

    // -----------------------------
    // Panel with preview parameters
    // -----------------------------

    preview = new JCheckBox("Show preview");
    preview.addActionListener(this);
    preview.setHorizontalAlignment(SwingConstants.CENTER);

    if (peakLists == null || peakLists.length == 0)
        preview.setEnabled(false);/* ww w  .ja va  2s.  com*/
    else
        preview.setEnabled(true);

    final JPanel previewPanel = new JPanel(new BorderLayout());
    previewPanel.add(new JSeparator(), BorderLayout.NORTH);
    previewPanel.add(preview, BorderLayout.CENTER);
    previewPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);

    comboPeakList.setFont(COMBO_FONT);
    for (final PeakList peakList : peakLists)
        if (peakList.getNumberOfRawDataFiles() == 1)
            comboPeakList.addItem(peakList);
    comboPeakList.addActionListener(this);

    comboClusters.setFont(COMBO_FONT);
    comboClusters.addActionListener(this);

    pnlLabelsFields = GUIUtils.makeTablePanel(2, 2, new JComponent[] { new JLabel("Peak list"), comboPeakList,
            new JLabel("Cluster list"), comboClusters });

    pnlVisible = new JPanel(new BorderLayout());
    pnlVisible.add(previewPanel, BorderLayout.NORTH);

    // --------------------------------------------------------------------
    // ----- Tabbed panel with plots --------------------------------------
    // --------------------------------------------------------------------

    //        pnlTabs = new JTabbedPane();
    pnlTabs = new JPanel();
    pnlTabs.setLayout(new BoxLayout(pnlTabs, BoxLayout.Y_AXIS));

    retTimeMZPlot.setMinimumSize(MIN_DIMENSIONS);

    JPanel pnlPlotRetTimeClusters = new JPanel(new BorderLayout());
    pnlPlotRetTimeClusters.setBackground(Color.white);
    pnlPlotRetTimeClusters.add(retTimeMZPlot, BorderLayout.CENTER);
    GUIUtils.addMarginAndBorder(pnlPlotRetTimeClusters, 10);

    pnlTabs.add(pnlPlotRetTimeClusters);

    retTimeIntensityPlot.setMinimumSize(MIN_DIMENSIONS);

    JPanel pnlPlotShapeClusters = new JPanel(new BorderLayout());
    pnlPlotShapeClusters.setBackground(Color.white);
    pnlPlotShapeClusters.add(retTimeIntensityPlot, BorderLayout.CENTER);
    GUIUtils.addMarginAndBorder(pnlPlotShapeClusters, 10);

    pnlTabs.add(pnlPlotShapeClusters);

    super.mainPanel.add(pnlVisible, 0, super.getNumberOfParameters() + 3, 2, 1, 0, 0,
            GridBagConstraints.HORIZONTAL);
}

From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java

public static JFrame createMessageFrame(String title, String msg) {

    final JFrame frame = new JFrame(title);

    final JTextArea message = createMultiLineLabel(msg);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());

    final JPanel messagePanel = new JPanel();
    messagePanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;//from w  w  w .j a v  a  2s . co  m
    cnstrs.gridheight = 1;
    messagePanel.add(message, cnstrs);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right           
    panel.add(messagePanel, cnstrs);

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right      
    panel.add(buttonPanel, cnstrs);

    frame.getContentPane().add(panel);
    frame.pack();
    return frame;
}

From source file:endrov.frameTime.FrameTimeWindow.java

/**
 * Regenerate UI/*w  w  w . j  a  v  a2 s .  com*/
 */
public void fillDatapart() {
    datapart.removeAll();
    datapart.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 0;
    datapart.add(new JLabel("Frame"), c);
    c.gridx = 1;
    datapart.add(new JLabel("Time"), c);
    for (int i = 0; i < inputVector.size(); i++) {
        c.gridy++;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1;
        c.gridx = 0;
        datapart.add(inputVector.get(i).frame, c);
        c.gridx = 1;
        datapart.add(inputVector.get(i).time, c);
        c.gridx = 2;
        c.fill = 0;
        c.weightx = 0;
        datapart.add(inputVector.get(i).bDelete, c);
    }
    setVisibleEvWindow(true);
}

From source file:EditorPaneExample20.java

public EditorPaneExample20() {
    super("JEditorPane Example 20");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);// w  w w  .  j  a v a2s . c om

    // Populate it
    createMenuBar();

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridy = 6;
    c.weightx = 0.0;
    JButton saveButton = new JButton("Save");
    panel.add(saveButton, c);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            try {
                if (kit instanceof RTFEditorKit) {
                    kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength());
                    System.out.flush();
                } else {
                    if (writer == null) {
                        writer = new OutputStreamWriter(System.out);
                        pane.write(writer);
                        writer.flush();
                    }
                    kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength());
                    writer.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });

    c.gridx = 1;
    insertButton = new JButton("Insert HTML");
    panel.add(insertButton, c);
    insertButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (insertFrame == null) {
                insertFrame = new HTMLInsertFrame("HTML Insertion", pane);
                Point pt = EditorPaneExample20.this.getLocationOnScreen();
                Dimension d = EditorPaneExample20.this.getSize();
                insertFrame.setLocation(pt.x + d.width, pt.y);
                insertFrame.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent evt) {
                        insertFrame.dispose();
                        insertFrame = null;
                        setInsertButtonState();
                    }
                });
                insertButton.setEnabled(false);
                insertFrame.setVisible(true);
            }
        }
    });
    insertButton.setEnabled(false);

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Register a custom EditorKit for HTML
    ClassLoader loader = getClass().getClassLoader();
    if (loader != null) {
        // Java 2
        JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.EnhancedHTMLEditorKit",
                loader);
    } else {
        // JDK 1.1
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.EnhancedHTMLEditorKit");
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));

                createMenuBar();
                enableMenuBar(true);
                getRootPane().revalidate();

                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}