Example usage for java.awt GridBagConstraints NORTHWEST

List of usage examples for java.awt GridBagConstraints NORTHWEST

Introduction

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

Prototype

int NORTHWEST

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

Click Source Link

Document

Put the component at the top-left corner of its display area.

Usage

From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java

public SimilarityRetrievalGUI() {
    super("Similarity Retrieval GUI");
    setLayout(new GridBagLayout());
    GridBagConstraintsIFS gcMain = new GridBagConstraintsIFS(GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // the panel with the feature files, allows to load new ones
    JPanel panelFeatureFiles = UiUtils.makeBorderedPanel(new VerticalLayout(), "Feature files");
    getContentPane().add(panelFeatureFiles, gcMain);

    panelLoadedFeatureFiles.add(labelNoInputData);

    panelFeatureFiles.add(panelLoadedFeatureFiles);

    JButton btnLoad = initButtonLoad();
    panelFeatureFiles.add(btnLoad);/*from   w ww  .  ja  va  2s.c  o  m*/

    txtFieldMusicPath.setToolTipText("Path to the music");

    // TODO: remove
    txtFieldMusicPath.setText("/data/music/ISMIRgenre/mp3_44khz_128kbit_stereo_30sec");

    JButton btnBrowseMusicPath = UiUtils.createBrowseButton(txtFieldMusicPath, this, true);

    JPanel panelMusicPath = new JPanel();
    panelMusicPath.add(new JLabel("Music path"));
    panelMusicPath.add(txtFieldMusicPath);
    panelMusicPath.add(btnBrowseMusicPath);

    panelFeatureFiles.add(panelMusicPath);

    initButtonStart();

    initButtonSaveResults();

    JRadioButton rbDistanceAbsolute = UiUtils.makeRadioButton("absolute", bgDistanceDisplay, true);
    bgDistanceDisplay.add(rbDistanceAbsolute);
    JRadioButton rbDistanceRelative = UiUtils.makeRadioButton("relative", bgDistanceDisplay);
    bgDistanceDisplay.add(rbDistanceRelative);

    initPanelRetrieval();

    ((JSpinner.DefaultEditor) spinnerNumberNeighbours.getEditor()).getTextField().setColumns(6);

    panelRetrieval.setBorder(new TitledBorder("Options"));
    GridBagConstraintsIFS gc = new GridBagConstraintsIFS().setInsets(5, 2);
    panelRetrieval.add(new JLabel("# to retrieve"), gc);
    panelRetrieval.add(spinnerNumberNeighbours, gc.nextCol());
    panelRetrieval.add(new JLabel("Query vector"), gc.nextRow());
    panelRetrieval.add(comboQueryVector, gc.nextCol());

    panelRetrieval.add(new JLabel("Distances"), gc.nextRow());
    panelRetrieval.add(UiUtils.makeAndFillPanel(rbDistanceAbsolute, rbDistanceRelative), gc.nextCol());

    boxMetric.setSelectedItem(L2Metric.class.getSimpleName());
    panelRetrieval.add(new JLabel("Distance metric"), gc.nextRow());
    panelRetrieval.add(boxMetric, gc.nextCol());

    gc.nextRow().setGridWidth(2).setAnchor(GridBagConstraints.CENTER);
    panelRetrieval.add(UiUtils.makeAndFillPanel(btnStart, btnSaveResults), gc);
    panelRetrieval.setEnabled(false);

    getContentPane().add(panelRetrieval, gcMain.nextRow());

    resizeResultTableColumns();

    JScrollPane scrollPaneResults = new JScrollPane(resultsTable);
    scrollPaneResults.setBorder(new TitledBorder("Results"));
    getContentPane().add(scrollPaneResults, gcMain.nextRow());

    databaseDetailsTable = new JTable(new DefaultTableModel(new Object[][] {}, databaseDetailsColumnNames));
    databaseDetailsTable.setAutoCreateRowSorter(true);

    databaseDetailsTable.setDefaultEditor(JButton.class, new ButtonCellEditor());

    resizeDatabaseDetailsTableColumns();
    JScrollPane scrollPaneDatabaseDetails = new JScrollPane(databaseDetailsTable);

    // panel in the upper-right corner, holding the database table & buttons to load class assignment
    JPanel databaseDetailsPanel = UiUtils.makeBorderedPanel(new GridBagLayout(), "Database Details");
    GridBagConstraintsIFS gcDatabaseDetails = new GridBagConstraintsIFS(GridBagConstraints.CENTER,
            GridBagConstraints.BOTH);
    gcDatabaseDetails.setWeights(1, 1);
    databaseDetailsPanel.add(scrollPaneDatabaseDetails, gcDatabaseDetails);

    initButtonLoadClassInfo();
    databaseDetailsPanel.add(buttonLoadClassInfo, gc.nextRow());

    JPanel histogramPanel = UiUtils.makeBorderedPanel("Histogram of Distances");
    histogramPanel.add(chartPanel);

    JPanel detailsPanel = new JPanel(new VerticalLayout());
    gcMain.setGridHeight(3);
    gcMain.setWeights(1, 1);
    getContentPane().add(detailsPanel, gcMain.moveTo(1, 0));
    detailsPanel.add(databaseDetailsPanel);
    detailsPanel.add(histogramPanel);

}

From source file:mekhq.gui.FinancesTab.java

@Override
public void initTab() {
    resourceMap = ResourceBundle.getBundle("mekhq.resources.FinancesTab", new EncodeControl()); //$NON-NLS-1$

    GridBagConstraints gridBagConstraints;

    setLayout(new GridBagLayout());
    ChartPanel financeAmountPanel = (ChartPanel) createGraphPanel(GraphType.BALANCE_AMOUNT);
    ChartPanel financeMonthlyPanel = (ChartPanel) createGraphPanel(GraphType.MONTHLY_FINANCES);

    financeModel = new FinanceTableModel();
    financeTable = new JTable(financeModel);
    financeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    financeTable.addMouseListener(new FinanceTableMouseAdapter(getCampaignGui(), financeTable, financeModel));
    financeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    TableColumn column = null;//from  w  w w  .j a va 2 s  .  c  o m
    for (int i = 0; i < FinanceTableModel.N_COL; i++) {
        column = financeTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(financeModel.getColumnWidth(i));
        column.setCellRenderer(financeModel.getRenderer());
    }
    financeTable.setIntercellSpacing(new Dimension(0, 0));
    financeTable.setShowGrid(false);

    loanModel = new LoanTableModel();
    loanTable = new JTable(loanModel);
    loanTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    loanTable.addMouseListener(new LoanTableMouseAdapter(getCampaignGui(), loanTable, loanModel));
    loanTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    column = null;
    for (int i = 0; i < LoanTableModel.N_COL; i++) {
        column = loanTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(loanModel.getColumnWidth(i));
        column.setCellRenderer(loanModel.getRenderer());
    }
    loanTable.setIntercellSpacing(new Dimension(0, 0));
    loanTable.setShowGrid(false);
    JScrollPane scrollLoanTable = new JScrollPane(loanTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    JPanel panBalance = new JPanel(new GridBagLayout());
    panBalance.add(new JScrollPane(financeTable), gridBagConstraints);
    panBalance.setMinimumSize(new java.awt.Dimension(350, 100));
    panBalance.setBorder(BorderFactory.createTitledBorder("Balance Sheet"));
    JPanel panLoan = new JPanel(new GridBagLayout());
    panLoan.add(scrollLoanTable, gridBagConstraints);

    JTabbedPane financeTab = new JTabbedPane();
    financeTab.setMinimumSize(new java.awt.Dimension(450, 300));
    financeTab.setPreferredSize(new java.awt.Dimension(450, 300));

    JSplitPane splitFinances = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panBalance, financeTab);
    splitFinances.setOneTouchExpandable(true);
    splitFinances.setContinuousLayout(true);
    splitFinances.setResizeWeight(1.0);
    splitFinances.setName("splitFinances");

    financeTab.addTab(resourceMap.getString("activeLoans.text"), panLoan);
    financeTab.addTab(resourceMap.getString("cbillsBalanceTime.text"), financeAmountPanel);
    financeTab.addTab(resourceMap.getString("monthlyRevenueExpenditures.text"), financeMonthlyPanel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(splitFinances, gridBagConstraints);

    JPanel panelFinanceRight = new JPanel(new BorderLayout());

    JPanel pnlFinanceBtns = new JPanel(new GridLayout(2, 2));
    btnAddFunds = new JButton("Add Funds (GM)");
    btnAddFunds.addActionListener(ev -> addFundsActionPerformed());
    btnAddFunds.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnAddFunds);
    JButton btnGetLoan = new JButton("Get Loan");
    btnGetLoan.addActionListener(e -> showNewLoanDialog());
    pnlFinanceBtns.add(btnGetLoan);

    btnManageAssets = new JButton("Manage Assets (GM)");
    btnManageAssets.addActionListener(e -> manageAssets());
    btnManageAssets.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnManageAssets);

    panelFinanceRight.add(pnlFinanceBtns, BorderLayout.NORTH);

    areaNetWorth = new JTextArea();
    areaNetWorth.setLineWrap(true);
    areaNetWorth.setWrapStyleWord(true);
    areaNetWorth.setFont(new Font("Courier New", Font.PLAIN, 12));
    areaNetWorth.setText(getCampaign().getFinancialReport());
    areaNetWorth.setEditable(false);

    JScrollPane descriptionScroll = new JScrollPane(areaNetWorth);
    panelFinanceRight.add(descriptionScroll, BorderLayout.CENTER);
    areaNetWorth.setCaretPosition(0);
    descriptionScroll.setMinimumSize(new Dimension(300, 200));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.0;
    gridBagConstraints.weighty = 1.0;
    add(panelFinanceRight, gridBagConstraints);
}

