Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

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

Prototype

int BOTH

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

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java

/**
 * Build the student body states panel./*w  w w.j ava2  s. c  o m*/
 *
 * @return Student body states panel.
 */
private JPanel buildUiStudentBodyStatesPanel() {
    // Create a new grid bag constraints configuration instance
    GridBagConstraints c = new GridBagConstraints();

    // Create the panel
    final JPanel studentBodyStatePanel = new JPanel(new GridBagLayout());

    // Add the label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(8, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentBodyStatePanel.add(new JLabel("Student's body states:"), c);

    // Create a list for the students body states
    this.studentBodyStates = new EntityViewComponent(Core.getInstance().getBodyStateManager());

    // Add the list
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentBodyStatePanel.add(this.studentBodyStates, c);

    // Update the student body state list when the selected student is changed
    this.studentList.addSelectionChangeListenerListener(this::updateStudentBodyStateList);

    // Set the minimum preferred size of the body states list
    this.studentBodyStates.setPreferredSize(new Dimension(200, 100));

    // Return the panel
    return studentBodyStatePanel;
}

From source file:org.intermine.install.swing.NewDerivedTypeDialog.java

/**
 * Initialise to show the properties needed to complete to create the
 * derived source from the given parent.
 * /* w  ww.  j  av a2 s. co m*/
 * @param project The Project being edited.
 * @param parentType The parent data source type descriptor.
 * @param name The name of the actual data source to add to the project.
 */
public void initialise(Project project, SourceInfo parentType, String name) {
    Container cp = getContentPane();

    this.project = project;
    parentInfo = parentType;

    nameField.setText(name);
    typeField.setText(parentType.getSource().getType());
    derivedTypeField.setText(name);

    for (JComponent c : additionalFields) {
        cp.remove(c);
    }
    cp.remove(spacerPanel);
    cp.remove(buttonPanel);

    additionalFields.clear();
    wrappers.clear();

    GridBagConstraints cons = GridBagHelper.defaultConstraints();

    cons.gridy = 3;

    SourceTypeDerivation derivation = parentInfo.getSource().getDerivation();
    assert derivation != null : "No derivation on source";
    for (PropertyDescriptor descriptor : derivation.getProperty()) {

        JLabel label = new JLabel(descriptor.getName());
        cons.gridx = 0;
        cons.weightx = 0;
        cp.add(label, cons);
        additionalFields.add(label);

        PropertyComponentWrapper wrapper = PropertyComponentCreator.createComponentFor(descriptor.getName(),
                descriptor, "");
        cons.weightx = 1;
        cons.gridx++;
        cp.add(wrapper.getDisplayComponent(), cons);
        additionalFields.add(wrapper.getDisplayComponent());
        wrappers.add(wrapper);

        cons.gridy++;
    }

    cons.gridx = 0;
    cons.weightx = 1;
    cons.weighty = 1;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.fill = GridBagConstraints.BOTH;
    cp.add(spacerPanel, cons);

    cons.gridy++;
    cons.weighty = 0;
    cons.fill = GridBagConstraints.HORIZONTAL;
    cp.add(buttonPanel, cons);

    pack();
}

From source file:com.stefanbrenner.droplet.utils.UiUtilsTest.java

@Test
public void testEditGridBagConstraints() {
    GridBagConstraints gbc = new GridBagConstraints(1, 2, 3, 4, 5.0, 6.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(1, 2, 3, 4), 9, 0);

    UiUtils.editGridBagConstraints(gbc, 11, 12);
    assertEquals(11, gbc.gridx);//  w ww  .j av  a 2 s . c  o  m
    assertEquals(12, gbc.gridy);
    assertEquals(3, gbc.gridwidth);
    assertEquals(4, gbc.gridheight);
    assertEquals(0.0, gbc.weightx);
    assertEquals(0.0, gbc.weighty);
    assertEquals(GridBagConstraints.CENTER, gbc.anchor);
    assertEquals(GridBagConstraints.BOTH, gbc.fill);

    UiUtils.editGridBagConstraints(gbc, 13, 14, 15.0, 16.0);
    assertEquals(13, gbc.gridx);
    assertEquals(14, gbc.gridy);
    assertEquals(3, gbc.gridwidth);
    assertEquals(4, gbc.gridheight);
    assertEquals(15.0, gbc.weightx);
    assertEquals(16.0, gbc.weighty);
    assertEquals(GridBagConstraints.CENTER, gbc.anchor);
    assertEquals(GridBagConstraints.BOTH, gbc.fill);

    UiUtils.editGridBagConstraints(gbc, 17, 18, 19.0, 20.0, GridBagConstraints.WEST);
    assertEquals(17, gbc.gridx);
    assertEquals(18, gbc.gridy);
    assertEquals(3, gbc.gridwidth);
    assertEquals(4, gbc.gridheight);
    assertEquals(19.0, gbc.weightx);
    assertEquals(20.0, gbc.weighty);
    assertEquals(GridBagConstraints.WEST, gbc.anchor);
    assertEquals(GridBagConstraints.BOTH, gbc.fill);

}

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

