Example usage for java.awt GridBagConstraints GridBagConstraints

List of usage examples for java.awt GridBagConstraints GridBagConstraints

Introduction

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

Prototype

public GridBagConstraints() 

Source Link

Document

Creates a GridBagConstraint object with all of its fields set to their default value.

Usage

From source file:com.digitalgeneralists.assurance.ui.components.ResultsPanel.java

private void initializeComponent() {
    if (!this.initialized) {
        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        ((DefaultTableCellRenderer) resultsTable.getTableHeader().getDefaultRenderer())
                .setHorizontalAlignment(JLabel.CENTER);
        this.resultsTable.setRowHeight(150);

        ListSelectionModel selectionModel = this.resultsTable.getSelectionModel();

        selectionModel.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                applicationDelegate.fireEvent(new SetScanResultsMenuStateEvent(false));
                resultsTable.editCellAt(resultsTable.getSelectedRow(), 0);
            }/*from w ww  . j  ava  2s.  com*/
        });

        GridBagConstraints resultsLabelConstraints = new GridBagConstraints();
        resultsLabelConstraints.anchor = GridBagConstraints.WEST;
        resultsLabelConstraints.fill = GridBagConstraints.BOTH;
        resultsLabelConstraints.gridx = 0;
        resultsLabelConstraints.gridy = 0;
        resultsLabelConstraints.weightx = 1.0;
        resultsLabelConstraints.weighty = 0.1;
        resultsLabelConstraints.gridheight = 1;
        resultsLabelConstraints.gridwidth = 1;
        resultsLabelConstraints.insets = new Insets(5, 5, 5, 5);

        this.progressIndicatorConstraints.anchor = GridBagConstraints.WEST;
        this.progressIndicatorConstraints.fill = GridBagConstraints.BOTH;
        this.progressIndicatorConstraints.gridx = 0;
        this.progressIndicatorConstraints.gridy = 1;
        this.progressIndicatorConstraints.weightx = 1.0;
        this.progressIndicatorConstraints.weighty = 0.1;
        this.progressIndicatorConstraints.gridheight = 1;
        this.progressIndicatorConstraints.gridwidth = 1;
        this.progressIndicatorConstraints.insets = new Insets(5, 5, 5, 5);

        this.progressIndicator.setIndeterminate(true);

        this.resultsListConstraints.anchor = GridBagConstraints.WEST;
        this.resultsListConstraints.fill = GridBagConstraints.BOTH;
        this.resultsListConstraints.gridx = 0;
        this.resultsListConstraints.gridy = 2;
        this.resultsListConstraints.weightx = 1.0;
        this.resultsListConstraints.weighty = 0.9;
        this.resultsListConstraints.gridheight = 1;
        this.resultsListConstraints.gridwidth = 1;
        this.resultsListConstraints.insets = new Insets(5, 5, 5, 5);

        this.add(this.resultsLabel, resultsLabelConstraints);
        this.add(this.resultsScrollPane, this.resultsListConstraints);

        this.addAncestorListener(new AncestorListener() {
            public void ancestorAdded(AncestorEvent event) {
                resultsTable.setDefaultRenderer(ComparisonResult.class, comparisonResultListRenderer);
                resultsTable.setDefaultEditor(ComparisonResult.class, comparisonResultListRenderer);

                applicationDelegate.addEventObserver(ScanStartedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ComparisonResultAddedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanResultsLoadedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(SelectedScanChangedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanProgressEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ResultMergeCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanMergeStartedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanMergeProgressEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanMergeCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(DeletedItemRestoreCompletedEvent.class,
                        (IEventObserver) event.getSource());
            }

            public void ancestorRemoved(AncestorEvent event) {
                applicationDelegate.removeEventObserver(ScanStartedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ComparisonResultAddedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanResultsLoadedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(SelectedScanChangedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanProgressEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ResultMergeCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanMergeStartedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanMergeProgressEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanMergeCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(DeletedItemRestoreCompletedEvent.class,
                        (IEventObserver) event.getSource());
            }

            public void ancestorMoved(AncestorEvent event) {
            }
        });

        this.initialized = true;
    }
}

From source file:net.vanosten.dings.swing.SummaryView.java

private void initializeChartPropertiesPanel() {
    chartPropertiesP = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    chartPropertiesP.setLayout(gbl);/*from www . j a v  a 2s  .co  m*/

    TitledBorder title;
    title = BorderFactory.createTitledBorder("Chart Properties");
    chartPropertiesP.setBorder(title);

    JLabel typeL = new JLabel("Chart Type:");
    typeL.setDisplayedMnemonic("C".charAt(0));
    typeL.setLabelFor(chartTypeCB);
    JLabel emptyL = new JLabel();

    Insets vghg = new Insets(DingsSwingConstants.SP_V_G, DingsSwingConstants.SP_H_G, 0, 0);
    //----type
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.LINE_END;
    gbc.insets = vghg;
    gbl.setConstraints(typeL, gbc);
    chartPropertiesP.add(typeL);
    //----
    gbc.gridx = 1;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbl.setConstraints(chartTypeCB, gbc);
    chartPropertiesP.add(chartTypeCB);
    //----
    gbc.gridx = 2;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbl.setConstraints(emptyL, gbc);
    chartPropertiesP.add(emptyL);
    //----chosen
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    gbl.setConstraints(chosenCB, gbc);
    chartPropertiesP.add(chosenCB);
}

From source file:logdruid.ui.RecordingList.java

/**
 * Create the panel./*from   w w w .  j  a  v  a  2  s.co m*/
 */
public RecordingList(final Repository rep) {

    if (Preferences.getPreference("timings").equals("true")) {
        header = (String[]) new String[] { "name", "regexp", "type", "active", "success time", "failed time",
                "match attempt", "success match" };
    } else {
        header = (String[]) new String[] { "name", "regexp", "type", "active" };
    }

    records = rep.getRecordings();
    // Collections.sort(records);
    Iterator it = records.iterator();
    while (it.hasNext()) {
        Recording record = (Recording) it.next();
        stats = DataVault.getRecordingStats(record.getName());
        if (stats != null) {
            data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(),
                    record.getIsActive(), stats[0], stats[1], stats[2], stats[3] });
        } else {
            data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(),
                    record.getIsActive(), 0, 0, 0, 0 });
        }
    }

    repository = rep;
    model = new MyTableModel2(data, header);

    JPanel panel_1 = new JPanel();
    GridBagConstraints gbc_panel_1 = new GridBagConstraints();
    gbc_panel_1.fill = GridBagConstraints.BOTH;
    gbc_panel_1.insets = new Insets(5, 0, 5, 5);
    gbc_panel_1.gridx = 1;
    gbc_panel_1.gridy = 0;
    panel_1.setLayout(new BorderLayout(0, 0));

    table = new JTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    int column;
    panel_1.add(scrollPane);

    table.setPreferredScrollableViewportSize(new Dimension(0, 150));
    table.setFillsViewportHeight(true);

    // Set up column sizes.
    initColumnSizes(table);
    table.setAutoCreateRowSorter(true);
    //   RowSorter sorter = table.getRowSorter();
    //      sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
    if (model.getRowCount() > 0) {
        table.getRowSorter().toggleSortOrder(0);
        table.getRowSorter().toggleSortOrder(2);
    }
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            int selectedRow = ((table.getSelectedRow() != -1)
                    ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1);
            ;
            logger.info("ListSelectionListener - selectedRow: " + selectedRow);
            if (selectedRow >= 0) {
                if (jPanelDetail != null) {
                    logger.info("ListSelectionListener - valueChanged");
                    jPanelDetail.removeAll();
                    recEditor = getEditor(repository.getRecording(selectedRow));
                    if (recEditor != null) {
                        jPanelDetail.add(recEditor, BorderLayout.CENTER);
                    }
                    jPanelDetail.revalidate();
                }
            }
        }
    });
    JPanel panel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) panel.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);
    flowLayout.setVgap(2);
    flowLayout.setHgap(2);
    panel_1.add(panel, BorderLayout.SOUTH);

    JButton btnNewMeta = new JButton("New Meta");
    panel.add(btnNewMeta);
    btnNewMeta.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            int rowCount = table.getRowCount();
            jPanelDetail.removeAll();
            Recording re = new MetadataRecording("name", "regex", "example line", "", true, null);
            recEditor = new MetadataRecordingEditor(thiis, repository, "the line", "regex",
                    (MetadataRecording) re);
            jPanelDetail.add(recEditor, BorderLayout.CENTER);
            repository.addRecording(re);
            model.addRow(
                    new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 });
            model.fireTableRowsInserted(rowCount, rowCount);
            table.setRowSelectionInterval(rowCount, rowCount);
            logger.info("New record - row count : " + rowCount);
        }
    });

    JButton btnDuplicate = new JButton("Duplicate");
    btnDuplicate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int rowCount = table.getRowCount();
            int selectRow = ((table.getSelectedRow() != -1) ? table.getSelectedRow() : -1);
            int selectedRow = ((table.getSelectedRow() != -1)
                    ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1);
            repository.addRecording(
                    repository.getRecording(table.convertRowIndexToModel(table.getSelectedRow())).duplicate());
            model.fireTableRowsInserted(rowCount, rowCount);
            table.setRowSelectionInterval(selectRow, selectRow);
        }
    });

    JButton btnNewStat = new JButton("New Stat");
    btnNewStat.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int rowCount = table.getRowCount();
            jPanelDetail.removeAll();
            Recording re = new StatRecording("name", "regex", "example line", "", true, null);
            recEditor = new StatRecordingEditor(thiis, repository, "the line", "regex", (StatRecording) re);
            jPanelDetail.add(recEditor, BorderLayout.CENTER);
            repository.addRecording(re);
            model.addRow(
                    new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 });
            model.fireTableRowsInserted(rowCount, rowCount);
            table.setRowSelectionInterval(rowCount, rowCount);
            logger.info("New record - row count : " + rowCount);
        }
    });
    panel.add(btnNewStat);

    JButton btnNewEvent = new JButton("New Event");
    btnNewEvent.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int rowCount = table.getRowCount();
            logger.info("table.getRowCount()" + table.getRowCount());
            jPanelDetail.removeAll();
            Recording re = new EventRecording("name", "regex", "example line", "", true, null);
            recEditor = new EventRecordingEditor(thiis, repository, "the line", "regex", (EventRecording) re);
            jPanelDetail.add(recEditor, BorderLayout.CENTER);
            repository.addRecording(re);
            model.addRow(
                    new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 });
            model.fireTableRowsInserted(rowCount, rowCount);
            table.setRowSelectionInterval(rowCount, rowCount);
            logger.info("New record - row count : " + rowCount);
        }
    });
    panel.add(btnNewEvent);
    panel.add(btnDuplicate);

    JButton btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int rowCount = table.getRowCount();
            int selectedRow = ((table.getSelectedRow() != -1)
                    ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1);
            ;
            int realSelectedRow = table.getSelectedRow();
            logger.info("selectedRow : " + selectedRow + ", row count: " + table.getRowCount());
            if (rowCount != 0) {
                repository.deleteRecording(selectedRow);
                model.fireTableRowsDeleted(selectedRow, selectedRow);
                //         table.remove(selectedRow);
                if (realSelectedRow != -1) {
                    if (realSelectedRow != 0)
                        table.setRowSelectionInterval(realSelectedRow - 1, realSelectedRow - 1);
                    else if (realSelectedRow > 0)
                        table.setRowSelectionInterval(realSelectedRow, realSelectedRow);
                    else if (rowCount > 1)
                        table.setRowSelectionInterval(0, 0);
                }
                /*            if (table.getRowCount() > 0) {
                               if (selectedRow == table.getRowCount()) {
                                  table.setRowSelectionInterval(selectedRow - 1, selectedRow - 1);
                               } else
                                  table.setRowSelectionInterval(selectedRow, selectedRow);
                            }*/
            }
        }
    });
    panel.add(btnDelete);
    setLayout(new BorderLayout(0, 0));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    jPanelDetail = new JPanel();
    GridBagConstraints gbc_jPanelDetail = new GridBagConstraints();
    gbc_jPanelDetail.insets = new Insets(0, 0, 0, 5);
    gbc_jPanelDetail.fill = GridBagConstraints.BOTH;
    gbc_jPanelDetail.gridx = 1;
    gbc_jPanelDetail.gridy = 4;
    splitPane.setBottomComponent(jPanelDetail);
    splitPane.setTopComponent(panel_1);
    jPanelDetail.setLayout(new BorderLayout(0, 0));
    if (repository.getRecordingCount() > 0) {
        //recEditor = getEditor(repository.getRecording(0));
        //jPanelDetail.add(recEditor, BorderLayout.CENTER);
        table.setRowSelectionInterval(0, 0);
    }
    jPanelDetail.revalidate();

}

