Example usage for java.awt GridBagConstraints NONE

List of usage examples for java.awt GridBagConstraints NONE

Introduction

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

Prototype

int NONE

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

Click Source Link

Document

Do not resize the component.

Usage

From source file:org.dwfa.ace.classifier.CNFormsLabelPanel.java

public CNFormsLabelPanel(I_GetConceptData conceptIn, List<I_Position> cEditPathPos,
        List<I_Position> cClassPathPos, SnoTable cSnoTable) {
    super();//from w  w  w. j  a  v  a 2s  .  co m
    this.theCBean = conceptIn;
    this.cEditPathPos = cEditPathPos;
    this.cClassPathPos = cClassPathPos;
    this.cSnoTable = cSnoTable;

    setLayout(new GridBagLayout()); // CNFormsLabelPanel LayoutManager
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST; // Place
    // CNFormsLabelPanel

    // TOP ROW
    c.gridy = 0; // first row
    c.gridx = 0; // reset at west side of row
    c.weightx = 0.0; // no extra space
    c.weighty = 0.0; // no extra space
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;

    // ADD CHECK BOXES
    c.gridy++;// next row
    c.gridx = 0;
    c.gridwidth = 5;
    JLabel label = new JLabel("Normal Forms Expanded View:");
    label.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 0));
    add(label, c);
    c.gridx++;
    add(showDistFormCB, c);
    c.gridx++;
    add(showAuthFormCB, c);
    c.gridx++;
    add(showLongFormCB, c);
    c.gridx++;
    add(showShortFormCB, c);

    // FORM SELECTION CHECKBOX ROW
    c.gridy++; // next row
    c.gridx = 0; // first cell in row
    c.gridwidth = 1;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;

    label = new JLabel("Information:");
    label.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 0));
    add(label, c);

    c.gridx++;
    add(showDetailCB, c);
    c.gridx++;
    add(showStatusCB, c);

    // SETUP CHECKBOX VALUES & LISTENER
    showStatusCB.setSelected(false);
    showStatusCB.addActionListener(this);
    showDetailCB.setSelected(false);
    showDetailCB.addActionListener(this);
    showDistFormCB.setSelected(false);
    showDistFormCB.addActionListener(this);
    showAuthFormCB.setSelected(false);
    showAuthFormCB.addActionListener(this);
    showLongFormCB.setSelected(false);
    showLongFormCB.addActionListener(this);
    showShortFormCB.setSelected(false);
    showShortFormCB.addActionListener(this);

    // COMMON & DIFFERENT PANELS ROW
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    commonJPanel = newMinMaxJPanel();
    commonJPanel.setLayout(new GridLayout(0, 1));
    commonJPanel.setName("Common Panel");
    commonJPanel.setBorder(BorderFactory.createTitledBorder("Common: "));
    add(commonJPanel, c);

    c.gridx = c.gridx + 1;
    deltaJPanel = newMinMaxJPanel();
    deltaJPanel.setLayout(new GridLayout(0, 1));
    deltaJPanel.setName("Differences Panel");
    deltaJPanel.setBorder(BorderFactory.createTitledBorder("Different: "));
    add(deltaJPanel, c);

    // FORMS PANEL ROW
    c.gridy++;// next row
    c.gridx = 0; // reset at west side of row
    c.gridwidth = 2; // number of cells in row
    c.fill = GridBagConstraints.BOTH;
    formsJPanel = new JPanel(new GridBagLayout());
    formsJPanel.setName("Forms Panel");
    formsJPanel.setBorder(BorderFactory.createTitledBorder("Forms: "));
    JScrollPane formJScrollPane = new JScrollPane(formsJPanel);
    formJScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    add(formJScrollPane, c);

}

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

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

    JLabel l = new JLabel();
    Font f = l.getFont();
    int size = f.getSize() - 1;
    content.removeAll();
    content.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 1, 2, 1);
    c.anchor = GridBagConstraints.WEST;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;

    if (!model.isAnnotationLoaded()) {
        l.setText("Annotation could not be loaded");
        content.add(l, c);
        return;
    }

    if (model.isMultiSelection()) {
        Object refObject = model.getRefObject();
        StringBuffer buffer = new StringBuffer();
        buffer.append("Annotate the selected ");
        buffer.append(model.getObjectTypeAsString(refObject));
        buffer.append("s");
        l.setText(buffer.toString());
        content.add(l, c);
        c.gridy++;
    }

    // filters
    content.add(createBar(filterButton, null), c);
    c.gridy++;

    // rating
    c.gridwidth = 1;
    c.gridx = 0;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("Rating:", Font.BOLD, size));
    p.add(createBar(unrateButton, null));
    content.add(p, c);
    c.gridx = 1;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(rating);
    p.add(Box.createHorizontalStrut(2));
    p.add(otherRating);
    content.add(p, c);
    c.gridy++;

    // tags
    c.gridx = 0;
    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("Tags:", Font.BOLD, size));
    p.add(createBar(addTagsButton, removeTagsButton));
    content.add(p, c);
    c.gridy++;
    content.add(tagsPane, c);
    c.gridy++;

    // attachment
    c.gridx = 0;
    c.gridwidth = 2;
    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("Attachments:", Font.BOLD, size));
    p.add(createBar(addDocsButton, removeDocsButton));
    content.add(p, c);
    c.gridy++;
    content.add(docRef, c);
    c.gridy++;

    if (!model.isMultiSelection()) {
        mapsPane.reload(filter);
        content.add(mapsPane, c);
        c.gridy++;
    }

    // other
    if (!CollectionUtils.isEmpty(model.getAllOtherAnnotations())) {
        p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
        p.setBackground(UIUtilities.BACKGROUND_COLOR);
        p.add(UIUtilities.setTextFont("Others:", Font.BOLD, size));
        p.add(createBar(null, removeOtherAnnotationsButton));
        content.add(p, c);
        c.gridy++;
        content.add(otherPane, c);
    }

    add(content, BorderLayout.CENTER);
}

