Example usage for java.awt GridBagLayout GridBagLayout

List of usage examples for java.awt GridBagLayout GridBagLayout

Introduction

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

Prototype

public GridBagLayout() 

Source Link

Document

Creates a grid bag layout manager.

Usage

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

/**
 * This method initializes jPanelValue   
 *    //from w  w w .  jav a 2  s  .  c  o m
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelValue() {
    if (jPanelValue == null) {

        jPanelValue = new JPanel();
        jPanelValue.setLayout(new GridBagLayout());
        jPanelValue.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jPanelValue.setPreferredSize(new Dimension(400, 200));

        // Default Report Location

        jLabelDefaultReportLocation = new JLabel();
        jLabelDefaultReportLocation.setText("Default Report Location:");
        jLabelDefaultReportLocation.setHorizontalAlignment(SwingConstants.RIGHT);

        GridBagConstraints gridBagConstraintsjLabelDefaultReportLocation = new GridBagConstraints();
        gridBagConstraintsjLabelDefaultReportLocation.gridx = 0;
        gridBagConstraintsjLabelDefaultReportLocation.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsjLabelDefaultReportLocation.insets = new Insets(5, 0, 0, 0);
        gridBagConstraintsjLabelDefaultReportLocation.gridy = 1;

        GridBagConstraints gridBagConstraintsjpanelDefaultReportLocation = new GridBagConstraints();
        gridBagConstraintsjpanelDefaultReportLocation.fill = GridBagConstraints.BOTH;
        gridBagConstraintsjpanelDefaultReportLocation.gridy = 1;
        gridBagConstraintsjpanelDefaultReportLocation.weightx = 1.0;
        gridBagConstraintsjpanelDefaultReportLocation.insets = new Insets(10, 5, 5, 15);
        gridBagConstraintsjpanelDefaultReportLocation.gridx = 1;

        // reciprocal license

        jLabelReciprocalLicense = new JLabel();
        jLabelReciprocalLicense.setText("Reciprocal License (RED):");
        jLabelReciprocalLicense.setHorizontalAlignment(SwingConstants.RIGHT);

        GridBagConstraints gridBagConstraintsjLabelReciprocalLicense = new GridBagConstraints();
        gridBagConstraintsjLabelReciprocalLicense.gridx = 0;
        gridBagConstraintsjLabelReciprocalLicense.insets = new Insets(0, 15, 0, 0);
        gridBagConstraintsjLabelReciprocalLicense.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsjLabelReciprocalLicense.gridy = 2;
        jPanelValue.add(jLabelDefaultReportLocation, gridBagConstraintsjLabelDefaultReportLocation);
        jPanelValue.add(getJPanelDefaultReportLocation(), gridBagConstraintsjpanelDefaultReportLocation);
        jPanelValue.add(jLabelReciprocalLicense, gridBagConstraintsjLabelReciprocalLicense);

        GridBagConstraints gridBagConstraintsgetJTextFieldReciprocalLicense = new GridBagConstraints();
        gridBagConstraintsgetJTextFieldReciprocalLicense.gridx = 1;
        gridBagConstraintsgetJTextFieldReciprocalLicense.weightx = 1.0;
        gridBagConstraintsgetJTextFieldReciprocalLicense.fill = GridBagConstraints.BOTH;
        gridBagConstraintsgetJTextFieldReciprocalLicense.insets = new Insets(5, 5, 5, 15);
        gridBagConstraintsgetJTextFieldReciprocalLicense.gridy = 2;
        jPanelValue.add(getJTextFieldReciprocalLicense(), gridBagConstraintsgetJTextFieldReciprocalLicense);

        // major license

        jLabelMajorLicense = new JLabel();
        jLabelMajorLicense.setText("Major License (ORANGE):");
        jLabelMajorLicense.setHorizontalAlignment(SwingConstants.RIGHT);

        GridBagConstraints gridBagConstraintsjLabelMajorLicense = new GridBagConstraints();
        gridBagConstraintsjLabelMajorLicense.gridx = 0;
        gridBagConstraintsjLabelMajorLicense.insets = new Insets(0, 15, 0, 0);
        gridBagConstraintsjLabelMajorLicense.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsjLabelMajorLicense.gridy = 3;
        jPanelValue.add(jLabelMajorLicense, gridBagConstraintsjLabelMajorLicense);

        GridBagConstraints gridBagConstraintsgetJTextFieldMajorLicense = new GridBagConstraints();
        gridBagConstraintsgetJTextFieldMajorLicense.gridx = 1;
        gridBagConstraintsgetJTextFieldMajorLicense.weightx = 1.0;
        gridBagConstraintsgetJTextFieldMajorLicense.fill = GridBagConstraints.BOTH;
        gridBagConstraintsgetJTextFieldMajorLicense.insets = new Insets(5, 5, 5, 15);
        gridBagConstraintsgetJTextFieldMajorLicense.gridy = 3;
        jPanelValue.add(getJTextFieldMajorLicense(), gridBagConstraintsgetJTextFieldMajorLicense);

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridx = 1;
        gridBagConstraints3.weighty = 1.0;
        gridBagConstraints3.weightx = 0.0;
        gridBagConstraints3.gridy = 4;
        JLabel jLabelEmpty = new JLabel();
        jLabelEmpty.setText("");
        jPanelValue.add(jLabelEmpty, gridBagConstraints3);
    }
    return jPanelValue;
}

From source file:de.codesourcery.jasm16.ide.ui.viewcontainers.EditorContainer.java

private JPanel createPanel() {
    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);

    setColors(result);/*from  w  w  w.ja v a 2  s .  c  om*/
    tabbedPane.setBackground(Color.WHITE);
    tabbedPane.setForeground(Color.black);
    result.add(tabbedPane, cnstrs);

    if (getViewContainer().getMenuManager() != null) {
        getViewContainer().getMenuManager().addEntry(saveCurrent);
    }

    tabbedPane.addChangeListener(changeListener);

    tabbedPane.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_W && (e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) {
                int idx = tabbedPane.getSelectedIndex();
                if (idx != -1) {
                    disposeView(getViewForTabIndex(idx));
                }
            }
        }
    });
    return result;
}