protected JPanel createFlowTypePanel() {
    JPanel panel = new JPanel();
    panel.setOpaque(false);//from   w ww .  j av a2s.c  o  m
    panel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    GridBagLayout gridBag = new GridBagLayout();
    panel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.insets = new Insets(8, 2, 2, 2);
    gc.weighty = 0;
    gc.weightx = 1;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.gridheight = 1;
    flowTypeChartPanel = new ChartPanel(null);
    flowTypeChartPanel.setPreferredSize(new Dimension(80, 60));
    panel.add(flowTypeChartPanel, gc);

    flowNumberLabels = new JLabel[flowTypes.length];
    flowNameLabels = new JLabel[flowTypes.length];
    gc.fill = GridBagConstraints.BOTH;
    gc.insets = new Insets(2, 2, 2, 2);
    for (int i = 0; i < flowTypes.length; i++) {
        gc.weightx = 1;
        gc.gridwidth = 1;
        flowNumberLabels[i] = createNumberLabel();
        panel.add(flowNumberLabels[i], gc);

        gc.weightx = 0;
        gc.gridwidth = GridBagConstraints.REMAINDER;
        flowNameLabels[i] = createNameLabel(flowTypes[i].getName());
        panel.add(flowNameLabels[i], gc);
    }

    return panel;
}

From source file:org.opendatakit.briefcase.ui.settings.SettingsPanelForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL// w ww.j a  va  2s. c om
 */
