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:io.github.tavernaextras.biocatalogue.ui.search_results.SOAPOperationListCellRenderer.java

/**
 * @return Final state of the {@link GridBagConstraints} instance
 *         that was used to lay out components in the panel.
 *///  ww  w  . j av  a 2  s . co  m
private GridBagConstraints arrangeLayout() {
    // 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(8, 6, 6, 3);
    this.add(jlTypeIcon, c);

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

    c.gridx++;
    c.gridheight = 7;
    c.weightx = 0;
    c.weighty = 1.0;
    this.add(jlItemStatus, c);

    c.gridx = 1;
    c.gridy++;
    c.gridheight = 1;
    c.weightx = 0;
    c.weighty = 0;
    this.add(jlPartOf, c);

    c.gridy++;
    this.add(jlWsdlLocation, c);

    c.fill = GridBagConstraints.NONE;
    c.gridy++;
    this.add(jtDescription, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridy++;
    this.add(jlSoapInputs, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridy++;
    this.add(jlSoapOutputs, c);

    return (c);
}

From source file:net.sourceforge.atunes.kernel.modules.state.RepositoryPanel.java

/**
 * Add components to panel//from  ww  w .  j av  a 2s . c o  m
 */
private void setupPanel() {
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 10, 0, 0);
    add(new JLabel(I18nUtils.getString("REPOSITORY_REFRESH_TIME")), c);
    c.gridx = 1;
    c.weightx = 1;
    c.insets = new Insets(0, 10, 0, 0);
    add(this.refreshTime, c);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.insets = new Insets(10, 10, 0, 0);
    add(new JLabel(I18nUtils.getString("COMMAND_BEFORE_REPOSITORY_ACCESS")), c);
    c.gridx = 1;
    c.weightx = 1;
    add(this.commandBeforeAccessRepository, c);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0;
    add(new JLabel(I18nUtils.getString("COMMAND_AFTER_REPOSITORY_ACCESS")), c);
    c.gridx = 1;
    c.weightx = 1;
    add(this.commandAfterAccessRepository, c);
    c.gridx = 0;
    c.gridy = 3;
    c.insets = new Insets(20, 10, 0, 0);
    JScrollPane scrollPane = this.controlsBuilder.createScrollPane(this.repositoryFoldersList);
    scrollPane.setMinimumSize(new Dimension(400, 300));
    scrollPane.setPreferredSize(new Dimension(400, 300));
    add(scrollPane, c);
    JPanel addRemovePanel = new JPanel(new GridLayout(1, 2, 5, 0));
    addRemovePanel.add(this.addFolderButton);
    addRemovePanel.add(this.removeFolderButton);
    c.gridy = 4;
    c.insets = new Insets(10, 10, 0, 0);
    add(addRemovePanel, c);
    c.gridx = 0;
    c.gridy = 5;
    c.weighty = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    add(this.useRatingsStoredInTag, c);
}

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

/**
 * @return Final state of the {@link GridBagConstraints} instance
 *         that was used to lay out components in the panel.
 *//*  w  w  w .  ja  va  2s  .co m*/
private GridBagConstraints arrangeLayout() {
    // 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(8, 6, 6, 3);
    this.add(jlTypeIcon, c);

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

    c.gridx++;
    c.gridheight = 8;
    c.weightx = 0;
    c.weighty = 1.0;
    this.add(jlItemStatus, c);

    c.gridx = 1;
    c.gridy++;
    c.gridheight = 1;
    c.weightx = 1.0;
    c.weighty = 0;
    this.add(jlPartOf, c);

    c.fill = GridBagConstraints.NONE;
    c.gridy++;
    this.add(jtDescription, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridy++;
    this.add(jlMethodType, c);

    c.gridy++;
    this.add(jlUrlTemplate, c);

    c.gridy++;
    this.add(jlMethodParameters, c);

    c.gridy++;
    this.add(jlInputRepresentations, c);

    c.gridy++;
    this.add(jlOutputRepresentations, c);
    return (c);
}

From source file:org.parosproxy.paros.extension.history.ManualRequestEditorDialog.java

private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        gridBagConstraints31.gridx = 0;//from w  w  w  .ja v a2 s . co m
        gridBagConstraints31.gridy = 0;
        gridBagConstraints31.weightx = 1.0;
        gridBagConstraints31.weighty = 1.0;
        gridBagConstraints31.fill = GridBagConstraints.BOTH;
        gridBagConstraints31.anchor = GridBagConstraints.NORTHWEST;
        jPanel.add(getPanelTab(), gridBagConstraints31);
    }
    return jPanel;
}