From source file:coreferenceresolver.gui.MarkupGUI.java

public MarkupGUI() throws IOException {
    highlightPainters = new ArrayList<>();

    for (int i = 0; i < COLORS.length; ++i) {
        DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter(
                COLORS[i]);//  w  w  w  .j a v a 2  s . c om
        highlightPainters.add(highlightPainter);
    }

    defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath"));
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setLayout(new BorderLayout());
    this.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    //create menu items
    JMenuItem importMenuItem = new JMenuItem("Import");

    JMenuItem exportMenuItem = new JMenuItem("Export");

    fileMenu.add(importMenuItem);
    fileMenu.add(exportMenuItem);

    menuBar.add(fileMenu);

    this.setJMenuBar(menuBar);

    ScrollablePanel mainPanel = new ScrollablePanel();
    mainPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.NONE);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    //IMPORT BUTTON
    importMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //                MarkupGUI.reviewElements.clear();
            //                MarkupGUI.markupReviews.clear();                
            JFileChooser markupFileChooser = new JFileChooser(defaulPath);
            markupFileChooser.setDialogTitle("Choose your markup file");
            markupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

            if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                final JDialog d = new JDialog();
                JPanel p1 = new JPanel(new GridBagLayout());
                p1.add(new JLabel("Please Wait..."), new GridBagConstraints());
                d.getContentPane().add(p1);
                d.setSize(100, 100);
                d.setLocationRelativeTo(null);
                d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                d.setModal(true);

                SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() {
                    protected Void doInBackground() throws IOException, BadLocationException {
                        readMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath());
                        for (int i = 0; i < markupReviews.size(); ++i) {
                            mainPanel.add(newReviewPanel(markupReviews.get(i), i));
                        }
                        return null;
                    }

                    protected void done() {
                        MarkupGUI.this.revalidate();
                        d.dispose();
                    }
                };
                worker.execute();
                d.setVisible(true);
            } else {
                return;
            }
        }
    });

    //EXPORT BUTTON: GET NEW VALUE (REF, TYPE) OF NPs      
    exportMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser markupFileChooser = new JFileChooser(defaulPath);
            markupFileChooser.setDialogTitle("Choose where your markup file saved");
            markupFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                final JDialog d = new JDialog();
                JPanel p1 = new JPanel(new GridBagLayout());
                p1.add(new JLabel("Please Wait..."), new GridBagConstraints());
                d.getContentPane().add(p1);
                d.setSize(100, 100);
                d.setLocationRelativeTo(null);
                d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                d.setModal(true);

                SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() {
                    protected Void doInBackground() throws IOException {
                        for (Review review : markupReviews) {
                            generateNPsRef(review);
                        }
                        int i = 0;
                        for (ReviewElement reviewElement : reviewElements) {
                            int j = 0;
                            for (Element element : reviewElement.elements) {
                                String newType = element.typeSpinner.getValue().toString();
                                if (newType.equals("Object")) {
                                    markupReviews.get(i).getNounPhrases().get(j).setType(0);
                                } else if (newType.equals("Attribute")) {
                                    markupReviews.get(i).getNounPhrases().get(j).setType(3);
                                } else if (newType.equals("Other")) {
                                    markupReviews.get(i).getNounPhrases().get(j).setType(1);
                                } else if (newType.equals("Candidate")) {
                                    markupReviews.get(i).getNounPhrases().get(j).setType(2);
                                }
                                ++j;
                            }
                            ++i;
                        }
                        initMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath() + File.separator
                                + "markup.out.txt");
                        return null;
                    }

                    protected void done() {
                        d.dispose();
                        try {
                            Desktop.getDesktop()
                                    .open(new File(markupFileChooser.getSelectedFile().getAbsolutePath()));
                        } catch (IOException ex) {
                            Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                };
                worker.execute();
                d.setVisible(true);
            } else {
                return;
            }
        }
    });

    JScrollPane scrollMainPane = new JScrollPane(mainPanel);
    scrollMainPane.getVerticalScrollBar().setUnitIncrement(16);
    scrollMainPane.setPreferredSize(new Dimension(this.getWidth(), this.getHeight()));
    scrollMainPane.setSize(this.getWidth(), this.getHeight());
    this.setResizable(false);
    this.add(scrollMainPane, BorderLayout.CENTER);
    this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    this.pack();
}