From source file:org.executequery.gui.drivers.AbstractDriverPanel.java

private void init() {

    ReflectiveAction action = new ReflectiveAction(this);

    JButton browseButton = new DefaultButton(action, getString("AbstractDriverPanel.addLibraryButton"),
            "browseDrivers");
    JButton removeButton = new DefaultButton(action, getString("AbstractDriverPanel.addRemoveButton"),
            "removeDrivers");

    JButton findButton = new DefaultInlineFieldButton(action);
    findButton.setText(getString("AbstractDriverPanel.addFindButton"));
    findButton.setActionCommand("findDriverClass");

    jarPathListModel = new DefaultListModel();

    nameField = textFieldWithKey("AbstractDriverPanel.driverNameToolTip");
    descField = textFieldWithKey("AbstractDriverPanel.descriptionToolTip");
    //        classField = textFieldWithKey("AbstractDriverPanel.classNameToolTip");

    classComboModel = new DynamicComboBoxModel();
    classField = WidgetFactory.createComboBox(classComboModel);
    classField.setToolTipText(getString("AbstractDriverPanel.classNameToolTip"));
    classField.setEditable(true);//from  ww  w.  jav a 2s  .  c  o  m

    jarPathList = new JList(jarPathListModel);
    jarPathList.setToolTipText(getString("AbstractDriverPanel.pathToolTip"));
    JScrollPane jarPathListScrollPane = new JScrollPane(jarPathList) {
        private int height = 120;

        @Override
        public Dimension getPreferredSize() {

            Dimension size = super.getPreferredSize();
            size.height = height;
            return size;
        }

        @Override
        public Dimension getMinimumSize() {

            Dimension size = super.getMinimumSize();
            size.height = height;
            return size;
        }
    };

    nameField.addFocusListener(new DriverNameFieldListener(this));

    databaseNameCombo = WidgetFactory.createComboBox(createDatabaseComboValues());
    databaseNameCombo.setToolTipText(getString("AbstractDriverPanel.databaseToolTip"));
    databaseNameCombo.addItemListener(this);

    urlComboModel = new DynamicComboBoxModel();
    driverUrlCombo = WidgetFactory.createComboBox(urlComboModel);
    driverUrlCombo.setToolTipText(getString("AbstractDriverPanel.jdbcUrlToolTip"));
    driverUrlCombo.setEditable(true);

    JPanel base = new TextFieldPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy++;
    gbc.insets = new Insets(10, 10, 5, 0);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    base.add(labelWithKey("AbstractDriverPanel.driverNameLabel"), gbc);
    gbc.gridy++;
    gbc.insets.top = 0;
    base.add(labelWithKey("AbstractDriverPanel.descriptionLabel"), gbc);
    gbc.gridy++;
    base.add(labelWithKey("AbstractDriverPanel.databaseLabel"), gbc);
    gbc.gridy++;
    base.add(labelWithKey("AbstractDriverPanel.jdbcUrlLabel"), gbc);
    gbc.gridy++;
    base.add(labelWithKey("AbstractDriverPanel.pathLabel"), gbc);
    gbc.gridy += 4;
    base.add(labelWithKey("AbstractDriverPanel.classNameLabel"), gbc);
    gbc.gridy = 0;
    gbc.gridx = 1;
    gbc.insets.right = 10;
    gbc.insets.top = 10;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    base.add(nameField, gbc);
    gbc.gridy++;
    gbc.insets.top = 0;
    base.add(descField, gbc);
    gbc.gridy++;
    base.add(databaseNameCombo, gbc);
    gbc.gridy++;
    base.add(driverUrlCombo, gbc);
    gbc.gridy++;
    gbc.gridwidth = 1;
    gbc.insets.right = 0;
    gbc.gridheight = 2;
    gbc.insets.top = 5;
    base.add(jarPathListScrollPane, gbc);
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.insets.right = 10;
    gbc.gridheight = 1;
    gbc.insets.left = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    base.add(browseButton, gbc);
    gbc.gridy++;
    gbc.insets.top = 0;
    base.add(removeButton, gbc);

    gbc.gridy += 3;
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.insets.right = 0;
    gbc.insets.left = 10;
    gbc.insets.top = 0;
    base.add(classField, gbc);
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.weighty = 1.0;
    gbc.insets.right = 10;
    gbc.insets.left = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    base.add(findButton, gbc);

    add(base, BorderLayout.CENTER);
}