From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java

private void addSelectedArtifactLineItem() {
    final String tipInfo = "The Artifact you want to use.";
    JLabel artifactSelectLabel = new JLabel("Select an Artifact to submit");
    artifactSelectLabel.setToolTipText(tipInfo);

    selectedArtifactComboBox = new ComboBox();
    selectedArtifactComboBox.setToolTipText(tipInfo);

    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()] = new JLabel(
            "Artifact should not be null!");
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()]
            .setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()].setVisible(false);

    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()] = new JLabel(
            "Could not find the local jar package for Artifact");
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()]
            .setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()].setVisible(false);

    selectedArtifactTextField = new TextFieldWithBrowseButton();
    selectedArtifactTextField.setToolTipText("Artifact from local jar package.");
    selectedArtifactTextField.setEditable(true);
    selectedArtifactTextField.setEnabled(false);
    selectedArtifactTextField.getTextField().getDocument().addDocumentListener(new DocumentListener() {
        @Override//from   www.ja  v  a2s .  co  m
        public void insertUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2,
                    !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2,
                    !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2,
                    !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }
    });

    selectedArtifactTextField.getButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true,
                    false);
            chooserDescriptor.setTitle("Select Local Artifact File");
            VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, null);
            if (chooseFile != null) {
                String path = chooseFile.getPath();
                if (path.endsWith("!/")) {
                    path = path.substring(0, path.length() - 2);
                }
                selectedArtifactTextField.setText(path);
            }
        }
    });

    intelliJArtifactRadioButton = new JRadioButton("Artifact from IntelliJ project:", true);
    localArtifactRadioButton = new JRadioButton("Artifact from local disk:", false);

    intelliJArtifactRadioButton.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectedArtifactComboBox.setEnabled(true);
                selectedArtifactTextField.setEnabled(false);
                mainClassTextField.setButtonEnabled(true);

                setVisibleForFixedErrorMessageLabel(2, false);

                if (selectedArtifactComboBox.getItemCount() == 0) {
                    setVisibleForFixedErrorMessageLabel(2, true);
                }
            }
        }
    });

    localArtifactRadioButton.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectedArtifactComboBox.setEnabled(false);
                selectedArtifactTextField.setEnabled(true);
                mainClassTextField.setButtonEnabled(false);

                setVisibleForFixedErrorMessageLabel(1, false);

                if (StringHelper.isNullOrWhiteSpace(selectedArtifactTextField.getText())) {
                    setVisibleForFixedErrorMessageLabel(2, true);
                }
            }
        }
    });

    ButtonGroup group = new ButtonGroup();
    group.add(intelliJArtifactRadioButton);
    group.add(localArtifactRadioButton);

    intelliJArtifactRadioButton.setSelected(true);

    add(artifactSelectLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 0, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));

    add(intelliJArtifactRadioButton,
            new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));

    add(selectedArtifactComboBox,
            new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));

    add(errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()],
            new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));

    add(localArtifactRadioButton,
            new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));

    add(selectedArtifactTextField,
            new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
    add(errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()],
            new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}