From source file:com.choicemaker.cm.modelmaker.gui.panels.StatisticsHistogramPanel.java

private void layoutPanel() {
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);/*from w  w w .  j  a  va  2  s. co m*/
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 10, 5, 10);

    //Row 0..........................................................
    //histo
    c.gridy = 0;
    c.gridx = 0;
    c.gridwidth = 5;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    add(histoPanel, c);

    //Row 1..........................................................
    //binWidthLabel
    c.gridy = 1;
    c.gridx = 1;
    c.gridwidth = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(binWidthLabel, c);
    add(binWidthLabel);
    //binWidthField
    c.gridx = 2;
    c.ipadx = 10;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    layout.setConstraints(binWidthField, c);
    add(binWidthField);
}

From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectAdd.java

/**
 * This method initializes this//from w  w w.j a  va  2 s  .c o  m
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
    gridBagConstraints10.gridx = 1;
    gridBagConstraints10.anchor = GridBagConstraints.NORTH;
    gridBagConstraints10.insets = new Insets(10, 0, 0, 0);
    gridBagConstraints10.fill = GridBagConstraints.NONE;
    gridBagConstraints10.gridy = 0;
    GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
    gridBagConstraints9.gridx = 0;
    gridBagConstraints9.insets = new Insets(10, 10, 10, 0);
    gridBagConstraints9.fill = GridBagConstraints.BOTH;
    gridBagConstraints9.weightx = 0.1;
    gridBagConstraints9.weighty = 0.1;
    gridBagConstraints9.gridheight = 1;
    gridBagConstraints9.gridy = 0;

    JPanel p = new JPanel();
    p.setSize(600, 300);
    p.setLayout(new GridBagLayout());
    p.add(getJPanelPjtList(), gridBagConstraints9);
    p.add(getJPanelButton(), gridBagConstraints10);

    getContentPane().add(p);
}

From source file:cool.pandora.modeller.ui.jpanel.base.NewBagFrame.java

/**
 * createComponents./*w  ww  .  j a v  a2  s  .c o m*/
 *
 * @return pageControl
 */