From source file:com.oracle.tutorial.jdbc.CoffeesFrame.java

public CoffeesFrame(JDBCTutorialUtilities settingsArg) throws SQLException {

    super("The Coffee Break: COFFEES Table"); // Set window title

    this.settings = settingsArg;
    connection = settings.getConnection();

    // Close connections exit the application when the user
    // closes the window

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {

            try {
                connection.close();//  w ww.j  av a  2 s  . c om
            } catch (SQLException sqle) {
                JDBCTutorialUtilities.printSQLException(sqle);
            }
            System.exit(0);
        }
    });

    // Initialize and lay out window controls

    CachedRowSet myCachedRowSet = getContentsOfCoffeesTable();
    myCoffeesTableModel = new CoffeesTableModel(myCachedRowSet);
    myCoffeesTableModel.addEventHandlersToRowSet(this);

    table = new JTable(); // Displays the table
    table.setModel(myCoffeesTableModel);

    label_COF_NAME = new JLabel();
    label_SUP_ID = new JLabel();
    label_PRICE = new JLabel();
    label_SALES = new JLabel();
    label_TOTAL = new JLabel();

    textField_COF_NAME = new JTextField(10);
    textField_SUP_ID = new JTextField(10);
    textField_PRICE = new JTextField(10);
    textField_SALES = new JTextField(10);
    textField_TOTAL = new JTextField(10);

    button_ADD_ROW = new JButton();
    button_UPDATE_DATABASE = new JButton();
    button_DISCARD_CHANGES = new JButton();

    label_COF_NAME.setText("Coffee Name:");
    label_SUP_ID.setText("Supplier ID:");
    label_PRICE.setText("Price:");
    label_SALES.setText("Sales:");
    label_TOTAL.setText("Total Sales:");

    textField_COF_NAME.setText("Enter new coffee name");
    textField_SUP_ID.setText("101");
    textField_PRICE.setText("0");
    textField_SALES.setText("0");
    textField_TOTAL.setText("0");

    button_ADD_ROW.setText("Add row to table");
    button_UPDATE_DATABASE.setText("Update database");
    button_DISCARD_CHANGES.setText("Discard changes");

    // Place the components within the container contentPane; use GridBagLayout
    // as the layout.

    Container contentPane = getContentPane();
    contentPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    contentPane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.5;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    contentPane.add(new JScrollPane(table), c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    contentPane.add(label_COF_NAME, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    contentPane.add(textField_COF_NAME, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.25;
    c.weighty = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    contentPane.add(label_SUP_ID, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    contentPane.add(textField_SUP_ID, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    contentPane.add(label_PRICE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = 1;
    contentPane.add(textField_PRICE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    contentPane.add(label_SALES, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 4;
    c.gridwidth = 1;
    contentPane.add(textField_SALES, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    contentPane.add(label_TOTAL, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = 1;
    contentPane.add(textField_TOTAL, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    contentPane.add(button_ADD_ROW, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = 1;
    contentPane.add(button_UPDATE_DATABASE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = 1;
    contentPane.add(button_DISCARD_CHANGES, c);

    // Add listeners for the buttons in the application

    button_ADD_ROW.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            JOptionPane.showMessageDialog(CoffeesFrame.this, new String[] { "Adding the following row:",
                    "Coffee name: [" + textField_COF_NAME.getText() + "]",
                    "Supplier ID: [" + textField_SUP_ID.getText() + "]",
                    "Price: [" + textField_PRICE.getText() + "]", "Sales: [" + textField_SALES.getText() + "]",
                    "Total: [" + textField_TOTAL.getText() + "]" });

            try {

                myCoffeesTableModel.insertRow(textField_COF_NAME.getText(),
                        Integer.parseInt(textField_SUP_ID.getText().trim()),
                        Float.parseFloat(textField_PRICE.getText().trim()),
                        Integer.parseInt(textField_SALES.getText().trim()),
                        Integer.parseInt(textField_TOTAL.getText().trim()));
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
            }
        }
    });

    button_UPDATE_DATABASE.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                myCoffeesTableModel.coffeesRowSet.acceptChanges();
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
                // Now revert back changes
                try {
                    createNewTableModel();
                } catch (SQLException sqle2) {
                    displaySQLExceptionDialog(sqle2);
                }
            }
        }
    });

    button_DISCARD_CHANGES.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                createNewTableModel();
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
            }
        }
    });
}

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 a va 2 s.c  o  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;

}