From source file:pcgen.gui2.dialog.AboutDialog.java

/**
 * Construct the credits panel. This panel shows basic details
 * about PCGen and lists all involved in it's creation.
 *
 * @return The credits panel.//w  ww .j  a va  2  s  . c om
 */
private JPanel buildCreditsPanel() {

    JLabel versionLabel = new JLabel();
    JLabel dateLabel = new JLabel();
    JLabel javaVersionLabel = new JLabel();
    JLabel leaderLabel = new JLabel();
    JLabel helperLabel = new JLabel();
    JLabel wwwLink = new JLabel();
    JLabel emailLabel = new JLabel();
    JTextField version = new JTextField();
    JTextField releaseDate = new JTextField();
    JTextField javaVersion = new JTextField();
    JTextField projectLead = new JTextField();
    wwwSite = new JButton();
    mailingList = new JButton();
    JTabbedPane monkeyTabPane = new JTabbedPane();

    JPanel aCreditsPanel = new JPanel();
    aCreditsPanel.setLayout(new GridBagLayout());

    // Labels

    versionLabel.setText(LanguageBundle.getString("in_abt_version")); //$NON-NLS-1$
    GridBagConstraints gridBagConstraints1 = buildConstraints(0, 0, GridBagConstraints.WEST);
    gridBagConstraints1.weightx = 0.2;
    aCreditsPanel.add(versionLabel, gridBagConstraints1);

    dateLabel.setText(LanguageBundle.getString("in_abt_release_date")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 1, GridBagConstraints.WEST);
    aCreditsPanel.add(dateLabel, gridBagConstraints1);

    javaVersionLabel.setText(LanguageBundle.getString("in_abt_java_version")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 2, GridBagConstraints.WEST);
    aCreditsPanel.add(javaVersionLabel, gridBagConstraints1);

    leaderLabel.setText(LanguageBundle.getString("in_abt_BD")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 3, GridBagConstraints.WEST);
    aCreditsPanel.add(leaderLabel, gridBagConstraints1);

    wwwLink.setText(LanguageBundle.getString("in_abt_web")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 4, GridBagConstraints.WEST);
    aCreditsPanel.add(wwwLink, gridBagConstraints1);

    emailLabel.setText(LanguageBundle.getString("in_abt_email")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 5, GridBagConstraints.WEST);
    aCreditsPanel.add(emailLabel, gridBagConstraints1);

    helperLabel.setText(LanguageBundle.getString("in_abt_monkeys")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 6, GridBagConstraints.NORTHWEST);
    aCreditsPanel.add(helperLabel, gridBagConstraints1);

    // Info

    version.setEditable(false);
    String versionNum = PCGenPropBundle.getVersionNumber();
    if (StringUtils.isNotBlank(PCGenPropBundle.getAutobuildNumber())) {
        versionNum += " autobuild #" + PCGenPropBundle.getAutobuildNumber();
    }
    version.setText(versionNum);
    version.setBorder(null);
    version.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 0, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints1.weightx = 1.0;
    aCreditsPanel.add(version, gridBagConstraints1);

    releaseDate.setEditable(false);
    String releaseDateStr = PCGenPropBundle.getReleaseDate();
    if (StringUtils.isNotBlank(PCGenPropBundle.getAutobuildDate())) {
        releaseDateStr = PCGenPropBundle.getAutobuildDate();
    }
    releaseDate.setText(releaseDateStr);
    releaseDate.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    releaseDate.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 1, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(releaseDate, gridBagConstraints1);

    javaVersion.setEditable(false);
    javaVersion.setText(
            System.getProperty("java.runtime.version") + " (" + System.getProperty("java.vm.vendor") + ")");
    javaVersion.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    javaVersion.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 2, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(javaVersion, gridBagConstraints1);

    projectLead.setEditable(false);
    projectLead.setText(PCGenPropBundle.getHeadCodeMonkey());
    projectLead.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    projectLead.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 3, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(projectLead, gridBagConstraints1);

    // Web site button
    wwwSite.setText(PCGenPropBundle.getWWWHome());
    wwwSite.addActionListener(event -> {
        try {
            DesktopBrowserLauncher.viewInBrowser(new URL(wwwSite.getText()));
        } catch (IOException ioe) {
            Logging.errorPrint(LanguageBundle.getString("in_abt_browser_err"), ioe); //$NON-NLS-1$
        }
    });
    gridBagConstraints1 = buildConstraints(1, 4, GridBagConstraints.WEST);
    aCreditsPanel.add(wwwSite, gridBagConstraints1);

    // Mailing list button
    mailingList.setText(PCGenPropBundle.getMailingList());
    mailingList.addActionListener(event -> {
        try {
            DesktopBrowserLauncher.viewInBrowser(new URL(mailingList.getText()));
        } catch (IOException ioe) {
            Logging.errorPrint(LanguageBundle.getString("in_err_browser_err"), ioe); //$NON-NLS-1$
        }
    });
    gridBagConstraints1 = buildConstraints(1, 5, GridBagConstraints.WEST);
    aCreditsPanel.add(mailingList, gridBagConstraints1);

    // Monkey tabbed pane
    gridBagConstraints1 = buildConstraints(1, 6, GridBagConstraints.WEST);
    gridBagConstraints1.gridwidth = 2;
    gridBagConstraints1.weighty = 1.0;
    gridBagConstraints1.fill = GridBagConstraints.BOTH;
    aCreditsPanel.add(monkeyTabPane, gridBagConstraints1);

    monkeyTabPane.add(LanguageBundle.getString("in_abt_code_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getCodeMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_list_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getListMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_test_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getTestMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_eng_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getEngineeringMonkeys()));

    // because there isn't one
    monkeyTabPane.setToolTipTextAt(2, LanguageBundle.getString("in_abt_easter_egg")); //$NON-NLS-1$

    return aCreditsPanel;
}

From source file:gov.nij.er.ui.EntityResolutionDemo.java

private void layoutUI() {

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

    JScrollPane rawDataTreeScrollPane = new JScrollPane(rawDataTree);
    JScrollPane parametersTableScrollPane = new JScrollPane(parametersTable);
    JScrollPane resolvedDataTreeScrollPane = new JScrollPane(resolvedDataTree);

    Insets insets = new Insets(5, 5, 5, 5);
    panel.add(new JLabel("Raw Data:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0));
    panel.add(new JLabel("Resolved Data:"), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0));
    panel.add(rawDataTreeScrollPane, new GridBagConstraints(0, 1, 1, 1, 0.5, 0.5, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, insets, 0, 0));
    panel.add(resolvedDataTreeScrollPane, new GridBagConstraints(1, 1, 1, 1, 0.5, 0.5,
            GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0));
    panel.add(rawRecordCountLabel, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, insets, 0, 0));
    JPanel resolvedLabelPanel = new JPanel();
    resolvedLabelPanel.setLayout(new GridBagLayout());
    resolvedLabelPanel.add(resolvedRecordCountLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
            GridBagConstraints.EAST, GridBagConstraints.BOTH, insets, 0, 0));
    resolvedLabelPanel.add(filterForSelectedCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0));
    panel.add(resolvedLabelPanel, new GridBagConstraints(1, 2, 1, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, insets, 0, 0));
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());
    bottomPanel.add(new JLabel("Parameters:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0));
    bottomPanel.add(parametersTableScrollPane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
            GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0));
    bottomPanel.add(resolveButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE, insets, 0, 0));
    panel.add(bottomPanel, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.5, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, insets, 0, 0));
    this.setContentPane(panel);

}