From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.JPanStringMatchMain.java

/**
 * This method initializes jPanel3   /*from w ww. j  av a2s  .  co m*/
 *    
 * @return javax.swing.JPanel   
 */
public JPanel getJPanelRepreLicenFolder() {
    if (jPanelRepreLicenFolder == null) {
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.anchor = GridBagConstraints.WEST;
        gridBagConstraints6.insets = new Insets(0, 0, 0, 0);
        gridBagConstraints6.gridx = -1;
        gridBagConstraints6.gridy = -1;
        gridBagConstraints6.weightx = 0.0;
        gridBagConstraints6.fill = GridBagConstraints.VERTICAL;
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.anchor = GridBagConstraints.EAST;
        gridBagConstraints3.insets = new Insets(0, 0, 0, 3);
        gridBagConstraints3.gridx = -1;
        gridBagConstraints3.gridy = -1;
        gridBagConstraints3.weightx = 0.0;
        gridBagConstraints3.fill = GridBagConstraints.NONE;
        jPanelRepreLicenFolder = new JPanel();
        jPanelRepreLicenFolder.setLayout(new GridBagLayout());
        jPanelRepreLicenFolder.setPreferredSize(new Dimension(489, 33));
        jPanelRepreLicenFolder.add(jLabelRepresentativeLicenseForOpt2, gridBagConstraints3);
        jPanelRepreLicenFolder.add(getJComboLicenseNameForOpt2(), gridBagConstraints6);
    }
    return jPanelRepreLicenFolder;
}

From source file:org.esa.beam.visat.toolviews.spectrum.SpectrumToolView.java