From source file:com.frostwire.gui.bittorrent.PartialFilesDialog.java

private void setupCancelButton() {
    GridBagConstraints c;//  ww w  .  j a v  a  2 s. c o  m
    _buttonCancel = new JButton(I18n.tr("Cancel"));
    _buttonCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            buttonCancel_actionPerformed(e);
        }
    });
    c = new GridBagConstraints();
    c.insets = new Insets(4, 0, 8, 6);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.EAST;
    c.ipadx = 18;
    c.gridy = 4;
    panel.add(_buttonCancel, c);
}

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

private void initialize() {
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;//w  w  w.j a va  2 s. com
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 5;
    gridBagConstraints.weightx = 0.7;
    gridBagConstraints.insets = new Insets(10, 300, 0, 0); //(int top, int left, int bottom, int right)
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
    gridBagConstraints7.gridx = 5;
    gridBagConstraints7.gridy = 0;
    gridBagConstraints7.weightx = 0.3;
    gridBagConstraints7.insets = new Insets(10, 0, 0, 90);
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
    gridBagConstraints3.gridx = 0;
    gridBagConstraints3.gridy = 1;
    gridBagConstraints3.weightx = 1.0;
    gridBagConstraints3.gridwidth = 6;
    GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
    gridBagConstraints5.fill = GridBagConstraints.BOTH;
    gridBagConstraints5.gridx = 0;
    gridBagConstraints5.gridy = 2;
    gridBagConstraints5.weightx = 1.0;
    gridBagConstraints5.weighty = 1.0;
    gridBagConstraints5.gridwidth = 6;
    this.setSize(920, 700);
    this.setLayout(new GridBagLayout());
    this.add(getJPanelProjectCombo(), gridBagConstraints);
    this.add(getJPanelAutoIdentify(), gridBagConstraints7);
    this.add(JPanPendingTypeSelection(), gridBagConstraints3);
    this.add(getJSplitPaneMain(), gridBagConstraints5);
}