private JPanel createComponents() {
    final TitlePane titlePane = new TitlePane();
    initStandardCommands();
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("NewBagFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("NewBagFrame" + ".description")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);

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

    int row = 0;
    layoutBagVersionSelection(contentPane, row++);
    layoutProfileSelection(contentPane, row++);

    if (getPreferredSize() != null) {
        contentPane.setPreferredSize(getPreferredSize());
    }

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(contentPane);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;
}

From source file:com.idealista.solrmeter.view.statistic.CacheHistoryPanel.java

/**
 * Creates the left panel, with the combo boxes to select wether to see hit ratio
 * or specific cache data, and if specific cache data is selected, will also show
 * the combo box to select the cache and the cumulative information
 * @return/*from  w  w w.  jav a  2s.com*/
 */
private Component createLeftPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.insets = new Insets(1, 1, 1, 1);
    for (Component component : this.createControlPanel()) {
        panel.add(component, constraints);
        constraints.gridy++;
    }
    cumulativeDataPanel = this.createCumulativeDataPanel();
    panel.add(cumulativeDataPanel, constraints);
    constraints.gridy++;
    constraints.weighty = 2.0;
    panel.add(Box.createVerticalGlue(), constraints);
    panel.setMaximumSize(new Dimension(100, Integer.MAX_VALUE));

    return panel;
}

From source file:Main.java

private void initScreen() {
    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new GridBagLayout());
    sourceLabel = new JLabel(DEFAULT_SOURCE_CHOICE_LABEL);
    sourceListModel = new SortedListModel();
    sourceList = new JList(sourceListModel);
    add(sourceLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, EMPTY_INSETS, 0, 0));
    add(new JScrollPane(sourceList), new GridBagConstraints(0, 1, 1, 5, .5, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, EMPTY_INSETS, 0, 0));

    addButton = new JButton(ADD_BUTTON_LABEL);
    add(addButton, new GridBagConstraints(1, 2, 1, 2, 0, .25, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, EMPTY_INSETS, 0, 0));
    addButton.addActionListener(new AddListener());
    removeButton = new JButton(REMOVE_BUTTON_LABEL);
    add(removeButton, new GridBagConstraints(1, 4, 1, 2, 0, .25, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
    removeButton.addActionListener(new RemoveListener());

    destLabel = new JLabel(DEFAULT_DEST_CHOICE_LABEL);
    destListModel = new SortedListModel();
    destList = new JList(destListModel);
    add(destLabel, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
            EMPTY_INSETS, 0, 0));/*from   www .j a  va  2 s  .  c  om*/
    add(new JScrollPane(destList), new GridBagConstraints(2, 1, 1, 5, .5, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, EMPTY_INSETS, 0, 0));
}

From source file:pipeline.parameter_cell_views.FloatRangeSlider.java