private void $$$setupUI$$$() {
    createUIComponents();
    container = new JPanel();
    container.setLayout(new GridBagLayout());
    storageLocationContainer = new JPanel();
    storageLocationContainer.setLayout(new GridBagLayout());
    GridBagConstraints gbc;
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridwidth = 5;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(storageLocationContainer, gbc);
    storageLocationLabel = new JLabel();
    storageLocationLabel.setText("Storage Location");
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    storageLocationContainer.add(storageLocationLabel, gbc);
    storageLocationField = new JTextField();
    storageLocationField.setEditable(false);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    storageLocationContainer.add(storageLocationField, gbc);
    storageLocationButtons = new JPanel();
    storageLocationButtons.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    storageLocationContainer.add(storageLocationButtons, gbc);
    storageLocationClearButton = new JButton();
    storageLocationClearButton.setText("Clear");
    storageLocationClearButton.setVisible(false);
    storageLocationButtons.add(storageLocationClearButton);
    storageLocationChooseButton = new JButton();
    storageLocationChooseButton.setText("Choose...");
    storageLocationButtons.add(storageLocationChooseButton);
    final JPanel spacer1 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    storageLocationContainer.add(spacer1, gbc);
    pullInParallelField = new JCheckBox();
    pullInParallelField.setText("Pull submissions in parallel (experimental)");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(pullInParallelField, gbc);
    rememberPasswordsField = new JCheckBox();
    rememberPasswordsField.setText("Remember passwords (unencrypted)");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(rememberPasswordsField, gbc);
    sendUsageDataField = new JCheckBox();
    sendUsageDataField.setText("Send usage data and crash logs to core developers");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 9;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(sendUsageDataField, gbc);
    useHttpProxyField = new JCheckBox();
    useHttpProxyField.setText("Use HTTP Proxy");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 11;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(useHttpProxyField, gbc);
    final JPanel spacer2 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 12;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 0, 20);
    container.add(spacer2, gbc);
    httpProxyJostLabel = new JLabel();
    httpProxyJostLabel.setText("Host");
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 12;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(httpProxyJostLabel, gbc);
    httpProxyHostField = new JTextField();
    httpProxyHostField.setPreferredSize(new Dimension(150, 30));
    httpProxyHostField.setText("127.0.0.1");
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 12;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(httpProxyHostField, gbc);
    final JPanel spacer3 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.gridy = 12;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(spacer3, gbc);
    httpProxyPortLabel = new JLabel();
    httpProxyPortLabel.setText("Port");
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 13;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(httpProxyPortLabel, gbc);
    final JPanel spacer4 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 5;
    gbc.gridy = 12;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(spacer4, gbc);
    httpProxyPortField.setPreferredSize(new Dimension(150, 30));
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 13;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(httpProxyPortField, gbc);
    final JPanel spacer5 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 10;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer5, gbc);
    final JPanel spacer6 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 6;
    gbc.gridy = 1;
    gbc.gridheight = 13;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(spacer6, gbc);
    final JPanel spacer7 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridheight = 13;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(spacer7, gbc);
    final JPanel spacer8 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer8, gbc);
    final JPanel spacer9 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 14;
    gbc.gridwidth = 5;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer9, gbc);
    final JPanel spacer10 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer10, gbc);
    final JPanel spacer11 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer11, gbc);
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 15;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.BOTH;
    container.add(panel1, gbc);
    panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Troubleshooting"));
    reloadCacheButton = new JButton();
    reloadCacheButton.setEnabled(false);
    reloadCacheButton.setText("Reload forms from storage location");
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(reloadCacheButton, gbc);
    final JPanel spacer12 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer12, gbc);
    final JPanel spacer13 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 9;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer13, gbc);
    final JPanel spacer14 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.gridy = 8;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer14, gbc);
    final JPanel spacer15 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer15, gbc);
    final JLabel label1 = new JLabel();
    label1.setText("The form list in Briefcase can get out of date if files are moved manually.");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    panel1.add(label1, gbc);
    final JLabel label2 = new JLabel();
    label2.setText("This reload is always safe.");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    panel1.add(label2, gbc);
    final JPanel spacer16 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer16, gbc);
    final JPanel spacer17 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer17, gbc);
    final JPanel spacer18 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer18, gbc);
    final JPanel spacer19 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer19, gbc);
    cleanAllPullResumePointsButton = new JButton();
    cleanAllPullResumePointsButton.setEnabled(false);
    cleanAllPullResumePointsButton.setText("Clear pull history");
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(cleanAllPullResumePointsButton, gbc);
    final JLabel label3 = new JLabel();
    label3.setText("Use if you wish to pull every submission, regardless of last submission pulled.");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    panel1.add(label3, gbc);
    final JPanel spacer20 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer20, gbc);
    final JPanel spacer21 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 16;
    gbc.gridwidth = 6;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer21, gbc);
    resumeLastPullField = new JCheckBox();
    resumeLastPullField.setText("Start pull from last submission pulled");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(resumeLastPullField, gbc);
    final JPanel spacer22 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer22, gbc);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.JPanCodeMatchMain.java