@Override
public JComponent createControl() {
    final JFreeChart chart = ChartFactory.createXYLineChart(CHART_TITLE, "Wavelength (nm)", "", null,
            PlotOrientation.VERTICAL, true, true, false);
    chart.getXYPlot().getRangeAxis().addChangeListener(new AxisChangeListener() {
        @Override//from w  ww  .  j  a  va2 s.  com
        public void axisChanged(AxisChangeEvent axisChangeEvent) {
            if (!isCodeInducedAxisChange) {
                rangeAxisAdjustmentIsFrozen = !((ValueAxis) axisChangeEvent.getAxis()).isAutoRange();
            }
        }
    });
    chart.getXYPlot().getDomainAxis().addChangeListener(new AxisChangeListener() {
        @Override
        public void axisChanged(AxisChangeEvent axisChangeEvent) {
            if (!isCodeInducedAxisChange) {
                domainAxisAdjustmentIsFrozen = !((ValueAxis) axisChangeEvent.getAxis()).isAutoRange();
            }
        }
    });
    chart.getXYPlot().getRangeAxis().setAutoRange(false);
    rangeAxisAdjustmentIsFrozen = false;
    chart.getXYPlot().getDomainAxis().setAutoRange(false);
    domainAxisAdjustmentIsFrozen = false;
    chartPanel = new ChartPanel(chart);
    chartHandler = new ChartHandler(chart);
    final XYPlotMarker plotMarker = new XYPlotMarker(chartPanel, new XYPlotMarker.Listener() {
        @Override
        public void pointSelected(XYDataset xyDataset, int seriesIndex, Point2D dataPoint) {
            if (hasDiagram()) {
                if (cursorSynchronizer == null) {
                    cursorSynchronizer = new CursorSynchronizer(VisatApp.getApp());
                }
                if (!cursorSynchronizer.isEnabled()) {
                    cursorSynchronizer.setEnabled(true);
                }
            }
        }

        @Override
        public void pointDeselected() {
            cursorSynchronizer.setEnabled(false);
        }
    });

    titleBase = getDescriptor().getTitle();
    filterButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Filter24.gif"), false);
    filterButton.setName("filterButton");
    filterButton.setEnabled(false);
    filterButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectSpectralBands();
            recreateChart();
        }
    });

    showSpectrumForCursorButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/CursorSpectrum24.gif"), true);
    showSpectrumForCursorButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            recreateChart();
        }
    });
    showSpectrumForCursorButton.setName("showSpectrumForCursorButton");
    showSpectrumForCursorButton.setSelected(true);
    showSpectrumForCursorButton.setToolTipText("Show spectrum at cursor position.");

    showSpectraForSelectedPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/SelectedPinSpectra24.gif"), true);
    showSpectraForSelectedPinsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isShowingSpectraForAllPins()) {
                showSpectraForAllPinsButton.setSelected(false);
            } else if (!isShowingSpectraForSelectedPins()) {
                plotMarker.setInvisible();
            }
            recreateChart();
        }
    });
    showSpectraForSelectedPinsButton.setName("showSpectraForSelectedPinsButton");
    showSpectraForSelectedPinsButton.setToolTipText("Show spectra for selected pins.");

    showSpectraForAllPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/PinSpectra24.gif"), true);
    showSpectraForAllPinsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isShowingSpectraForSelectedPins()) {
                showSpectraForSelectedPinsButton.setSelected(false);
            } else if (!isShowingSpectraForAllPins()) {
                plotMarker.setInvisible();
            }
            recreateChart();
        }
    });
    showSpectraForAllPinsButton.setName("showSpectraForAllPinsButton");
    showSpectraForAllPinsButton.setToolTipText("Show spectra for all pins.");

    // todo - not yet implemented for 4.1 but planned for 4.2 (mp - 31.10.2007)
    //        showAveragePinSpectrumButton = ToolButtonFactory.createButton(
    //                UIUtils.loadImageIcon("icons/AverageSpectrum24.gif"), true);
    //        showAveragePinSpectrumButton.addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                // todo - implement
    //            }
    //        });
    //        showAveragePinSpectrumButton.setName("showAveragePinSpectrumButton");
    //        showAveragePinSpectrumButton.setToolTipText("Show average spectrum of all pin spectra.");

    showGridButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SpectrumGrid24.gif"), true);
    showGridButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            chartHandler.setGridVisible(showGridButton.isSelected());
        }
    });
    showGridButton.setName("showGridButton");
    showGridButton.setToolTipText("Show diagram grid.");

    // todo - not yet implemented for 4.1 but planned for 4.2 (mp - 31.10.2007)
    //        showGraphPointsButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/GraphPoints24.gif"), true);
    //        showGraphPointsButton.addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                // todo - implement
    //                JOptionPane.showMessageDialog(null, "Not implemented");
    //            }
    //        });
    //        showGraphPointsButton.setName("showGraphPointsButton");
    //        showGraphPointsButton.setToolTipText("Show graph points grid.");

    AbstractButton exportSpectraButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    exportSpectraButton.addActionListener(new SpectraExportAction(this));
    exportSpectraButton.setToolTipText("Export spectra to text file.");
    exportSpectraButton.setName("exportSpectraButton");

    AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help22.png"),
            false);
    helpButton.setName("helpButton");
    helpButton.setToolTipText("Help."); /*I18N*/

    final JPanel buttonPane = GridBagUtils.createPanel();
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets.top = 2;
    gbc.gridy = 0;
    buttonPane.add(filterButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectrumForCursorButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectraForSelectedPinsButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectraForAllPinsButton, gbc);
    gbc.gridy++;
    // todo - not yet implemented for 4.1 but planned for 4.2 (mp - 31.10.2007)
    //        buttonPane.add(showAveragePinSpectrumButton, gbc);
    //        gbc.gridy++;
    buttonPane.add(showGridButton, gbc);
    gbc.gridy++;
    // todo - not yet implemented for 4.1 but planned for 4.2 (mp - 31.10.2007)
    //        buttonPane.add(showGraphPointsButton, gbc);
    //        gbc.gridy++;
    buttonPane.add(exportSpectraButton, gbc);

    gbc.gridy++;
    gbc.insets.bottom = 0;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.weighty = 1.0;
    gbc.gridwidth = 2;
    buttonPane.add(new JLabel(" "), gbc); // filler
    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;
    gbc.gridy = 10;
    gbc.anchor = GridBagConstraints.EAST;
    buttonPane.add(helpButton, gbc);

    chartPanel.setPreferredSize(new Dimension(300, 200));
    chartPanel.setBackground(Color.white);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createBevelBorder(BevelBorder.LOWERED), BorderFactory.createEmptyBorder(2, 2, 2, 2)));
    chartPanel.addChartMouseListener(plotMarker);

    JPanel mainPane = new JPanel(new BorderLayout(4, 4));
    mainPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPane.add(BorderLayout.CENTER, chartPanel);
    mainPane.add(BorderLayout.EAST, buttonPane);
    mainPane.setPreferredSize(new Dimension(320, 200));

    if (getDescriptor().getHelpId() != null) {
        HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId());
        HelpSys.enableHelpKey(mainPane, getDescriptor().getHelpId());
    }

    // Add an internal frame listener to VISAT so that we can update our
    // spectrum dialog with the information of the currently activated
    // product scene view.
    //
    VisatApp.getApp().addInternalFrameListener(new SpectrumIFL());

    VisatApp.getApp().getProductManager().addListener(new ProductManager.Listener() {
        @Override
        public void productAdded(ProductManager.Event event) {
            // ignored
        }

        @Override
        public void productRemoved(ProductManager.Event event) {
            final Product product = event.getProduct();
            if (getCurrentProduct() == product) {
                chartPanel.getChart().getXYPlot().setDataset(null);
                setCurrentView(null);
                setCurrentProduct(null);
            }
            if (productToAllSpectraMap.containsKey(product)) {
                productToAllSpectraMap.remove(product);
            }
            if (productToBandsMap.containsKey(product)) {
                productToBandsMap.remove(product);
            }
            PlacemarkGroup pinGroup = product.getPinGroup();
            for (int i = 0; i < pinGroup.getNodeCount(); i++) {
                chartHandler.removePinInformation(pinGroup.get(i));
            }
        }
    });

    final ProductSceneView view = VisatApp.getApp().getSelectedProductSceneView();
    if (view != null) {
        handleViewActivated(view);
    } else {
        setCurrentView(view);
    }
    updateUIState();
    return mainPane;
}