From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java

private JPanel initJournalPanel(final Journal jrnl) {

    final JPanel panelTmp = new JPanel();
    long totalDebitJournal = 0;
    long totalCreditJournal = 0;

    panelTmp.setLayout(new GridBagLayout());

    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;//  w ww .  j a v  a 2 s.c  o  m
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 0;

    String req = "SELECT DISTINCT EXTRACT(YEAR FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\"), "
            + "EXTRACT(MONTH FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\")," + " SUM(\"" + baseName
            + "\".\"ECRITURE\".\"DEBIT\"), " + "SUM(\"" + baseName + "\".\"ECRITURE\".\"CREDIT\")" + " FROM \""
            + baseName + "\".\"ECRITURE\" " + "WHERE (\"" + baseName + "\".\"ECRITURE\".\"ID\" != 1) "
            + "AND ((\"" + baseName + "\".\"ECRITURE\".\"ARCHIVE\" = 0) " + "AND (\"" + baseName
            + "\".\"ECRITURE\".\"ID_JOURNAL\" = " + jrnl.getId() + ")) " + "GROUP BY EXTRACT(YEAR FROM \""
            + baseName + "\".\"ECRITURE\".\"DATE\"), " + "EXTRACT(MONTH FROM \"" + baseName
            + "\".\"ECRITURE\".\"DATE\") " + "ORDER BY EXTRACT(YEAR FROM \"" + baseName
            + "\".\"ECRITURE\".\"DATE\"), " + "EXTRACT(MONTH FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\")";
    System.out.println(req);

    Object ob = base.getDataSource().execute(req, new ArrayListHandler());

    List myList = (List) ob;

    // System.err.println("TEST DATE " + t);

    if (myList.size() != 0) {

        for (int i = 0; i < myList.size(); i++) {

            Object[] objTmp = (Object[]) myList.get(i);

            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.DATE, 1);
            int month = (new Double(objTmp[1].toString()).intValue() - 1);
            System.err.println(jrnl.getNom() + " SET MONTH " + month);
            cal.set(Calendar.MONTH, month);
            System.err.println(month + " = " + cal.getTime());

            cal.set(Calendar.YEAR, new Double(objTmp[0].toString()).intValue());

            long debitMois = ((Number) objTmp[2]).longValue();
            long creditMois = ((Number) objTmp[3]).longValue();

            c.gridwidth = GridBagConstraints.REMAINDER;
            final JPanel creerJournalMoisPanel = creerJournalMoisPanel(cal.getTime(), debitMois, creditMois,
                    jrnl);
            creerJournalMoisPanel.setOpaque(false);
            panelTmp.add(creerJournalMoisPanel, c);

            c.gridy++;

            totalDebitJournal += debitMois;
            totalCreditJournal += creditMois;
        }
    }
    c.gridx = 0;
    c.weighty = 1;
    c.gridwidth = 1;
    final JLabel label = new JLabel("Journal " + jrnl.getNom());
    label.setOpaque(false);
    panelTmp.add(label, c);
    c.gridx = GridBagConstraints.RELATIVE;
    panelTmp.add(new JLabel(" Total dbit : " + GestionDevise.currencyToString(totalDebitJournal)), c);
    panelTmp.add(new JLabel(" Total crdit : " + GestionDevise.currencyToString(totalCreditJournal)), c);

    return panelTmp;
}

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

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

    bgColor = UIUtilities.BACKGROUND_COLOUR_ODD;

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

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

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