/**
 * This method initializes this/*from   w  ww.j  a  v  a  2  s .  co  m*/
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
    gridBagConstraints15.gridx = 1;
    gridBagConstraints15.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints15.gridy = 0;
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.gridx = 1;
    jLabelLicense = new JLabel();
    jLabelLicense.setText("License :");
    jLabelLicense.setFont(new Font("Dialog", Font.PLAIN, 12));
    jLabelComponent = new JLabel();
    jLabelComponent.setText("Component :");
    jLabelComponent.setFont(new Font("Dialog", Font.PLAIN, 12));
    this.setSize(570, 480);
    this.setLayout(new GridBagLayout());
    this.setBorder(BorderFactory.createTitledBorder(null, "Identification Information",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
    this.add(getJSplitPane(), gridBagConstraints);
    this.add(getJScrollLabel(), gridBagConstraints15);

    getJPanMatchedSourceViewLeft().addScrollAdjustmentObserver(getJPanMatchedSourceViewRight());
    getJPanMatchedSourceViewRight().addScrollAdjustmentObserver(getJPanMatchedSourceViewLeft());

}

From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java

/**
 * Populate the display area with a multiple rows of graphs representing
 * the loads on each ComputeBean object within the HashSet.
 * @param resource/* w w w.  j a va  2  s  .co m*/
 * @param chartType
 */
private JPanel createChartPanel() {

    JPanel chartPanel = new JPanel();

    if (CURRENT_CHARTTYPE.equals(ChartType.METER) || CURRENT_CHARTTYPE.equals(ChartType.PIE)) {

        chartPanel.setLayout(new GridLayout(resources.size(), 1));

        LoadType[] loadTypes;

        if (CURRENT_LOADTYPE.equals(LoadType.SUMMARY)) {
            loadTypes = LoadType.values();
        } else {
            loadTypes = new LoadType[1];
            loadTypes[0] = CURRENT_LOADTYPE;
        }

        for (ComputeBean resource : resources) {
            // create a row to insert in the chartPanel
            JPanel multiChartPanelRow = new JPanel();
            multiChartPanelRow.setLayout(new GridBagLayout());
            GridBagConstraints c = new GridBagConstraints();

            // first part is name of the row
            c.weightx = 0;
            c.weighty = 0;
            c.gridx = 0;
            c.gridy = 0;
            c.fill = GridBagConstraints.NONE;
            multiChartPanelRow.add(new JLabel(resource.getName()));

            // chart row will take up the remainder of this panel.
            c.weightx = 1.0;
            c.weighty = 1.0;
            c.gridx = 0;
            c.gridy = 1;
            c.fill = GridBagConstraints.BOTH;

            JPanel chartRow = new JPanel();
            chartRow.setLayout(new GridLayout(1, (LoadType.values().length - 1)));

            for (int i = 0; i < ((loadTypes.length == 1) ? 1 : loadTypes.length - 1); i++) {
                JFreeChart chart = createChart(resource, CURRENT_CHARTTYPE, loadTypes[i]);

                ChartPanel cp = new ChartPanel(chart);

                cp.setPreferredSize(new Dimension(40, 45));

                cp.addMouseListener(new MouseListener() {
                    public void mouseClicked(MouseEvent event) {
                        // if they double click on the graph, then zoom in on it and
                        // make it the single display in the screen.
                        if (event.getClickCount() == 2) {
                            if (zoomOnSingleChart) {
                                zoomOnSingleChart = false;
                                setChartDisplayType(CURRENT_CHARTTYPE);
                            } else {
                                zoomOnSingleChart = true;
                                removeAll();
                                GridBagConstraints c = new GridBagConstraints();
                                c.weightx = 1.0;
                                c.weighty = 1.0;
                                c.gridx = 0;
                                c.gridy = 0;
                                c.fill = GridBagConstraints.BOTH;
                                add((ChartPanel) event.getSource(), c);
                                c.weightx = 0;
                                c.weighty = 0;
                                c.gridx = 0;
                                c.gridy = 1;
                                add(createSelectionBar(), c);
                                revalidate();
                            }
                        }

                    }

                    public void mousePressed(MouseEvent arg0) {
                    }

                    public void mouseReleased(MouseEvent arg0) {
                    }

                    public void mouseEntered(MouseEvent arg0) {
                    }

                    public void mouseExited(MouseEvent arg0) {
                    }
                });

                chartRow.add(cp);
            }
            multiChartPanelRow.add(chartRow, c);
            chartPanel.add(multiChartPanelRow);

        }
    } else {
        chartPanel.setLayout(new GridLayout(1, 1));
        JFreeChart chart = createChart(resources, CURRENT_CHARTTYPE, CURRENT_LOADTYPE);
        ChartPanel cp = new ChartPanel(chart);
        cp.setPreferredSize(new Dimension(40, 45));
        chartPanel.add(cp);
    }

    return chartPanel;

}

From source file:de.codesourcery.gittimelapse.MyFrame.java

public MyFrame(File file, GitHelper gitHelper) throws RevisionSyntaxException, MissingObjectException,
        IncorrectObjectTypeException, AmbiguousObjectException, IOException, GitAPIException {
    super("GIT timelapse: " + file.getAbsolutePath());
    if (gitHelper == null) {
        throw new IllegalArgumentException("gitHelper must not be NULL");
    }/*from ww  w . ja  va 2 s  .  c o  m*/

    this.gitHelper = gitHelper;
    this.file = file;
    this.diffPanel = new DiffPanel();

    final JDialog dialog = new JDialog((Frame) null, "Please wait...", false);
    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.getContentPane().add(new JLabel("Please wait, locating revisions..."), BorderLayout.CENTER);
    dialog.pack();
    dialog.setVisible(true);

    final IProgressCallback callback = new IProgressCallback() {

        @Override
        public void foundCommit(ObjectId commitId) {
            System.out.println("*** Found commit " + commitId);
        }
    };

    System.out.println("Locating commits...");
    commitList = gitHelper.findCommits(file, callback);

    dialog.setVisible(false);

    if (commitList.isEmpty()) {
        throw new RuntimeException("Found no commits");
    }
    setMenuBar(createMenuBar());

    diffModeChooser.setModel(new DefaultComboBoxModel<MyFrame.DiffDisplayMode>(DiffDisplayMode.values()));
    diffModeChooser.setSelectedItem(DiffDisplayMode.ALIGN_CHANGES);
    diffModeChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1);
            try {
                diffPanel.showRevision(commit);
            } catch (IOException | PatchApplyException e1) {
                e1.printStackTrace();
            }
        }
    });

    diffModeChooser.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            Component result = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            DiffDisplayMode mode = (DiffDisplayMode) value;
            switch (mode) {
            case ALIGN_CHANGES:
                setText("Align changes");
                break;
            case REGULAR:
                setText("Regular");
                break;
            default:
                setText(mode.toString());
            }
            return result;
        }
    });

    revisionSlider = new JSlider(1, commitList.size());

    revisionSlider.setPaintLabels(true);
    revisionSlider.setPaintTicks(true);

    addKeyListener(keyListener);
    getContentPane().addKeyListener(keyListener);

    if (commitList.size() < 10) {
        revisionSlider.setMajorTickSpacing(1);
        revisionSlider.setMinorTickSpacing(1);
    } else {
        revisionSlider.setMajorTickSpacing(5);
        revisionSlider.setMinorTickSpacing(1);
    }

    final ObjectId latestCommit = commitList.getLatestCommit();
    if (latestCommit != null) {
        revisionSlider.setValue(1 + commitList.indexOf(latestCommit));
        revisionSlider.setToolTipText(latestCommit.getName());
    }

    revisionSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (!revisionSlider.getValueIsAdjusting()) {
                final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1);
                long time = -System.currentTimeMillis();
                try {
                    diffPanel.showRevision(commit);
                } catch (IOException | PatchApplyException e1) {
                    e1.printStackTrace();
                } finally {
                    time += System.currentTimeMillis();
                }
                if (Main.DEBUG_MODE) {
                    System.out.println("Rendering time: " + time);
                }
            }
        }
    });

    getContentPane().setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = new GridBagConstraints();
    cnstrs.gridx = 0;
    cnstrs.gridy = 0;
    cnstrs.gridwidth = 1;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 0;
    cnstrs.weighty = 0;
    cnstrs.fill = GridBagConstraints.NONE;

    getContentPane().add(new JLabel("Diff display mode:"), cnstrs);

    cnstrs = new GridBagConstraints();
    cnstrs.gridx = 1;
    cnstrs.gridy = 0;
    cnstrs.gridwidth = 1;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 0;
    cnstrs.weighty = 0;
    cnstrs.fill = GridBagConstraints.NONE;

    getContentPane().add(diffModeChooser, cnstrs);

    cnstrs = new GridBagConstraints();
    cnstrs.gridx = 2;
    cnstrs.gridy = 0;
    cnstrs.gridwidth = 1;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 1.0;
    cnstrs.weighty = 0;
    cnstrs.fill = GridBagConstraints.HORIZONTAL;

    getContentPane().add(revisionSlider, cnstrs);

    cnstrs = new GridBagConstraints();
    cnstrs.gridx = 0;
    cnstrs.gridy = 1;
    cnstrs.gridwidth = 3;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 1;
    cnstrs.weighty = 1;
    cnstrs.fill = GridBagConstraints.BOTH;

    getContentPane().add(diffPanel, cnstrs);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    if (latestCommit != null) {
        diffPanel.showRevision(latestCommit);
    }
}