From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java

private JPanel createLanguagePanel(int stentWidth) {
    // Language radios.
    MultiBitTitledPanel languagePanel = new MultiBitTitledPanel(
            controller.getLocaliser().getString("showPreferencesPanel.languageTitle"),
            ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    GridBagConstraints constraints = new GridBagConstraints();

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 0;/*ww w  .j a  v  a 2s .co  m*/
    constraints.gridy = 3;
    constraints.weightx = 0.1;
    constraints.weighty = 0.05;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    JPanel indent = MultiBitTitledPanel.getIndentPanel(1);
    languagePanel.add(indent, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    JPanel stent = MultiBitTitledPanel.createStent(stentWidth);
    languagePanel.add(stent, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 3;
    constraints.weightx = 0.05;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.CENTER;
    languagePanel.add(MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS),
            constraints);

    ButtonGroup languageUsageGroup = new ButtonGroup();
    useDefaultLocale = new JRadioButton(controller.getLocaliser().getString("showPreferencesPanel.useDefault"));
    useDefaultLocale.setOpaque(false);
    useDefaultLocale.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());

    JRadioButton useSpecific = new JRadioButton(
            controller.getLocaliser().getString("showPreferencesPanel.useSpecific"));
    useSpecific.setOpaque(false);
    useSpecific.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());

    ItemListener itemListener = new ChangeLanguageUsageListener();
    useDefaultLocale.addItemListener(itemListener);
    useSpecific.addItemListener(itemListener);
    languageUsageGroup.add(useDefaultLocale);
    languageUsageGroup.add(useSpecific);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 4;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    languagePanel.add(useDefaultLocale, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 5;
    constraints.weightx = 0.2;
    constraints.weighty = 0.3;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    languagePanel.add(useSpecific, constraints);

    // Language combo box.
    int numberOfLanguages = Integer
            .parseInt(controller.getLocaliser().getString("showPreferencesPanel.numberOfLanguages"));

    // Languages are added to the combo box in alphabetic order.
    languageDataSet = new TreeSet<LanguageData>();

    for (int i = 0; i < numberOfLanguages; i++) {
        String languageCode = controller.getLocaliser()
                .getString("showPreferencesPanel.languageCode." + (i + 1));
        String language = controller.getLocaliser().getString("showPreferencesPanel.language." + (i + 1));

        LanguageData languageData = new LanguageData();
        languageData.languageCode = languageCode;
        languageData.language = language;
        languageData.image = createImageIcon(languageCode);
        languageData.image.setDescription(language);
        languageDataSet.add(languageData);
    }

    Integer[] indexArray = new Integer[languageDataSet.size()];
    int index = 0;
    for (@SuppressWarnings("unused")
    LanguageData languageData : languageDataSet) {
        indexArray[index] = index;
        index++;
    }
    languageComboBox = new JComboBox(indexArray);
    languageComboBox.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
    languageComboBox.setOpaque(false);
    LanguageComboBoxRenderer renderer = new LanguageComboBoxRenderer();

    FontMetrics fontMetrics = getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont());
    Dimension preferredSize = new Dimension(fontMetrics.stringWidth(A_LONG_LANGUAGE_NAME)
            + LANGUAGE_COMBO_WIDTH_DELTA + LANGUAGE_CODE_IMAGE_WIDTH,
            fontMetrics.getHeight() + COMBO_HEIGHT_DELTA);
    renderer.setPreferredSize(preferredSize);

    languageComboBox.setRenderer(renderer);

    // Get the languageCode value stored in the model.
    String userLanguageCode = controller.getModel().getUserPreference(CoreModel.USER_LANGUAGE_CODE);
    if (userLanguageCode == null || CoreModel.USER_LANGUAGE_IS_DEFAULT.equals(userLanguageCode)) {
        useDefaultLocale.setSelected(true);
        languageComboBox.setEnabled(false);
    } else {
        useSpecific.setSelected(true);
        int startingIndex = 0;
        Integer languageCodeIndex = 0;
        for (LanguageData languageData : languageDataSet) {
            if (languageData.languageCode.equals(userLanguageCode)) {
                languageCodeIndex = startingIndex;
                break;
            }
            startingIndex++;
        }
        if (languageCodeIndex != 0) {
            languageComboBox.setSelectedItem(languageCodeIndex);
            languageComboBox.setEnabled(true);
        }
    }

    // Store original value for use by submit action.
    originalUserLanguageCode = userLanguageCode;

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 3;
    constraints.gridy = 6;
    constraints.weightx = 0.8;
    constraints.weighty = 0.6;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    languagePanel.add(languageComboBox, constraints);

    JPanel fill1 = new JPanel();
    fill1.setOpaque(false);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 4;
    constraints.gridy = 6;
    constraints.weightx = 20;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    languagePanel.add(fill1, constraints);

    return languagePanel;
}