From source file:org.languagetool.gui.ConfigurationDialog.java

public boolean show(List<Rule> rules) {
    configChanged = false;/*ww w . j av a2s .  c  o  m*/
    if (original != null) {
        config.restoreState(original);
    }
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiConfigWindowTitle"));
    // close dialog when user presses Escape key:
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    ActionListener actionListener = new ActionListener() {
        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    };
    JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    configurableRules.clear();

    Language lang = config.getLanguage();
    if (lang == null) {
        lang = Languages.getLanguageForLocale(Locale.getDefault());
    }

    String specialTabNames[] = config.getSpecialTabNames();
    int numConfigTrees = 2 + specialTabNames.length;
    configTree = new JTree[numConfigTrees];
    JPanel checkBoxPanel[] = new JPanel[numConfigTrees];
    DefaultMutableTreeNode rootNode;
    GridBagConstraints cons;

    for (int i = 0; i < numConfigTrees; i++) {
        checkBoxPanel[i] = new JPanel();
        cons = new GridBagConstraints();
        checkBoxPanel[i].setLayout(new GridBagLayout());
        cons.anchor = GridBagConstraints.NORTHWEST;
        cons.gridx = 0;
        cons.weightx = 1.0;
        cons.weighty = 1.0;
        cons.fill = GridBagConstraints.HORIZONTAL;
        Collections.sort(rules, new CategoryComparator());
        if (i == 0) {
            rootNode = createTree(rules, false, null); //  grammar options
        } else if (i == 1) {
            rootNode = createTree(rules, true, null); //  Style options
        } else {
            rootNode = createTree(rules, true, specialTabNames[i - 2]); //  Special tab options
        }
        configTree[i] = new JTree(getTreeModel(rootNode));

        configTree[i].applyComponentOrientation(ComponentOrientation.getOrientation(lang.getLocale()));

        configTree[i].setRootVisible(false);
        configTree[i].setEditable(false);
        configTree[i].setCellRenderer(new CheckBoxTreeCellRenderer());
        TreeListener.install(configTree[i]);
        checkBoxPanel[i].add(configTree[i], cons);
        configTree[i].addMouseListener(getMouseAdapter());
    }

    JPanel portPanel = new JPanel();
    portPanel.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.anchor = GridBagConstraints.WEST;
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.0f;
    if (!insideOffice) {
        createNonOfficeElements(cons, portPanel);
    } else {
        createOfficeElements(cons, portPanel);
    }

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
    okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
    okButton.setActionCommand(ACTION_COMMAND_OK);
    okButton.addActionListener(this);
    JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
    cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
    cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
    cancelButton.addActionListener(this);
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    buttonPanel.add(okButton, cons);
    buttonPanel.add(cancelButton, cons);

    JTabbedPane tabpane = new JTabbedPane();

    JPanel jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);

    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.NORTHWEST;
    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getMotherTonguePanel(cons), cons);

    if (insideOffice) {
        cons.gridy += 3;
    } else {
        cons.gridy++;
    }
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getNgramPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getWord2VecPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(portPanel, cons);
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.anchor = GridBagConstraints.WEST;
    for (JPanel extra : extraPanels) {
        //in case it wasn't in a containment hierarchy when user changed L&F
        SwingUtilities.updateComponentTreeUI(extra);
        cons.gridy++;
        jPane.add(extra, cons);
    }

    cons.gridy++;
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1.0f;
    jPane.add(new JPanel(), cons);

    tabpane.addTab(messages.getString("guiGeneral"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[0]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(0), cons);

    tabpane.addTab(messages.getString("guiGrammarRules"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[1]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(1), cons);

    cons.gridx = 0;
    cons.gridy++;
    cons.weightx = 5.0f;
    cons.weighty = 5.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(new JScrollPane(getSpecialRuleValuePanel()), cons);

    tabpane.addTab(messages.getString("guiStyleRules"), jPane);

    for (int i = 0; i < specialTabNames.length; i++) {
        jPane = new JPanel();
        jPane.setLayout(new GridBagLayout());
        cons = new GridBagConstraints();
        cons.insets = new Insets(4, 4, 4, 4);
        cons.gridx = 0;
        cons.gridy = 0;
        cons.weightx = 10.0f;
        cons.weighty = 10.0f;
        cons.fill = GridBagConstraints.BOTH;
        jPane.add(new JScrollPane(checkBoxPanel[i + 2]), cons);
        cons.weightx = 0.0f;
        cons.weighty = 0.0f;

        cons.gridx = 0;
        cons.gridy++;
        cons.fill = GridBagConstraints.NONE;
        cons.anchor = GridBagConstraints.LINE_END;
        jPane.add(getTreeButtonPanel(i + 2), cons);

        tabpane.addTab(specialTabNames[i], jPane);
    }

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    if (insideOffice) {
        JLabel versionText = new JLabel(messages.getString("guiUColorHint"));
        versionText.setForeground(Color.blue);
        jPane.add(versionText, cons);
        cons.gridy++;
    }

    cons.weightx = 2.0f;
    cons.weighty = 2.0f;
    cons.fill = GridBagConstraints.BOTH;

    jPane.add(new JScrollPane(getUnderlineColorPanel(rules)), cons);

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.NORTHWEST;
    contentPane.add(tabpane, cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.EAST;
    contentPane.add(buttonPanel, cons);

    dialog.pack();
    // center on screen:
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dialog.getSize();
    dialog.setLocation(screenSize.width / 2 - frameSize.width / 2,
            screenSize.height / 2 - frameSize.height / 2);
    dialog.setLocationByPlatform(true);
    //  add Color tab after dimension was set
    tabpane.addTab(messages.getString("guiUnderlineColor"), jPane);

    for (JPanel extra : this.extraPanels) {
        if (extra instanceof SavablePanel) {
            ((SavablePanel) extra).componentShowing();
        }
    }
    dialog.setVisible(true);
    return configChanged;
}

From source file:burp.BurpExtender.java

private JPanel createMainPanel() {
    JPanel main = new JPanel();
    main.setLayout(new GridBagLayout());

    // Create Settings Panel
    JPanel settings = new JPanel(new GridBagLayout());

    createTitle("Settings", settings);
    KeyListener projectEnter = new KeyAdapter() {
        @Override//from   w w  w.j  a  va 2 s  .c om
        public void keyPressed(KeyEvent k) {
            if (k.getKeyCode() == KeyEvent.VK_ENTER)
                updateProjects();
        }
    };

    serverUrl = labelTextField("Server URL: ", settings,
            callbacks.loadExtensionSetting(BurpExtender.SERVER_KEY));
    serverUrl.addKeyListener(projectEnter);
    serverUrl.addFocusListener(new JTextFieldSettingFocusListener(BurpExtender.SERVER_KEY, callbacks));

    apiKey = labelTextField("API Key: ", settings, callbacks.loadExtensionSetting(BurpExtender.API_KEY));
    apiKey.addKeyListener(projectEnter);
    apiKey.addFocusListener(new JTextFieldSettingFocusListener(BurpExtender.API_KEY, callbacks));

    JButton targetRefresh = new JButton();
    targetRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateTargets();
        }
    });
    targetUrl = createComboBox("Target URL: ", settings, 3, targetRefresh);

    projectRefresh = new JButton();
    projectRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Thread updateThread = new Thread() {
                public void run() {
                    NameValuePair selected = getProject();
                    if (selected != null)
                        callbacks.saveExtensionSetting(BurpExtender.PROJECT_KEY, selected.getValue());
                    updateProjects();
                }
            };
            updateThread.start();
        }
    });
    projectBox = createComboBox("Projects: ", settings, 4, projectRefresh);

    GridBagConstraints setGBC = new GridBagConstraints();
    setGBC.gridy = 3;
    setGBC.anchor = GridBagConstraints.NORTHWEST;
    main.add(settings, setGBC);

    // Separator
    Insets ins = new Insets(10, 10, 2, 10);

    JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
    callbacks.customizeUiComponent(sep);
    GridBagConstraints sepGBC = new GridBagConstraints();
    sepGBC.gridwidth = 3;
    sepGBC.gridx = 0;
    sepGBC.fill = GridBagConstraints.HORIZONTAL;
    sepGBC.insets = ins;
    main.add(sep, sepGBC);

    // Create Export Button
    JButton exportBtn = new JButton();
    exportBtn.setText("Send to Code Dx");
    exportBtn.addActionListener(new ExportActionListener(this, callbacks));
    callbacks.customizeUiComponent(exportBtn);
    GridBagConstraints btnGBC = new GridBagConstraints();
    btnGBC.gridx = 0;
    btnGBC.weightx = 1.0;
    btnGBC.weighty = 1.0;
    btnGBC.insets = ins;
    btnGBC.anchor = GridBagConstraints.NORTHWEST;
    main.add(exportBtn, btnGBC);

    updateTargets();
    return main;
}