From source file:org.jfree.chart.demo.CompassDemo.java

/**
 * Initialises the user interface.//w  w w.j  a  va  2  s .  com
 *
 * @throws Exception if there are any exceptions.
 */
void jbInit() throws Exception {
    this.titledBorder1 = new TitledBorder("");
    this.titledBorder2 = new TitledBorder("");
    this.titledBorder3 = new TitledBorder("");
    setLayout(this.gridLayout1);
    this.panelCompassHolder.setLayout(this.borderLayout);
    this.windNullCheckBox.setHorizontalTextPosition(SwingConstants.LEADING);
    this.windNullCheckBox.setText("Null");
    this.windNullCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            checkWindNullActionPerformed(e);
        }
    });
    this.shipNullCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
    this.shipNullCheckBox.setText("Null");
    this.shipNullCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            checkShipNullActionPerformed(e);
        }
    });

    this.spinShip.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (DEBUG) {
                System.out.println("compassDemo:spinShipPropertyChange");
            }
            final Spinner spinner = (Spinner) evt.getSource();
            if (spinner.isEnabled()) {
                shipData.setValue(new Double(spinner.getValue()));
            }
        }
    });

    this.spinWind.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (DEBUG) {
                System.out.println("compassDemo:spinWindPropertyChange");
            }
            final Spinner spinner = (Spinner) evt.getSource();
            if (spinner.isEnabled()) {
                compassData.setValue(new Double(spinner.getValue()));
            }
        }
    });
    this.jPanel12.setLayout(this.gridLayout2);
    this.jPanel2.setBorder(this.titledBorder1);
    this.jPanel2.setLayout(this.gridBagLayout2);
    this.jPanel1.setBorder(this.titledBorder2);
    this.jPanel1.setLayout(this.gridBagLayout1);
    this.titledBorder1.setTitle("Second Pointer");
    this.titledBorder2.setTitle("First Pointer");
    this.titledBorder3.setTitle("Plot Options");
    this.pick2Pointer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            pick2PointerActionPerformed(e);
        }
    });
    this.pick1Pointer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            pick1PointerActionPerformed(e);
        }
    });
    add(this.panelCompassHolder, null);
    this.panelCompassHolder.add(this.jPanel12, BorderLayout.SOUTH);
    this.jPanel12.add(this.jPanel1, null);

    this.jPanel1.add(this.pick1Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel1.add(this.windNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel1.add(this.spinWind, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel12.add(this.jPanel2, null);

    this.jPanel2.add(this.pick2Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel2.add(this.shipNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel2.add(this.spinShip, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    this.panelCompassHolder.add(this.panelCompass, BorderLayout.CENTER);

}

From source file:at.ac.tuwien.ibk.biqini.pep.gui.PEPGUI.java

/**
 * sets up all charts for later usage/* w  w  w  .  java 2s  .c  om*/
 */
public void insertAllCharts() {
    for (int i = 0; i < MAXCHARTS; i++) {
        tsc[i] = new TimeSeriesCollection(new TimeSeries("unused", Millisecond.class));
        charts[i] = ChartFactory.createTimeSeriesChart("unused", null, "bitrate kbit/sec", tsc[i], false, true,
                false);

        XYPlot plot = charts[i].getXYPlot();
        ValueAxis axis = plot.getDomainAxis();
        axis.setAutoRange(true);
        axis.setFixedAutoRange(DISPLAYEDTIME);
        axis = plot.getRangeAxis();
        axis.setRange(0.0, 128);
        ChartPanel chartPanel = new ChartPanel(charts[i]);

        // do the layout stuff
        GridBagConstraints c = new GridBagConstraints();
        c.weighty = 3;
        c.weightx = 10.0;
        c.fill = GridBagConstraints.BOTH;
        c.insets = new Insets(0, 0, 0, 0);
        c.gridx = 1;
        c.gridy = i;
        c.gridwidth = 1;
        c.gridheight = 1;
        gridBagLayout.setConstraints(chartPanel, c);

        // paste it
        content.add(chartPanel);
        chartPanel.setPreferredSize(new java.awt.Dimension(1000, 270));
    }
}