public FloatRangeSlider() {
    super();/*w  ww. j a va2s. c o  m*/
    addMouseWheelListener(e -> {

        int rotation = e.getWheelRotation();

        float[] float_values = (float[]) (currentParameter.getValue());
        currentValue0 = float_values[0];
        currentValue1 = float_values[1];
        minimum = float_values[2];
        maximum = float_values[3];

        float change = (currentValue1 - currentValue0 + 1) * rotation * Utils.getMouseWheelClickFactor();

        currentValue0 += change;
        currentValue1 += change;

        if (!((e.getModifiers() & java.awt.event.InputEvent.ALT_MASK) > 0)) {
            if (currentValue1 > maximum) {
                float difference = currentValue1 - currentValue0;
                currentValue1 = maximum;
                currentValue0 = currentValue1 - difference;
            }
            if (currentValue0 < minimum) {
                float difference = currentValue1 - currentValue0;
                currentValue0 = minimum;
                currentValue1 = currentValue0 + difference;
            }
        }

        currentParameter.setValue(new float[] { currentValue0, currentValue1, minimum, maximum });

        readInValuesFromParameter();
        updateDisplays();
        currentParameter.fireValueChanged(false, false, true);
    });
    nf.setGroupingUsed(true);
    nf.setMaximumFractionDigits(5);
    nf.setMaximumIntegerDigits(10);

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;

    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 1.0;
    c.gridwidth = 4;

    cForHistogram = (GridBagConstraints) c.clone();

    panelForHistogram = new JPanel();
    panelForHistogram.setPreferredSize(new Dimension(200, 150));
    panelForHistogram.setLayout(new BorderLayout());

    c.gridx = 0;
    c.gridy = 1;// 1
    c.weighty = 0.0;
    c.weightx = 0.0;
    c.gridwidth = 4;
    add(Box.createRigidArea(new Dimension(0, 5)), c);

    slider = new RangeSlider(0, 20);
    slider.addChangeListener(new sliderListener());
    c.gridx = 0;
    c.gridy = 2;
    c.weighty = 0.0;
    c.weightx = 0.0;
    c.gridwidth = 4;
    add(slider, c);

    c.gridx = 0;
    c.gridy = 3;
    c.weighty = 0.0;
    c.weightx = 1.0;
    c.gridwidth = 4;
    Component comp = Box.createRigidArea(new Dimension(0, 10));
    ((JComponent) comp).setOpaque(true);
    add(comp, c);
    c.gridwidth = 1;

    final textBoxListener minMaxListener = new textBoxListener();

    currentTextValue0 = new JTextField("");
    currentTextValue1 = new JTextField("");
    currentTextValue0.addActionListener(new textBoxListenerTriggersUpdate());
    currentTextValue1.addActionListener(new textBoxListenerTriggersUpdate());
    Font smallerFont = new Font(currentTextValue0.getFont().getName(), currentTextValue0.getFont().getStyle(),
            currentTextValue0.getFont().getSize() - 2);
    textMinimum = new JTextField("0");
    textMinimum.setFont(smallerFont);
    textMinimum.addActionListener(minMaxListener);
    textMaximum = new JTextField("50");
    textMaximum.setFont(smallerFont);
    textMaximum.addActionListener(minMaxListener);
    textMaximum.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            minMaxListener.actionPerformed(new ActionEvent(textMaximum, 0, ""));
        }
    });
    textMinimum.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            minMaxListener.actionPerformed(new ActionEvent(textMinimum, 0, ""));
        }
    });

    textValueFrame = new JPanel();
    textValueFrame.setBackground(getBackground());
    textValueFrame.setLayout(new GridBagLayout());

    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 0.1;
    textValueFrame.add(textMinimum, c);

    c.gridx = 1;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 0.3;
    textValueFrame.add(currentTextValue0, c);

    c.gridx = 2;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 0.3;
    textValueFrame.add(currentTextValue1, c);

    c.gridx = 3;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 0.1;
    textValueFrame.add(textMaximum, c);

    c.gridx = 0;
    c.gridy = 4;
    c.weighty = 0.0;
    c.weightx = 0.3;
    c.gridwidth = 4;
    add(textValueFrame, c);
    c.gridwidth = 1;

    parameterName = new JLabel("parameter");
    c.gridx = 0;
    c.gridy = 5;
    c.weighty = 0.0;
    c.weightx = 0.01;
    c.gridwidth = 1;
    add(parameterName, c);

    resetMin = new JButton("Min");
    resetMin.setActionCommand("Reset Min");
    resetMin.addActionListener(new buttonListener());
    resetMax = new JButton("Max");
    resetMax.setActionCommand("Reset Max");
    resetMax.addActionListener(new buttonListener());
    resetRange = new JButton("MinMax");
    resetRange.setActionCommand("Reset Range");
    resetRange.addActionListener(new buttonListener());

    c.gridx = 1;
    c.gridy = 5;
    c.weighty = 0.0;
    c.weightx = 0.2;
    c.gridwidth = 1;
    add(resetMin, c);

    c.gridx = 2;
    c.gridy = 5;
    c.weighty = 0.0;
    c.weightx = 0.2;
    c.gridwidth = 1;
    add(resetMax, c);

    c.gridx = 3;
    c.gridy = 5;
    c.weighty = 0.0;
    c.weightx = 0.2;
    c.gridwidth = 1;
    add(resetRange, c);
    // ,resetMax,resetRange;

}

From source file:com.intel.stl.ui.monitor.view.PSEventsCardView.java

@Override
protected JComponent getMainComponent() {

    if (mainPanel != null) {
        return mainPanel;
    }//from   w w  w  .j ava  2  s.co m

    mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 5));

    GridBagConstraints gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.weightx = 0;

    piePanel = new NodeStatesPie(false);
    piePanel.setOpaque(false);
    mainPanel.add(piePanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 1;
    gc.weighty = 1;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    barPanel = new ChartPanel(null);
    barPanel.setPreferredSize(new Dimension(60, 20));
    barPanel.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            barPanel.setMaximumDrawHeight(e.getComponent().getHeight());
            barPanel.setMaximumDrawWidth(e.getComponent().getWidth());
            barPanel.setMinimumDrawWidth(e.getComponent().getWidth());
            barPanel.setMinimumDrawHeight(e.getComponent().getHeight());
        }
    });
    barPanel.setOpaque(false);
    mainPanel.add(barPanel, gc);

    return mainPanel;

}