From source file:com.limegroup.gnutella.gui.LicenseWindow.java

protected void createNotValid() {
    GridBagConstraints c = new GridBagConstraints();
    URI licenseURI = LICENSE.getLicenseURI();
    JComponent comp;//from  w w w. ja  va2 s  .  c o  m

    comp = new JLabel(getWarningIcon());
    c.anchor = GridBagConstraints.NORTH;
    c.insets = new Insets(0, 0, 0, 5);
    DETAILS.add(comp, c);

    String invalidText = getInvalidString();
    if (licenseURI != null && allowRetryLink())
        invalidText += "  " + getRetryString();
    comp = newTextArea(invalidText);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    c.insets = new Insets(7, 0, 0, 0);
    DETAILS.add(comp, c);

    c.gridwidth = 1;
    c.gridheight = 2;
    c.weightx = 0;
    c.weighty = 0;
    DETAILS.add(javax.swing.Box.createGlue(), c);

    JButton button = new JButton(getVerifyString());
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            LICENSE.verify(LicenseWindow.this);
            buildDetails();
        }
    });
    button.setVisible(licenseURI != null && allowVerifyLookup());
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.gridheight = 2;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 100);
    DETAILS.add(button, c);

    if (LICENSE.getLicenseDeed(URN) == null || !allowClaimedDeedLink()) {
        comp = new JLabel();
        comp.setVisible(false);
    } else {
        comp = new URLLabel(LICENSE.getLicenseDeed(URN), getClaimedDeedString());
    }
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(0, 0, 3, 0);
    DETAILS.add(comp, c);

    if (licenseURI == null || !allowVerificationLink()) {
        comp = new JLabel();
        comp.setVisible(false);
    } else {
        comp = new URLLabel(licenseURI, getVerificationString());
    }
    c.insets = new Insets(0, 0, 3, 0);
    DETAILS.add(comp, c);
}

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