From source file:org.executequery.gui.ExportResultSetPanel.java

private void init() throws Exception {

    fileNameField = WidgetFactory.createTextField();
    connectionsCombo = WidgetFactory.createComboBox();

    String[] delims = { "|", ",", ";", "#" };
    delimiterCombo = WidgetFactory.createComboBox(delims);
    delimiterCombo.setEditable(true);/*w  w  w. j av a 2 s. c  om*/

    combosGroup = new TableSelectionCombosGroup(connectionsCombo);

    includeColumNamesCheck = new JCheckBox("Include column names as first row");

    sqlText = new SimpleSqlTextPanel();
    //        sqlText.getTextPane().setBackground(Color.WHITE);
    sqlText.setBorder(null);
    sqlText.setScrollPaneBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, UIUtils.getDefaultBorderColour()));

    statusBar = new SqlTextPaneStatusBar();
    JPanel sqlPanel = new JPanel(new BorderLayout());
    sqlPanel.add(sqlText, BorderLayout.CENTER);
    sqlPanel.add(statusBar, BorderLayout.SOUTH);
    statusBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1));

    outputPanel = new LoggingOutputPanel();
    FlatSplitPane splitPane = new FlatSplitPane(JSplitPane.VERTICAL_SPLIT, sqlPanel, outputPanel);
    splitPane.setResizeWeight(0.5);
    splitPane.setDividerLocation(0.8);
    splitPane.setDividerSize(5);

    JButton button = WidgetFactory.createInlineFieldButton("Browse");
    button.setActionCommand("browse");
    button.addActionListener(this);
    button.setMnemonic('r');

    JPanel mainPanel = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridheight = 1;
    gbc.insets.top = 5;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    gbc.insets.left = 5;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    mainPanel.add(new JLabel("Connection:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(connectionsCombo, gbc);
    gbc.insets.left = 5;
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    mainPanel.add(new JLabel("Data Delimiter:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(delimiterCombo, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 2;
    mainPanel.add(new JLabel("Output File:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(fileNameField, gbc);
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.insets.left = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(button, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets.top = 2;
    gbc.insets.left = 5;
    mainPanel.add(includeColumNamesCheck, gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    mainPanel.add(new JLabel(instructionNote()), gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gbc.insets.top = 0;
    gbc.insets.left = 5;
    gbc.insets.bottom = 5;
    gbc.fill = GridBagConstraints.BOTH;
    mainPanel.add(splitPane, gbc);

    mainPanel.setBorder(BorderFactory.createEtchedBorder());

    int minimumButtonWidth = 85;
    executeButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Execute", "executeAndExport");
    stopButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Stop", "stop");
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5));
    buttonPanel.add(executeButton);
    buttonPanel.add(stopButton);

    stopButton.setEnabled(false);

    add(mainPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    // register as a keyword and connection listener
    EventMediator.registerListener(this);

    JTextPane textPane = sqlText.getTextPane();
    ActionMap actionMap = textPane.getActionMap();

    String actionKey = "executeQueryAction";
    actionMap.put(actionKey, executeQueryAction);

    InputMap inputMap = textPane.getInputMap();
    inputMap.put(EXECUTE_KEYSTROKE, actionKey);

    JPopupMenu popupMenu = sqlText.getPopup();
    popupMenu.addSeparator();
    popupMenu.add(executeQueryAction);
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java

/**
 * Cre le panel d'un onglet associ  une classe
 * //w  ww.  j a  v  a 2s .  c o  m
 * @param cc ClasseCompte la classe des comptes
 * @return JPanel le JPanel associ
 */
private JPanel initClassePanel(ClasseCompte cc) {

    final JPanel panelTmp = new JPanel();
    long totalDebitClasse = 0;
    long totalCreditClasse = 0;

    panelTmp.setLayout(new GridBagLayout());
    panelTmp.setOpaque(false);
    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 0;

    // Rcupration des comptes de la classe avec le total
    SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLTable compteTable = base.getTable("COMPTE_PCE");
    SQLTable ecritureTable = base.getTable("ECRITURE");

    SQLSelect sel = new SQLSelect(base);
    sel.addSelect(compteTable.getKey());
    sel.addSelect(compteTable.getField("NUMERO"));
    sel.addSelect(compteTable.getField("NOM"));
    sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
    sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");

    String function = "REGEXP";
    String match = cc.getTypeNumeroCompte();
    if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
        // function = "SIMILAR TO";
        function = "~";
        // match = cc.getTypeNumeroCompte().replace(".*", "%");
    }

    Where w = new Where(compteTable.getField("NUMERO"), function, match);
    Where w2 = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey());

    if (!UserManager.getInstance().getCurrentUser().getRights()
            .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
        // TODO Show Restricted acces in UI
        w = w.and(new Where(ecritureTable.getField("COMPTE_NUMERO"), "LIKE", "411%"));
    }

    sel.setWhere(w.and(w2));

    String req = sel.asString()
            + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\",\"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
    System.out.println(req);

    Object ob = base.getDataSource().execute(req, new ArrayListHandler());

    List myList = (List) ob;

    JLabel labelTotalClasse = new JLabel();
    labelTotalClasse.setOpaque(false);
    if (myList.size() != 0) {

        /***************************************************************************************
         * Cration des Panels de chaque compte
         **************************************************************************************/
        // c.weighty = 1;
        for (int i = 0; i < myList.size(); i++) {

            Object[] objTmp = (Object[]) myList.get(i);

            final Compte compteTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(),
                    objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(),
                    ((Number) objTmp[4]).longValue());

            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 1;
            c.weighty = 0;
            c.gridx = 0;
            c.gridy++;
            panelTmp.add(creerComptePanel(compteTmp), c);

            // calcul du total de la classe
            totalDebitClasse += compteTmp.getTotalDebit();
            totalCreditClasse += compteTmp.getTotalCredit();
        }

        // Total de la classe
        labelTotalClasse.setText(
                "Total Classe " + cc.getNom() + " Dbit : " + GestionDevise.currencyToString(totalDebitClasse)
                        + " Crdit : " + GestionDevise.currencyToString(totalCreditClasse));

    } else {
        labelTotalClasse.setHorizontalAlignment(SwingConstants.CENTER);
        labelTotalClasse.setText("Aucune criture pour la classe " + cc.getNom());
    }
    c.gridy++;
    c.weighty = 1;
    panelTmp.add(labelTotalClasse, c);

    return panelTmp;
}

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

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

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

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

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

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

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

    return (c);
}