From source file:ro.nextreports.designer.wizimport.ImportPathSelectionWizardPanel.java

private void init() {
    setLayout(new BorderLayout());

    nameTextField = new JTextField();
    nameTextField.setPreferredSize(dim);
    nameTextField.setEditable(false);//from www.j  av a2  s.  c om

    propCheck = new JCheckBox(I18NSupport.getString("wizard.import.panel.start.select.title.prop"), true);

    selButton = new JButton();
    selButton.setPreferredSize(buttonDim);
    selButton.setMaximumSize(buttonDim);
    selButton.setMinimumSize(buttonDim);
    selButton.setIcon(ImageUtil.getImageIcon("folder"));
    selButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            fc.setDialogTitle(I18NSupport.getString("import.long.desc"));
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = fc.showSaveDialog((JDialog) context.getAttribute(ImportWizard.MAIN_FRAME));

            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File f = fc.getSelectedFile();
                if (f != null) {
                    nameTextField.setText(f.getName());
                    path = f.getAbsolutePath();
                }
            }
        }
    });

    JPanel dsPanel = new JPanel(new GridBagLayout());
    dsPanel.add(new JLabel(I18NSupport.getString("wizard.import.panel.start.select.title.label")),
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
                    new Insets(5, 5, 5, 0), 0, 0));
    dsPanel.add(nameTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    dsPanel.add(selButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    dsPanel.add(propCheck, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    dsPanel.add(new JLabel(""), new GridBagConstraints(3, 1, 1, 2, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    add(dsPanel, BorderLayout.CENTER);
}

From source file:org.jets3t.apps.cockpit.Cockpit.java

/**
 * Initialises the application's GUI elements.
 *///  w ww . j  a v  a  2 s .c  om
private void initGui() {
    initMenus();

    JPanel appContent = new JPanel(new GridBagLayout());
    this.getContentPane().add(appContent);

    // Buckets panel.
    JPanel bucketsPanel = new JPanel(new GridBagLayout());

    JButton bucketActionButton = new JButton();
    bucketActionButton.setToolTipText("Bucket actions menu");
    guiUtils.applyIcon(bucketActionButton, "/images/nuvola/16x16/actions/misc.png");
    bucketActionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton sourceButton = (JButton) e.getSource();
            bucketActionMenu.show(sourceButton, 0, sourceButton.getHeight());
        }
    });
    bucketsPanel.add(new JHtmlLabel("<html><b>Buckets</b></html>", this), new GridBagConstraints(0, 0, 1, 1, 1,
            0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    bucketsPanel.add(bucketActionButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    bucketTableModel = new BucketTableModel(false);
    bucketTableModelSorter = new TableSorter(bucketTableModel);
    bucketsTable = new JTable(bucketTableModelSorter);
    bucketTableModelSorter.setTableHeader(bucketsTable.getTableHeader());
    bucketsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    bucketsTable.getSelectionModel().addListSelectionListener(this);
    bucketsTable.setShowHorizontalLines(true);
    bucketsTable.setShowVerticalLines(false);
    bucketsTable.addMouseListener(new ContextMenuListener());
    bucketsPanel.add(new JScrollPane(bucketsTable), new GridBagConstraints(0, 1, 2, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
    bucketsPanel.add(new JLabel(" "), new GridBagConstraints(0, 2, 2, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));

    // Filter panel.
    filterObjectsPanel = new JPanel(new GridBagLayout());
    filterObjectsPrefix = new JTextField();
    filterObjectsPrefix.setToolTipText("Only show objects with this prefix");
    filterObjectsPrefix.addActionListener(this);
    filterObjectsPrefix.setActionCommand("RefreshObjects");
    filterObjectsDelimiter = new JComboBox(new String[] { "", "/", "?", "\\" });
    filterObjectsDelimiter.setEditable(true);
    filterObjectsDelimiter.setToolTipText("Object name delimiter");
    filterObjectsDelimiter.addActionListener(this);
    filterObjectsDelimiter.setActionCommand("RefreshObjects");
    filterObjectsPanel.add(new JHtmlLabel("Prefix:", this), new GridBagConstraints(0, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
    filterObjectsPanel.add(filterObjectsPrefix, new GridBagConstraints(1, 0, 1, 1, 1, 0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    filterObjectsPanel.add(new JHtmlLabel("Delimiter:", this), new GridBagConstraints(2, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    filterObjectsPanel.add(filterObjectsDelimiter, new GridBagConstraints(3, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
    filterObjectsPanel.setVisible(false);

    // Objects panel.
    JPanel objectsPanel = new JPanel(new GridBagLayout());
    int row = 0;
    filterObjectsCheckBox = new JCheckBox("Filter objects");
    filterObjectsCheckBox.addActionListener(this);
    filterObjectsCheckBox.setToolTipText("Check this option to filter the objects listed");
    objectsPanel.add(new JHtmlLabel("<html><b>Objects</b></html>", this), new GridBagConstraints(0, row, 1, 1,
            1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    objectsPanel.add(filterObjectsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    JButton objectActionButton = new JButton();
    objectActionButton.setToolTipText("Object actions menu");
    guiUtils.applyIcon(objectActionButton, "/images/nuvola/16x16/actions/misc.png");
    objectActionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton sourceButton = (JButton) e.getSource();
            objectActionMenu.show(sourceButton, 0, sourceButton.getHeight());
        }
    });
    objectsPanel.add(objectActionButton, new GridBagConstraints(2, row, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    objectsPanel.add(filterObjectsPanel, new GridBagConstraints(0, ++row, 3, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    objectsTable = new JTable();
    objectTableModel = new ObjectTableModel();
    objectTableModelSorter = new TableSorter(objectTableModel);
    objectTableModelSorter.setTableHeader(objectsTable.getTableHeader());
    objectsTable.setModel(objectTableModelSorter);
    objectsTable.setDefaultRenderer(Long.class, new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 301092191828910402L;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            String formattedSize = byteFormatter.formatByteSize(((Long) value).longValue());
            return super.getTableCellRendererComponent(table, formattedSize, isSelected, hasFocus, row, column);
        }
    });
    objectsTable.setDefaultRenderer(Date.class, new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 7285511556343895652L;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Date date = (Date) value;
            return super.getTableCellRendererComponent(table, yearAndTimeSDF.format(date), isSelected, hasFocus,
                    row, column);
        }
    });
    objectsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    objectsTable.getSelectionModel().addListSelectionListener(this);
    objectsTable.setShowHorizontalLines(true);
    objectsTable.setShowVerticalLines(true);
    objectsTable.addMouseListener(new ContextMenuListener());
    objectsTableSP = new JScrollPane(objectsTable);
    objectsPanel.add(objectsTableSP, new GridBagConstraints(0, ++row, 3, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsZero, 0, 0));
    objectsSummaryLabel = new JHtmlLabel("Please select a bucket", this);
    objectsSummaryLabel.setHorizontalAlignment(JLabel.CENTER);
    objectsSummaryLabel.setFocusable(false);
    objectsPanel.add(objectsSummaryLabel, new GridBagConstraints(0, ++row, 3, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    // Combine sections.
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, bucketsPanel, objectsPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setContinuousLayout(true);

    appContent.add(splitPane, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));

    // Set preferred sizes
    int preferredWidth = 800;
    int preferredHeight = 600;
    this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight)));

    splitPane.setResizeWeight(0.30);

    // Initialize drop target.
    initDropTarget(new JComponent[] { objectsTableSP, objectsTable });
    objectsTable.getDropTarget().setActive(false);
    objectsTableSP.getDropTarget().setActive(false);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.JPanStringMatchMain.java

/**
 * This method initializes jPanel2   /*  w  ww  . jav  a2 s.c  om*/
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelThisFileContainsFolderTitle() {
    if (jPanelThisFileContainsFolderTitle == null) {
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.anchor = GridBagConstraints.WEST;
        gridBagConstraints1.insets = new Insets(3, 0, 0, 0);
        gridBagConstraints1.gridwidth = 1;
        gridBagConstraints1.gridx = -1;
        gridBagConstraints1.gridy = -1;
        gridBagConstraints1.weightx = 0.0;
        gridBagConstraints1.fill = GridBagConstraints.NONE;
        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
        gridBagConstraints10.gridx = 1;
        gridBagConstraints10.insets = new Insets(3, 10, 0, 0);
        gridBagConstraints10.gridy = 0;
        jPanelThisFileContainsFolderTitle = new JPanel();
        jPanelThisFileContainsFolderTitle.setLayout(new GridBagLayout());
        jPanelThisFileContainsFolderTitle.add(getJRadioButtonThisFileContains(), gridBagConstraints1);
        jPanelThisFileContainsFolderTitle.add(getJButtonRepreLicen(), gridBagConstraints10);
    }
    return jPanelThisFileContainsFolderTitle;
}

From source file:com.sec.ose.osi.ui.dialog.setting.JPanProjectAnalysisSetting.java

/**
 * This method initializes jInnerPanel   
 *    //www  . j  a va2 s.  c o  m
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelMonitorInterval() {
    if (jInnerPanel == null) {
        GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
        gridBagConstraints12.anchor = GridBagConstraints.WEST;
        gridBagConstraints12.gridx = 0;
        gridBagConstraints12.gridy = 1;
        gridBagConstraints12.weightx = 1.0;
        gridBagConstraints12.insets = new Insets(0, 0, 10, 0);
        gridBagConstraints12.fill = GridBagConstraints.NONE;
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.anchor = GridBagConstraints.WEST;
        gridBagConstraints8.insets = new Insets(0, 0, 0, 0);
        gridBagConstraints8.gridx = -1;
        gridBagConstraints8.gridy = -1;
        gridBagConstraints8.weightx = 1.0;
        gridBagConstraints8.fill = GridBagConstraints.NONE;
        jInnerPanel = new JPanel();
        jInnerPanel.setLayout(new GridBagLayout());
        jInnerPanel.setBorder(BorderFactory.createTitledBorder(null, "Monitor Interval",
                TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jInnerPanel.add(getJIntRadioTopPanel(), gridBagConstraints8);
        jInnerPanel.add(getJIntRadioBottomPanel(), gridBagConstraints12);
    }
    return jInnerPanel;
}