protected void createControlPanel(JPanel dataPanel) {
    JPanel cntlPanel = new JPanel();
    GridBagConstraints gbl_ctrlPanel = new GridBagConstraints();
    gbl_ctrlPanel.insets = insets3;//from w  w w. jav  a2 s.com
    gbl_ctrlPanel.anchor = GridBagConstraints.NORTH;
    gbl_ctrlPanel.fill = GridBagConstraints.HORIZONTAL;
    gbl_ctrlPanel.gridx = 0;
    gbl_ctrlPanel.gridy = 0;
    gbl_ctrlPanel.weightx = 1.0;
    gbl_ctrlPanel.gridwidth = 2;
    dataPanel.add(cntlPanel, gbl_ctrlPanel);

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

    addButton(cntlPanel, 0, "Load Log", "loadlog", GridBagConstraints.WEST);
    addButton(cntlPanel, 1, "Clear SD Data", "clearorig", GridBagConstraints.WEST);
    addButton(cntlPanel, 2, "Clear Run Data", "clearlog", GridBagConstraints.WEST);
    addButton(cntlPanel, 3, "Clear All", "clearall", GridBagConstraints.WEST);
    addLabel(cntlPanel, 4, "SD");
    sdType = addComboBox(cntlPanel, 5, new String[] { "RR SD", "Cobb SD" });
    addLabel(cntlPanel, 6, "MP");
    mpType = addComboBox(cntlPanel, 7,
            new String[] { "Torr/mmHG Abs", "Torr/mmHG Rel Sea Lvl", "Psi Abs", "Psi Rel Sea Lvl" });
    addLabel(cntlPanel, 8, "Run");
    dataType = addComboBox(cntlPanel, 9, new String[] { "MAF Builder", "AFR Tuner" });
    addCheckBox(cntlPanel, 10, "Hide Log Table", "hidelogtable");
    compareTableCheckBox = addCheckBox(cntlPanel, 11, "Compare Tables", "comparetables");
    addButton(cntlPanel, 12, "GO", "go", GridBagConstraints.EAST);
}