From source file:analysers.FilterValidatedDialog.java

/**
 * Create the dialog.//from  w ww.j  a v a2s. c o m
 */
public FilterValidatedDialog() {
    setTitle("Validated Lineages: Export Filter");
    setBounds(100, 100, 632, 348);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    GridBagLayout gbl_contentPanel = new GridBagLayout();
    gbl_contentPanel.columnWidths = new int[] { 160, 440, 0 };
    gbl_contentPanel.rowHeights = new int[] { 1, 28, 28, 28, 0, 0 };
    gbl_contentPanel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
    contentPanel.setLayout(gbl_contentPanel);
    {
        JLabel lblCriterion = new JLabel("Lineage Criterion");
        lblCriterion.setFont(new Font("Lucida Grande", Font.BOLD, 13));
        GridBagConstraints gbc_lblCriterion = new GridBagConstraints();
        gbc_lblCriterion.insets = new Insets(0, 0, 5, 5);
        gbc_lblCriterion.gridx = 0;
        gbc_lblCriterion.gridy = 0;
        contentPanel.add(lblCriterion, gbc_lblCriterion);
    }
    {
        JLabel lblValue = new JLabel("Value");
        lblValue.setFont(new Font("Lucida Grande", Font.BOLD, 13));
        GridBagConstraints gbc_lblValue = new GridBagConstraints();
        gbc_lblValue.insets = new Insets(0, 0, 5, 0);
        gbc_lblValue.gridx = 1;
        gbc_lblValue.gridy = 0;
        contentPanel.add(lblValue, gbc_lblValue);
    }
    {
        lblMinLineageLength = new JLabel("Min. Length (frames)");
        GridBagConstraints gbc_lblMinLineageLength = new GridBagConstraints();
        gbc_lblMinLineageLength.fill = GridBagConstraints.BOTH;
        gbc_lblMinLineageLength.insets = new Insets(0, 0, 5, 5);
        gbc_lblMinLineageLength.gridx = 0;
        gbc_lblMinLineageLength.gridy = 1;
        contentPanel.add(lblMinLineageLength, gbc_lblMinLineageLength);
    }
    {
        minLinLen = new JTextField();
        GridBagConstraints gbc_minLinLen = new GridBagConstraints();
        gbc_minLinLen.anchor = GridBagConstraints.NORTH;
        gbc_minLinLen.fill = GridBagConstraints.HORIZONTAL;
        gbc_minLinLen.insets = new Insets(0, 0, 5, 0);
        gbc_minLinLen.gridx = 1;
        gbc_minLinLen.gridy = 1;
        contentPanel.add(minLinLen, gbc_minLinLen);
        minLinLen.setText("1");
        minLinLen.setColumns(3);
    }
    {
        lblStartFrameOf = new JLabel("Max. Start Frame");
        GridBagConstraints gbc_lblStartFrameOf = new GridBagConstraints();
        gbc_lblStartFrameOf.fill = GridBagConstraints.HORIZONTAL;
        gbc_lblStartFrameOf.insets = new Insets(0, 0, 5, 5);
        gbc_lblStartFrameOf.gridx = 0;
        gbc_lblStartFrameOf.gridy = 2;
        contentPanel.add(lblStartFrameOf, gbc_lblStartFrameOf);
    }
    {
        startLin = new JTextField();
        GridBagConstraints gbc_startLin = new GridBagConstraints();
        gbc_startLin.insets = new Insets(0, 0, 5, 0);
        gbc_startLin.fill = GridBagConstraints.HORIZONTAL;
        gbc_startLin.gridx = 1;
        gbc_startLin.gridy = 2;
        contentPanel.add(startLin, gbc_startLin);
        startLin.setText("-1");
        startLin.setColumns(3);
    }
    {
        JButton btnPreview = new JButton("Preview");
        btnPreview.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                preview.setText(makePreview());
            }
        });
        GridBagConstraints gbc_btnPreview = new GridBagConstraints();
        gbc_btnPreview.insets = new Insets(0, 0, 5, 5);
        gbc_btnPreview.gridx = 0;
        gbc_btnPreview.gridy = 3;
        contentPanel.add(btnPreview, gbc_btnPreview);
    }
    {
        JScrollPane scrollPane = new JScrollPane();
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 1;
        gbc_scrollPane.gridy = 3;
        contentPanel.add(scrollPane, gbc_scrollPane);
        {
            preview = new JTextArea();
            scrollPane.setViewportView(preview);
            preview.setEditable(false);
            preview.setColumns(10);
            preview.setTabSize(4);
        }
    }
    {
        JLabel lblOptions = new JLabel("Options");
        GridBagConstraints gbc_lblOptions = new GridBagConstraints();
        gbc_lblOptions.insets = new Insets(0, 0, 0, 5);
        gbc_lblOptions.gridx = 0;
        gbc_lblOptions.gridy = 4;
        contentPanel.add(lblOptions, gbc_lblOptions);
    }
    {
        JPanel panel = new JPanel();
        GridBagConstraints gbc_panel = new GridBagConstraints();
        gbc_panel.anchor = GridBagConstraints.NORTH;
        gbc_panel.fill = GridBagConstraints.HORIZONTAL;
        gbc_panel.gridx = 1;
        gbc_panel.gridy = 4;
        contentPanel.add(panel, gbc_panel);
        GridBagLayout gbl_panel = new GridBagLayout();
        gbl_panel.columnWidths = new int[] { 69, 169, 162, 0 };
        gbl_panel.rowHeights = new int[] { 23, 23, 0 };
        gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
        gbl_panel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
        panel.setLayout(gbl_panel);
        {
            rdbtnExportMeanIntensity = new JRadioButton("Export Mean Intensity");
            rdbtnExportMeanIntensity.setSelected(true);
            buttonGroup.add(rdbtnExportMeanIntensity);
            GridBagConstraints gbc_rdbtnExportMeanIntensity = new GridBagConstraints();
            gbc_rdbtnExportMeanIntensity.anchor = GridBagConstraints.NORTHWEST;
            gbc_rdbtnExportMeanIntensity.insets = new Insets(0, 0, 5, 5);
            gbc_rdbtnExportMeanIntensity.gridx = 1;
            gbc_rdbtnExportMeanIntensity.gridy = 0;
            panel.add(rdbtnExportMeanIntensity, gbc_rdbtnExportMeanIntensity);
        }
        {
            rdbtnExportMaxIntensity = new JRadioButton("Export Max Intensity");
            buttonGroup.add(rdbtnExportMaxIntensity);
            GridBagConstraints gbc_rdbtnExportMaxIntensity = new GridBagConstraints();
            gbc_rdbtnExportMaxIntensity.anchor = GridBagConstraints.NORTHWEST;
            gbc_rdbtnExportMaxIntensity.insets = new Insets(0, 0, 5, 0);
            gbc_rdbtnExportMaxIntensity.gridx = 2;
            gbc_rdbtnExportMaxIntensity.gridy = 0;
            panel.add(rdbtnExportMaxIntensity, gbc_rdbtnExportMaxIntensity);
        }
        {
            chckbxExportPositions = new JCheckBox("Export Cell Positions and Areas in CSV");
            GridBagConstraints gbc_chckbxExportPositions = new GridBagConstraints();
            gbc_chckbxExportPositions.anchor = GridBagConstraints.NORTH;
            gbc_chckbxExportPositions.gridwidth = 2;
            gbc_chckbxExportPositions.gridx = 1;
            gbc_chckbxExportPositions.gridy = 1;
            panel.add(chckbxExportPositions, gbc_chckbxExportPositions);
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton okButton = new JButton("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                    if (validateFields()) {
                        Prefs.set("TrackApp.FilterValidatedDialog.startLin", valStartLin);
                        Prefs.set("TrackApp.FilterValidatedDialog.minLinLen", valMinLinLen);
                        Prefs.set("TrackApp.FilterValidatedDialog.exportMean", doExportMean);
                        Prefs.set("TrackApp.FilterValidatedDialog.exportPositions", doExportPositions);
                        Prefs.savePreferences();
                        dispose();
                    }
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    dispose();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}

From source file:org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement.java

public SQLComponent createComponent() {
    return new BaseSQLComponent(this) {

        private Icon iconWarning = ImageIconWarning.getInstance();

        public void addViews() {
            this.setLayout(new GridBagLayout());
            final GridBagConstraints c = new DefaultGridBagConstraints();

            Set<Class<? extends SQLElement>> s = map.keySet();

            final ArrayList<Class<? extends SQLElement>> list = new ArrayList<Class<? extends SQLElement>>(s);
            Collections.sort(list, new Comparator<Class<? extends SQLElement>>() {
                public int compare(Class<? extends SQLElement> o1, Class<? extends SQLElement> o2) {
                    return o1.getSimpleName().toString().compareTo(o2.getSimpleName().toString());
                };/* w w  w.j a va  2s .  c om*/
            });

            List<String> added = new ArrayList<String>();
            for (Class<? extends SQLElement> class1 : list) {
                String prefix = map.get(class1);
                if (!added.contains(prefix)) {
                    c.gridy++;
                    c.gridx = 0;
                    c.weightx = 0;
                    added.add(prefix);
                    SQLElement elt = Configuration.getInstance().getDirectory().getElement(class1);
                    if (elt == null) {
                        throw new IllegalArgumentException("Element null for class " + class1);
                    }
                    // Avoir
                    JLabel labelAvoirFormat = new JLabel(
                            StringUtils.firstUp(elt.getPluralName()) + " " + getLabelFor(prefix + FORMAT),
                            SwingConstants.RIGHT);
                    this.add(labelAvoirFormat, c);
                    c.gridx++;
                    c.weightx = 1;
                    final JTextField fieldFormat = new JTextField();
                    this.add(fieldFormat, c);

                    final JLabel labelAvoirStart = new JLabel(getLabelFor(prefix + START));
                    c.gridx++;
                    c.weightx = 0;
                    this.add(labelAvoirStart, c);
                    c.gridx++;
                    c.weightx = 1;
                    final JTextField fieldStart = new JTextField();
                    this.add(fieldStart, c);

                    final JLabel labelResult = new JLabel();
                    c.gridx++;
                    c.weightx = 0;
                    this.add(labelResult, c);

                    if (getTable().getFieldsName().contains(prefix + AUTO_MONTH)) {
                        final JCheckBox boxAuto = new JCheckBox(getLabelFor(prefix + AUTO_MONTH));
                        c.gridx++;
                        c.weightx = 0;
                        this.add(boxAuto, c);
                        this.addSQLObject(boxAuto, prefix + AUTO_MONTH);
                    }
                    // Affichage dynamique du rsultat
                    SimpleDocumentListener listener = new SimpleDocumentListener() {

                        @Override
                        public void update(DocumentEvent e) {
                            updateLabel(fieldStart, fieldFormat, labelResult);

                        }
                    };

                    fieldFormat.getDocument().addDocumentListener(listener);
                    fieldStart.getDocument().addDocumentListener(listener);

                    this.addRequiredSQLObject(fieldFormat, prefix + FORMAT);
                    this.addRequiredSQLObject(fieldStart, prefix + START);
                }
            }

            // JLabel labelCodeLettrage = new JLabel(getLabelFor("CODE_LETTRAGE"));
            // c.gridy++;
            // c.gridx = 0;
            // c.weightx = 0;
            // this.add(labelCodeLettrage, c);
            // c.gridx++;
            // c.weightx = 1;
            // this.add(this.textCodeLettrage, c);
            //
            // c.gridx++;
            // c.weightx = 0;
            // labelNextCodeLettrage = new JLabel();
            // this.add(labelNextCodeLettrage, c);

            JLabel labelExemple = new JLabel("Exemple de format : 'Fact'yyyy0000");
            c.gridy++;
            c.gridx = 0;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weighty = 1;
            c.anchor = GridBagConstraints.NORTHWEST;
            this.add(labelExemple, c);

            // this.textCodeLettrage.getDocument().addDocumentListener(this.listenText);

        }

        // private void updateLabelNextCode() {
        // String s = getNextCodeLetrrage(this.textCodeLettrage.getText());
        // this.labelNextCodeLettrage.setText(donne + " " + s);
        // }

        private void updateLabel(JTextField textStart, JTextField textFormat, JLabel label) {
            if (textStart.getText().trim().length() > 0) {
                try {
                    String numProposition = getNextNumero(textFormat.getText(),
                            Integer.parseInt(textStart.getText()), new Date());

                    if (numProposition != null) {
                        label.setText(" --> " + numProposition);
                        label.setIcon(null);
                    } else {
                        label.setIcon(this.iconWarning);
                        label.setText("");
                    }
                } catch (IllegalArgumentException e) {
                    JOptionPane.showMessageDialog(null,
                            "Le format " + textFormat.getText() + " n'est pas valide!");
                }
            } else {
                label.setIcon(this.iconWarning);
                label.setText("");
            }
        }

    };
}

From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java

private void initUI() {
    setLayout(new GridBagLayout());

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    components = new ArrayList<JComponent>();
    checks = new ArrayList<JCheckBox>();

    int size = paramList.size();
    boolean shouldExpand = false;
    boolean needScroll = false;
    for (int i = 0; i < size; i++) {
        final int pos = i;
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            components.add(null);/*  w w w  .j a  va  2  s.co  m*/
            checks.add(null);
            initHiddenParameterValues(param);
            continue;
        }
        String source = param.getSource();
        String defaultSource = param.getDefaultSource();

        if ((defaultSource != null) && !defaultSource.trim().equals("")) {
            try {
                param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param));
            } catch (NextSqlException e) {
                Show.error(e);
            }
        }

        final JComponent component;
        int anchor = GridBagConstraints.WEST;
        double y = 0.0;
        int expand = GridBagConstraints.HORIZONTAL;
        if ((source != null) && !source.equals("")) {
            List<IdName> values = new ArrayList<IdName>();
            try {
                if (param.isManualSource()) {
                    if (!param.isDependent()) {
                        values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy());
                    }
                } else {
                    int index = source.indexOf(".");
                    int index2 = source.lastIndexOf(".");
                    String tableName = source.substring(0, index);
                    String columnName;
                    String shownColumnName = null;
                    if (index == index2) {
                        columnName = source.substring(index + 1);
                    } else {
                        columnName = source.substring(index + 1, index2);
                        shownColumnName = source.substring(index2 + 1);
                    }
                    values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName,
                            columnName, shownColumnName, param.getOrderBy());
                }
            } catch (NextSqlException e) {
                error = true;
                Show.error(e);
            } catch (InvalidSqlException e) {
                String m = I18NSupport.getString("source.dialog.valid");
                Show.info(m + " : \"select <exp1> , <exp2> from ...\"");
            }
            if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) {
                component = new JComboBox();
                final JComboBox combo = (JComboBox) component;
                combo.setRenderer(new IdNameRenderer());
                combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --");
                for (int j = 0, len = values.size(); j < len; j++) {
                    combo.addItem(values.get(j));
                }

                combo.addItemListener(new ItemListener() {
                    public void itemStateChanged(ItemEvent e) {
                        if (e.getStateChange() == ItemEvent.SELECTED) {
                            IdName in = null;
                            if (combo.getSelectedIndex() > 0) {
                                in = (IdName) combo.getSelectedItem();
                            }
                            parameterSelection(pos, in);
                        }
                    }
                });
                AutoCompleteDecorator.decorate(combo);
                needScroll = false;
            } else {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;

                DefaultListModel model = new DefaultListModel();
                for (int j = 0, len = values.size(); j < len; j++) {
                    model.addElement(values.get(j));
                }
                List srcList = Arrays.asList(model.toArray());
                component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    // needed for saved parameters on rerun
                    protected void onSetRight() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getDestinationElements().toArray();
                            if (values.length == 0) {
                                values = new Object[] { ParameterUtil.NULL };
                            }
                            parameterSelection(pos, values);
                        }
                    }
                };
                ((ListSelectionPanel) component).setListSize(scrListDim);
                ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(),
                        new IdNameComparator(param.getOrderBy()));

                shouldExpand = true;
            }

        } else {
            if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;
                ;
                component = new ListAddPanel(param) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getElements().toArray();
                            parameterSelection(pos, values);
                        }
                    }
                };
            } else {
                needScroll = false;
                if (param.getValueClassName().equals("java.util.Date")) {
                    component = new JXDatePicker();
                    ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() {
                        public void propertyChange(PropertyChangeEvent e) {
                            if ("date".equals(e.getPropertyName())) {
                                parameterSelection(pos, ((JXDatePicker) component).getDate());
                            }
                        }
                    });
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) component.getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.sql.Timestamp")
                        || param.getValueClassName().equals("java.sql.Time")) {
                    component = new JDateTimePicker() {
                        protected void onChange() {
                            parameterSelection(pos, getDate());
                        }
                    };
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker())
                            .getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.lang.Boolean")) {
                    component = new JCheckBox();
                    ((JCheckBox) component).addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
                            boolean selected = abstractButton.getModel().isSelected();
                            parameterSelection(pos, selected);
                        }
                    });
                } else {
                    component = new JTextField(25);
                    ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() {

                        @Override
                        public void changedUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void insertUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void removeUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        private void updateFromTextField(DocumentEvent e) {
                            java.awt.EventQueue.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    Object value = null;
                                    try {
                                        if ("".equals(((JTextField) component).getText().trim())) {
                                            value = null;
                                        } else {
                                            value = ParameterUtil.getParameterValueFromString(
                                                    param.getValueClassName(),
                                                    ((JTextField) component).getText());
                                        }
                                        parameterSelection(pos, value);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                        LOG.error(e.getMessage(), e);
                                    }
                                }
                            });
                        }
                    });
                }
            }
        }
        components.add(component);
        final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore"));
        checks.add(cb);

        final JLabel label = new JLabel(getRuntimeParameterName(param));
        panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE,
                new Insets(5, 5, 5, 5), 0, 0));
        final JComponent addComponent;
        if (needScroll) {
            JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scr.setPreferredSize(listDim);
            addComponent = scr;
        } else {
            addComponent = component;
        }
        panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand,
                new Insets(5, 0, 5, 5), 0, 0));
        int checkAnchor = GridBagConstraints.WEST;
        if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) {
            checkAnchor = GridBagConstraints.NORTHWEST;
        }

        if (Globals.getParametersIgnore()) {
            panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE,
                    new Insets(5, 0, 5, 5), 0, 0));
        }

        cb.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                if (cb.isSelected()) {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(false);
                    }
                    label.setEnabled(false);
                    addComponent.setEnabled(false);
                    param.setIgnore(true);
                } else {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(true);
                    }
                    label.setEnabled(true);
                    addComponent.setEnabled(true);
                    param.setIgnore(false);
                }
            }
        });
    }

    // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter)
    // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here
    for (int i = 0; i < size; i++) {
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            populateDependentParameters(param, false);
        }
    }

    if (!shouldExpand) {
        panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }

    JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrPanel.setPreferredSize(scrDim);
    scrPanel.setMinimumSize(scrDim);

    add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0), 0, 0));
    setParameterValues(parametersValues);
    setParameterIgnore(parametersIgnore);
}

From source file:net.datacrow.console.windows.charts.ChartPanel.java

private void build() {
    setLayout(Layout.getGBL());//from w  w  w. j  ava2s.co m

    JPanel panel = new JPanel();

    comboFields = ComponentFactory.getComboBox();
    comboTypes = ComponentFactory.getComboBox();

    panel.add(comboFields);
    panel.add(comboTypes);
    panel.add(btnAccept);

    for (DcField field : getFields()) {
        if (!field.isUiOnly() || field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION)
            comboFields.addItem(field);
    }

    comboTypes.addItem(DcResources.getText("lblPie"));
    comboTypes.addItem(DcResources.getText("lblBar"));

    btnAccept.addActionListener(this);
    btnAccept.setActionCommand("buildChart");
    add(panel, Layout.getGBC(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5), 0, 0));
}