From source file:org.fhcrc.cpl.viewer.quant.gui.PanelWithLogRatioHistAndFields.java

/**
 * Set the log ratios, build the histogram and display, removing the old one if there was one.  Nothing gets
 * cleaned up related to the old chart; it'll just hang around intil GC
 * todo: do I need to dispose of the old chart in a better way?
 * @param logRatios//from   ww w.  j  a v  a  2s . c o m
 */
public void setLogRatios(List<Float> logRatios) {
    _log.debug("setLogRatios 1");
    if (logRatioHistogram != null) {
        remove(logRatioHistogram);
    }
    this.logRatios = logRatios;

    float minLogRatioBound = (float) Math.log(minRatioBound);
    float maxLogRatioBound = (float) Math.log(maxRatioBound);

    _log.debug("setLogRatios 2");

    List<Float> boundedLogRatios = new ArrayList<Float>(logRatios.size());
    for (float logRatio : logRatios)
        boundedLogRatios.add(Math.min(maxLogRatioBound, Math.max(minLogRatioBound, logRatio)));

    logRatioHistogram = new PanelWithHistogram(boundedLogRatios, "Log Ratios", 200);
    Dimension histDimension = new Dimension(300, 80);
    if (!Float.isNaN(domainCrosshairValue)) {
        logRatioHistogram.getChart().getXYPlot().setDomainCrosshairValue(domainCrosshairValue, true);
        logRatioHistogram.getChart().getXYPlot().setDomainCrosshairVisible(true);
    }

    _log.debug("setLogRatios 1");

    logRatioHistogram.setPreferredSize(histDimension);
    logRatioHistogram.getChart().removeLegend();
    logRatioHistogram.getChart().getXYPlot().getDomainAxis().setLowerBound(minLogRatioBound);
    logRatioHistogram.getChart().getXYPlot().getDomainAxis().setUpperBound(maxLogRatioBound);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.weighty = 10;
    gbc.weightx = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(logRatioHistogram, gbc);

    histMouseListener = new LogRatioHistMouseListener(logRatioHistogram);
    ChartPanel histChartPanel = logRatioHistogram.getChartPanel();
    histChartPanel.setMouseZoomable(false);
    logRatioHistogram.getChartPanel().addMouseListener(histMouseListener);
    logRatioHistogram.getChartPanel().addMouseMotionListener(histMouseListener);
    histMouseListener.addRangeUpdateListener(new LogRatioHistogramListener(this));

    logRatioHistogram.updateUI();
    //if there are specified minHigh and maxHigh values, and they're valid, draw the initially selected region
    if (minHighRatio > maxLowRatio && minHighRatio > 0 && maxLowRatio > 0)
        updateSelectedRegion();

    //remove axes from chart
    ((XYPlot) logRatioHistogram.getPlot()).getRangeAxis().setVisible(false);
    ((XYPlot) logRatioHistogram.getPlot()).getDomainAxis().setVisible(false);

    logRatioHistogram.updateUI();
}