Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

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

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

From source file:net.jradius.client.gui.JRadiusSimulator.java

/**
 * This method initializes tlsOptionsPanel
 * //ww  w .ja  v a2  s. c om
 * @return javax.swing.JPanel
 */
private JPanel getKeysOptionsPanel() {
    if (keysOptionsPanel == null) {
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 5);

        GridBagConstraints gridBagConstraintsH = new GridBagConstraints();
        gridBagConstraintsH.insets = new java.awt.Insets(10, 10, 5, 10);
        gridBagConstraintsH.gridwidth = java.awt.GridBagConstraints.REMAINDER;

        GridBagConstraints gridBagConstraints0 = new GridBagConstraints();
        gridBagConstraints0.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints0.insets = new java.awt.Insets(0, 0, 0, 5);
        gridBagConstraints0.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints0.weightx = 1.0;

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 5);
        gridBagConstraints1.weightx = 1.0;

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints2.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 10);

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints3.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints3.insets = new java.awt.Insets(0, 0, 0, 10);
        gridBagConstraints3.gridx = 1;

        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints4.insets = new java.awt.Insets(0, 0, 0, 5);

        GridBagLayout gridBagLayout = new GridBagLayout();

        keysOptionsPanel = new JPanel();
        keysOptionsPanel.setLayout(gridBagLayout);
        keysOptionsPanel.add(new JLabel("Client Certificate Java Keystore"), gridBagConstraintsH);
        keysOptionsPanel.add(new JLabel("File:"), gridBagConstraints);
        keysOptionsPanel.add(getTLSKeyFileTextField(), gridBagConstraints0);
        keysOptionsPanel.add(new JLabel("Password:"), gridBagConstraints);
        keysOptionsPanel.add(getTLSKeyPasswordTextField(), gridBagConstraints1);
        keysOptionsPanel.add(new JLabel("Type:"), gridBagConstraints4);
        keysOptionsPanel.add(getTLSKeyFileTypeComboBox(), gridBagConstraints2);
        keysOptionsPanel.add(new JLabel("Root CA Chain Java Keystore"), gridBagConstraintsH);
        keysOptionsPanel.add(new JLabel("File:"), gridBagConstraints);
        keysOptionsPanel.add(getTLSCAFileTextField(), gridBagConstraints0);
        keysOptionsPanel.add(new JLabel("Password:"), gridBagConstraints);
        keysOptionsPanel.add(getTLSCAPasswordTextField(), gridBagConstraints1);
        keysOptionsPanel.add(new JLabel("Type:"), gridBagConstraints4);
        keysOptionsPanel.add(getTLSCAFileTypeComboBox(), gridBagConstraints2);
        keysOptionsPanel.add(getOptionsLabel(), gridBagConstraints);
        //tlsOptionsPanel.add(getUseJavaRootCAChainCheckBox(), gridBagConstraints2);
        keysOptionsPanel.add(getTLSTrustAllCheckBox(), gridBagConstraints2);
    }
    return keysOptionsPanel;
}

From source file:de.bwravencl.controllerbuddy.gui.Main.java

void updateModesPanel() {
    if (modesListPanel == null)
        return;//from  w w  w . j  a  v  a 2s. co  m

    modesListPanel.removeAll();

    final var modes = input.getProfile().getModes();
    for (var i = 0; i < modes.size(); i++) {
        final var mode = modes.get(i);

        final var modePanel = new JPanel(new GridBagLayout());
        modesListPanel.add(modePanel,
                new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                        GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,
                        new Insets(0, 0, 0, 0), 0, 5));

        final var modeNoLabel = new JLabel(rb.getString("MODE_NO_LABEL_PREFIX") + (i + 1));
        modeNoLabel.setPreferredSize(new Dimension(100, 15));
        modePanel.add(modeNoLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BASELINE,
                GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        modePanel.add(Box.createGlue(), new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var descriptionTextField = new JTextField(mode.getDescription(), 20);
        modePanel.add(descriptionTextField, new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var setModeDescriptionAction = new SetModeDescriptionAction(mode, descriptionTextField);
        descriptionTextField.addActionListener(setModeDescriptionAction);
        descriptionTextField.getDocument().addDocumentListener(setModeDescriptionAction);

        modePanel.add(Box.createGlue(), new GridBagConstraints(3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        if (Profile.defaultMode.equals(mode) || OnScreenKeyboard.onScreenKeyboardMode.equals(mode)) {
            descriptionTextField.setEditable(false);
            modePanel.add(Box.createHorizontalStrut(BUTTON_DIMENSION.width));
        } else {
            final var deleteButton = new JButton(new RemoveModeAction(mode));
            deleteButton.setPreferredSize(BUTTON_DIMENSION);
            modePanel.add(deleteButton, new GridBagConstraints(4, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                    GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
    }

    modesListPanel.add(Box.createGlue(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
            GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    modesScrollPane.setViewportView(modesListPanel);
}

From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java

private JPanel createButtonPanel() {
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();

    buttonPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, SystemColor.windowBorder));
    buttonPanel.setOpaque(true);/*from ww w . j ava2  s  .c o  m*/
    buttonPanel.setBackground(ColorAndFontConstants.MID_BACKGROUND_COLOR);
    buttonPanel.setComponentOrientation(
            ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    Action helpAction;
    if (ComponentOrientation.LEFT_TO_RIGHT == ComponentOrientation
            .getOrientation(controller.getLocaliser().getLocale())) {
        helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_ICON_FILE,
                "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText",
                HelpContentsPanel.HELP_PREFERENCES_URL);
    } else {
        helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_RTL_ICON_FILE,
                "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText",
                HelpContentsPanel.HELP_PREFERENCES_URL);
    }
    HelpButton helpButton = new HelpButton(helpAction, controller);
    helpButton.setText("");
    helpButton.setToolTipText(controller.getLocaliser().getString("multiBitFrame.helpMenuTooltip"));
    helpButton.setHorizontalAlignment(SwingConstants.LEADING);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 0.3;
    constraints.weighty = 0.1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    buttonPanel.add(helpButton, constraints);

    ShowPreferencesSubmitAction submitAction = new ShowPreferencesSubmitAction(this.bitcoinController,
            this.exchangeController, this, ImageLoader.createImageIcon(ImageLoader.PREFERENCES_ICON_FILE),
            mainFrame);
    MultiBitButton submitButton = new MultiBitButton(submitAction, controller);
    buttonPanel.add(submitButton);

    UndoPreferencesChangesSubmitAction undoChangesAction = new UndoPreferencesChangesSubmitAction(controller,
            ImageLoader.createImageIcon(ImageLoader.UNDO_ICON_FILE));
    undoChangesButton = new MultiBitButton(undoChangesAction, controller);

    buttonPanel.add(undoChangesButton);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 0.1;
    constraints.weighty = 1.0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    buttonPanel.add(submitButton, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.weightx = 0.1;
    constraints.weighty = 1.0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    buttonPanel.add(undoChangesButton, constraints);

    JPanel fill1 = new JPanel();
    fill1.setOpaque(false);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.weightx = 200;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(fill1, constraints);

    return buttonPanel;
}

From source file:de.bwravencl.controllerbuddy.gui.Main.java

private void updateOverlayPanel() {
    if (indicatorsListPanel == null)
        return;/*w w w  .j a v a 2 s . c  o m*/

    indicatorsListPanel.removeAll();

    for (final var virtualAxis : Input.VirtualAxis.values()) {
        final var indicatorPanel = new JPanel(new GridBagLayout());
        indicatorsListPanel.add(indicatorPanel,
                new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                        GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,
                        new Insets(0, 0, 0, 0), 0, 5));

        final var virtualAxisLabel = new JLabel(virtualAxis.toString() + rb.getString("AXIS_LABEL_SUFFIX"));
        virtualAxisLabel.setPreferredSize(new Dimension(100, 15));
        indicatorPanel.add(virtualAxisLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var virtualAxisToOverlayAxisMap = input.getProfile().getVirtualAxisToOverlayAxisMap();
        final var overlayAxis = virtualAxisToOverlayAxisMap.get(virtualAxis);
        final var enabled = overlayAxis != null;

        final var colorLabel = new JLabel();
        if (enabled) {
            colorLabel.setOpaque(true);
            colorLabel.setBackground(overlayAxis.color);
        } else
            colorLabel.setText(rb.getString("INDICATOR_DISABLED_LABEL"));
        colorLabel.setHorizontalAlignment(SwingConstants.CENTER);

        colorLabel.setPreferredSize(new Dimension(100, 15));
        colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        indicatorPanel.add(colorLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.BASELINE,
                GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var colorButton = new JButton(new SelectIndicatorColorAction(virtualAxis));
        colorButton.setPreferredSize(BUTTON_DIMENSION);
        colorButton.setEnabled(enabled);
        indicatorPanel.add(colorButton, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var invertedCheckBox = new JCheckBox(new InvertIndicatorAction(virtualAxis));
        invertedCheckBox.setSelected(enabled && overlayAxis.inverted);
        invertedCheckBox.setEnabled(enabled);
        indicatorPanel.add(invertedCheckBox, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var displayCheckBox = new JCheckBox(new DisplayIndicatorAction(virtualAxis));
        displayCheckBox.setSelected(enabled);
        indicatorPanel.add(displayCheckBox, new GridBagConstraints(4, GridBagConstraints.RELATIVE, 1, 1, 0.0,
                0.0, GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    }

    indicatorsListPanel.add(Box.createGlue(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0,
            1.0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    indicatorsScrollPane.setViewportView(indicatorsListPanel);
}

From source file:Creator.WidgetPanel.java

private void _List_WidgetCodeListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event__List_WidgetCodeListValueChanged

    // _ScrollPane_WidgetSettings
    if (!evt.getValueIsAdjusting()) {

        // Load the variables of the widget
        String widgetCodeStr;//from  www .ja  v  a2  s  .  c o  m
        WidgetCode wc = null;
        WidgetLink wl = null;
        if (!_JTree_WidgetLinks.isSelectionEmpty()) {

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) _JTree_WidgetLinks
                    .getLastSelectedPathComponent();

            if (node == null) //Nothing is selected.  
            {
                return;
            }

            if (node.getParent() != null) {
                String s = node.getParent().toString() + "-" + node.getUserObject().toString();

                if (ws.containsKey(s)) {
                    wl = ws.get(s);
                    wc = widgetList.get(wl.getWidgetCodeName());
                }
            }
        }

        if (wc == null) {
            // No selected item on the JTree
            widgetCodeStr = _List_WidgetCodeList.getSelectedValue().toString();
            wc = widgetList.get(widgetCodeStr);
        } else {

            // Make sure the item selected matches the code in the widget link
            // This makes selecting 
            if (!wc.getWidgetName().equals(_List_WidgetCodeList.getSelectedValue().toString())) {

                widgetCodeStr = _List_WidgetCodeList.getSelectedValue().toString();
                wc = widgetList.get(widgetCodeStr);
            }

        }

        GridBagLayout gbl = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();

        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridx = 0;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 0;
        c.gridwidth = 1;
        c.gridheight = 1;
        c.ipadx = 0;
        c.ipady = 5;

        if (widgetCodeSettings == null) {
            widgetCodeSettings = new HashMap<>();
        } else {
            widgetCodeSettings.clear();
        }

        _Panel_WidgetSettings.removeAll();
        _Panel_WidgetSettings.setLayout(gbl);

        for (String name : wc.getVariables()) {
            JLabel label = new JLabel(name);
            label.setFont(new Font("Arial", Font.BOLD, 13));
            label.setHorizontalAlignment(SwingConstants.CENTER);
            JTextField textfield = new JTextField("");
            textfield.setHorizontalAlignment(SwingConstants.CENTER);
            if (wl != null) {
                textfield.setText(wl.getVariables().get(name));
            }

            textfield.setFont(new Font("Arial", Font.BOLD, 15));

            widgetCodeSettings.put(label.getText(), textfield);
            _Panel_WidgetSettings.add(label, c);
            c.gridy += 1;
            _Panel_WidgetSettings.add(textfield, c);
            c.gridy += 1;
        }

        _ScrollPane_WidgetSettings.revalidate();
        _ScrollPane_WidgetSettings.repaint();

    }

}

From source file:org.gtdfree.GTDFree.java

/**
 * This method initializes aboutDialog   
 *    //w  w  w . j  a va2s.  c  o m
 * @return javax.swing.JDialog
 */
private JDialog getAboutDialog() {
    if (aboutDialog == null) {
        aboutDialog = new JDialog(getJFrame(), true);
        aboutDialog.setTitle(Messages.getString("GTDFree.About.Free")); //$NON-NLS-1$
        Image i = ApplicationHelper.loadImage(ApplicationHelper.icon_name_large_logo); //$NON-NLS-1$
        ImageIcon ii = new ImageIcon(i);

        JTabbedPane jtp = new JTabbedPane();

        JPanel jp = new JPanel();
        jp.setLayout(new GridBagLayout());
        JLabel jl = new JLabel("GTD-Free", ii, SwingConstants.CENTER); //$NON-NLS-1$
        jl.setIconTextGap(22);
        jl.setFont(jl.getFont().deriveFont((float) 24));
        jp.add(jl, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 11), 0, 0));
        String s = "Version " + ApplicationHelper.getVersion(); //$NON-NLS-1$
        jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 1, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 11, 4, 11), 0, 0));
        s = Messages.getString("GTDFree.About.DBType") //$NON-NLS-1$
                + getEngine().getGTDModel().getDataRepository().getDatabaseType();
        jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 2, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 2, 11), 0, 0));
        s = Messages.getString("GTDFree.About.DBloc") + getEngine().getDataFolder(); //$NON-NLS-1$
        jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 3, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 11, 4, 11), 0, 0));
        jp.add(new JLabel("Copyright  2008,2009 ikesan@users.sourceforge.net", SwingConstants.CENTER), //$NON-NLS-1$
                new GridBagConstraints(0, 4, 1, 1, 1, 0, GridBagConstraints.CENTER,
                        GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 11), 0, 0));
        jtp.addTab("About", jp); //$NON-NLS-1$

        jp = new JPanel();
        jp.setLayout(new GridBagLayout());
        TableModel tm = new AbstractTableModel() {
            private static final long serialVersionUID = -8449423008172417278L;
            private String[] props;

            private String[] getProperties() {
                if (props == null) {
                    props = System.getProperties().keySet().toArray(new String[System.getProperties().size()]);
                    Arrays.sort(props);
                }
                return props;
            }

            @Override
            public String getColumnName(int column) {
                switch (column) {
                case 0:
                    return Messages.getString("GTDFree.About.Prop"); //$NON-NLS-1$
                case 1:
                    return Messages.getString("GTDFree.About.Val"); //$NON-NLS-1$
                default:
                    return null;
                }
            }

            public int getColumnCount() {
                return 2;
            }

            public int getRowCount() {
                return getProperties().length;
            }

            public Object getValueAt(int rowIndex, int columnIndex) {
                switch (columnIndex) {
                case 0:
                    return getProperties()[rowIndex];
                case 1:
                    return System.getProperty(getProperties()[rowIndex]);
                default:
                    return null;
                }
            }
        };
        JTable jt = new JTable(tm);
        jp.add(new JScrollPane(jt), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0));
        jtp.addTab(Messages.getString("GTDFree.About.SysP"), jp); //$NON-NLS-1$

        jp = new JPanel();
        jp.setLayout(new GridBagLayout());
        JTextArea ta = new JTextArea();
        ta.setEditable(false);
        ta.setText(ApplicationHelper.loadLicense());
        ta.setCaretPosition(0);
        jp.add(new JScrollPane(ta), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0));
        jtp.addTab("License", jp); //$NON-NLS-1$

        aboutDialog.setContentPane(jtp);
        aboutDialog.setSize(550, 300);
        //aboutDialog.pack();
        aboutDialog.setLocationRelativeTo(getJFrame());
    }
    return aboutDialog;
}

From source file:net.jradius.client.gui.JRadiusSimulator.java

/**
 * This method initializes openUrlContentPane   
 *    //  w ww . j a va2s  . c o  m
 * @return javax.swing.JPanel   
 */
private JPanel getOpenUrlContentPane() {
    if (openUrlContentPane == null) {
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.insets = new java.awt.Insets(25, 25, 10, 25);

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.insets = new java.awt.Insets(0, 25, 0, 5);
        gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 25);
        gridBagConstraints2.weightx = 1.0;

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints3.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints3.insets = new java.awt.Insets(0, 25, 25, 25);

        JLabel openUrlLabel = new JLabel();
        openUrlLabel.setText("URL:");

        openUrlStatusLabel = new JLabel();

        GridBagLayout gridBagLayout = new GridBagLayout();

        openUrlContentPane = new JPanel();
        openUrlContentPane.setLayout(gridBagLayout);

        JPanel buttonPanel = new JPanel();
        buttonPanel.add(getOpenUrlButton(), null);
        buttonPanel.add(getCancelUrlButton(), null);

        openUrlContentPane.add(openUrlStatusLabel, gridBagConstraints);
        openUrlContentPane.add(openUrlLabel, gridBagConstraints1);
        openUrlContentPane.add(getOpenUrlTextField(), gridBagConstraints2);
        openUrlContentPane.add(buttonPanel, gridBagConstraints3);
    }
    return openUrlContentPane;
}

From source file:base.BasePlayer.Main.java

void setButtons() {
    try {//from   www .  java2  s . c  o  m

        //      filemenu.setFont(font);
        GridBagConstraints c = new GridBagConstraints();

        c.anchor = GridBagConstraints.NORTHWEST;
        c.insets = new Insets(1, 4, 4, 2);
        //c.insets = new Insets(5, 5, 2, 5);
        c.gridx = 0;
        c.gridy = 0;
        c.gridwidth = 1;
        /*   opensamples.setMargin(new Insets(0, 0, 0,0));
                   
           opensamples.setPreferredSize(buttonDimension);
           addtracks.setMargin(new Insets(0, 0, 0, 0));
           addtracks.setPreferredSize(buttonDimension);
           addcontrols.setMargin(new Insets(0, 0, 0, 0));
           addcontrols.setPreferredSize(buttonDimension);
           */

        menubar.setOpaque(true);
        panel.add(menubar, c);
        c.gridx = 1;

        setbut = new JButton("", settingsIcon);
        setbut.setToolTipText("Settings");

        setbut.setOpaque(false);
        setbut.setContentAreaFilled(false);
        setbut.setBackground(Main.panel.getBackground());
        setbut.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                Settings.frame.setLocation(
                        frame.getLocationOnScreen().x + frame.getWidth() / 2 - Settings.frame.getWidth() / 2,
                        frame.getLocationOnScreen().y + frame.getHeight() / 6);
                Settings.frame.setState(JFrame.NORMAL);
                Settings.frame.setVisible(true);
            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {
                setbut.setOpaque(true);
                Main.setbut.setBackground(Color.white);
                Main.setbut.revalidate();
            }

            @Override
            public void mouseExited(MouseEvent e) {
                setbut.setOpaque(false);
                Main.setbut.revalidate();
            }

        });
        setbut.setBorder(null);
        c.insets = new Insets(0, 2, 0, 0);
        menubar.add(setbut, c);
        //   c.gridx = 1;
        //   c.gridx = 2;      
        //   c.gridx = 3;      

        //      zoomout.setMargin(new Insets(0, 0, 0, 0));
        //   panel.add(zoomout, c);      

        /*   JMenuItem empty2 = new JMenuItem("");
           empty2.setEnabled(false);      
           menubar.add(empty2);
                  
            c.gridx = 4;*/
        //  chromosomeDropdown.setPreferredSize(buttonDimension);

        // panel.add(chromosomeDropdown, c);
        //       c.gridx = 5;

        //  back.setMargin(new Insets(0, 0, 0, 0));
        // forward.setMargin(new Insets(0, 0, 0, 0));
        // back.setPreferredSize(new Dimension(back.getFontMetrics(back.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight()));
        //    forward.setPreferredSize(new Dimension(forward.getFontMetrics(forward.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight()));
        //back.setMinimumSize(new Dimension(back.getFontMetrics(back.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight()));
        //    forward.setMinimumSize(new Dimension(forward.getFontMetrics(forward.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight()));
        //    panel.add(back, c);
        //       c.gridx = 7;
        //   panel.add(forward, c);

        chromosomeDropdown.setMaximumRowCount(25);
        chromosomeDropdown.setEnabled(true);
        chromosomeDropdown.addActionListener(ChromoDropActionListener);
        chromosomeDropdown.addMouseListener(this);

        c.gridwidth = 10;
        c.gridx = 0;
        c.gridy = 1;
        bedScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        bedScroll.getViewport().setPreferredSize(bedDimensions);

        drawScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        drawScroll.getViewport().setPreferredSize(drawDimensions);

        chromScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        chromScroll.getViewport().setPreferredSize(chromDimensions);

        drawScroll.getVerticalScrollBar().setAutoscrolls(false);
        //       chromScroll.getViewport().setPreferredSize(new Dimension(drawWidth,chromHeight-20));

        //    drawScroll.setBorder(BorderFactory.createEmptyBorder());
        //chromScroll.setBorder(BorderFactory.createLoweredBevelBorder());
        //    drawScroll.setBorder(BorderFactory.createLoweredBevelBorder());
        //    bedScroll.setBorder(BorderFactory.createLoweredBevelBorder());

        //   chromScroll.setBorder(BorderFactory.createEmptyBorder());

        //       bedScroll.setBorder(BorderFactory.createEmptyBorder());

        controlScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        controlScroll.getViewport().setPreferredSize(bedDimensions);
        controlScroll.getViewport().add(controlDraw);
        controlDraw.setVisible(false);
        controlScroll.setVisible(false);

        chromScroll.setBorder(BorderFactory.createEmptyBorder());
        drawScroll.setBorder(BorderFactory.createEmptyBorder());
        bedScroll.setBorder(BorderFactory.createLoweredBevelBorder());
        controlScroll.setBorder(BorderFactory.createLoweredBevelBorder());

        addSplit(chromosomeDropdown.getItemAt(0));

        chromScroll.getViewport().add(chromDraw);
        drawScroll.getViewport().add(drawCanvas);
        drawScroll.addMouseListener(this);
        bedCanvas = new BedCanvas(drawWidth, 200);

        bedScroll.getViewport().add(bedCanvas);

        frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);

        c.weightx = 1.0;
        c.weighty = 1.0;
        c.fill = GridBagConstraints.BOTH;

        trackPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, bedScroll, controlScroll);
        trackPane.setUI(new BasicSplitPaneUI() {
            public BasicSplitPaneDivider createDefaultDivider() {
                return new BasicSplitPaneDivider(this) {

                    private static final long serialVersionUID = 1L;

                    public void setBorder(Border b) {
                    }

                    @Override
                    public void paint(Graphics g) {
                        g.setColor(Color.lightGray);
                        g.fillRect(0, 0, getSize().width, getSize().height);
                        super.paint(g);
                    }
                };
            }
        });
        trackPane.setBorder(null);

        trackPane.setDividerSize(0);
        trackPane.setPreferredSize(drawDimensions);
        trackPane.setResizeWeight(0.0);
        trackPane.setContinuousLayout(true);
        trackPane.setVisible(false);

        varpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, trackPane, drawScroll);
        varpane.setUI(new BasicSplitPaneUI() {
            public BasicSplitPaneDivider createDefaultDivider() {
                return new BasicSplitPaneDivider(this) {

                    private static final long serialVersionUID = 1L;

                    public void setBorder(Border b) {
                    }

                    @Override
                    public void paint(Graphics g) {
                        g.setColor(Color.lightGray);
                        g.fillRect(0, 0, getSize().width, getSize().height);
                        super.paint(g);
                    }
                };
            }
        });
        varpane.setBorder(null);

        varpane.setDividerSize(0);
        varpane.setPreferredSize(drawDimensions);
        varpane.setResizeWeight(0.0);
        varpane.setContinuousLayout(true);
        bedScroll.setVisible(false);

        controlScroll.setVisible(false);

        chrompan = new JPanel() {
            private static final long serialVersionUID = 1L;

            protected void paintComponent(Graphics g) {

                super.paintComponent(g);
                g.setColor(Draw.sidecolor);
                g.fillRect(0, 0, this.getWidth(), this.getHeight());

                g.setColor(Color.gray);
                g.fillRect(0, 0, 3, this.getHeight());
                g.setColor(Color.lightGray);
                g.fillRect(2, 0, 2, this.getHeight());

            }

        };
        chrompan.setLayout(new GridBagLayout());
        GridBagConstraints gb = new GridBagConstraints();
        gb.anchor = GridBagConstraints.NORTHWEST;

        gb.insets = new Insets(2, 10, 2, 2);
        gb.gridx = 0;
        gb.gridy = 0;
        gb.gridwidth = 1;
        gb.fill = GridBagConstraints.HORIZONTAL;
        refDropdown.setBackground(Color.white);
        refDropdown.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray));
        refDropdown.setBorder(BorderFactory.createCompoundBorder(refDropdown.getBorder(),
                BorderFactory.createEmptyBorder(0, 0, 0, 0)));
        geneDropdown.setBackground(Color.white);
        geneDropdown.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray));
        geneDropdown.setBorder(BorderFactory.createCompoundBorder(geneDropdown.getBorder(),
                BorderFactory.createEmptyBorder(0, 0, 0, 0)));
        geneDropdown.addActionListener(annoDropActionListener);
        JLabel refLabel = new JLabel("Reference genome:");

        JLabel geneLabel = new JLabel("Gene annotation:");
        chromLabel.setName("header");
        chrompan.add(chromLabel, gb);
        gb.gridy++;
        chrompan.add(new JSeparator(), gb);
        gb.gridy++;
        gb.insets = new Insets(0, 10, 0, 2);
        chrompan.add(refLabel, gb);
        gb.gridy++;
        chrompan.add(refDropdown, gb);
        gb.gridy++;
        chrompan.add(geneLabel, gb);
        gb.gridy++;
        chrompan.add(geneDropdown, gb);
        gb.gridy++;
        gb.insets = new Insets(20, 10, 0, 2);
        JLabel memory = new JLabel("Memory usage:");
        memory.setName("header");
        chrompan.add(memory, gb);
        gb.insets = new Insets(0, 10, 0, 2);
        gb.gridy++;
        chrompan.add(memLabel, gb);
        gb.weightx = 1;
        gb.weighty = 1;
        gb.gridwidth = GridBagConstraints.REMAINDER;
        chrompan.add(new JLabel(), gb);
        chrompan.setMinimumSize(new Dimension(1, 1));
        chrompan.addComponentListener(this);
        upPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chrompan, chromScroll);
        drawScroll.addComponentListener(this);
        //upPanel.setBorder(BorderFactory.createLoweredBevelBorder());
        upPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white));
        upPanel.setDividerLocation(Main.sidebarWidth - 2);
        chrompan.setBackground(Draw.sidecolor);
        BasicSplitPaneUI chromPaneUI = (BasicSplitPaneUI) upPanel.getUI();
        chromPaneDivider = chromPaneUI.getDivider();
        chromPaneDivider.addMouseListener(this);

        upPanel.setDividerSize(3);

        upPanel.setUI(new BasicSplitPaneUI() {
            public BasicSplitPaneDivider createDefaultDivider() {
                return new BasicSplitPaneDivider(this) {

                    private static final long serialVersionUID = 1L;

                    public void setBorder(Border b) {
                    }

                    @Override
                    public void paint(Graphics g) {
                        g.setColor(Color.lightGray);
                        g.fillRect(0, 0, getSize().width, getSize().height);

                        super.paint(g);
                    }
                };
            }
        });

        splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upPanel, varpane);

        splitPane.setUI(new BasicSplitPaneUI() {
            public BasicSplitPaneDivider createDefaultDivider() {
                return new BasicSplitPaneDivider(this) {

                    private static final long serialVersionUID = 1L;

                    public void setBorder(Border b) {
                    }

                    @Override
                    public void paint(Graphics g) {
                        g.setColor(Color.lightGray);
                        g.fillRect(0, 0, getSize().width, getSize().height);

                        super.paint(g);
                    }
                };
            }
        });

        BasicSplitPaneUI basicSplitPaneUI = (BasicSplitPaneUI) splitPane.getUI();
        splitPaneDivider = basicSplitPaneUI.getDivider();
        //    splitPaneDivider.addMouseListener(this);
        basicSplitPaneUI = (BasicSplitPaneUI) trackPane.getUI();
        trackPaneDivider = basicSplitPaneUI.getDivider();
        //    trackPaneDivider.addMouseListener(this);
        BasicSplitPaneUI splitPaneUI = (BasicSplitPaneUI) varpane.getUI();
        varPaneDivider = splitPaneUI.getDivider();
        //   varPaneDivider.addMouseListener(this);
        splitPane.setDividerSize(3);

        splitPane.setPreferredSize(drawDimensions);
        splitPane.setContinuousLayout(true);

        panel.add(splitPane, c);
        add(panel, c);

        openvcfs.addActionListener(this);
        openbams.addActionListener(this);
        addtracks.addActionListener(this);
        addcontrols.addActionListener(this);

        openProject.addActionListener(this);
        saveProject.addActionListener(this);
        saveProjectAs.addActionListener(this);
        dosomething.addActionListener(this);
        clear.addActionListener(this);
        //    drawScroll.getVerticalScrollBar().addMouseMotionListener(this);
        drawScroll.getVerticalScrollBar().addMouseListener(this);
        drawScroll.getVerticalScrollBar().addMouseMotionListener(this);
        drawScroll.getVerticalScrollBar().addMouseWheelListener(new MouseWheelListener() {
            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                Draw.setGlasspane(true);
                if (e.getWheelRotation() < 0) {
                    if (drawCanvas.drawVariables.visiblestart > 0) {
                        drawCanvas.drawVariables.visiblestart--;

                    }
                    Draw.setScrollbar((int) (drawCanvas.drawVariables.visiblestart
                            * drawCanvas.drawVariables.sampleHeight));
                } else {
                    if (drawCanvas.drawVariables.visiblestart
                            + drawCanvas.drawVariables.visiblesamples < Main.samples) {
                        drawCanvas.drawVariables.visiblestart++;

                    }
                    Draw.setScrollbar((int) (drawCanvas.drawVariables.visiblestart
                            * drawCanvas.drawVariables.sampleHeight));
                }

            }

        }

        );
        drawScroll.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent event) {

                //System.out.println(drawCanvas.drawVariables.visiblestart +" " +(short)(Main.drawScroll.getVerticalScrollBar().getValue()/drawCanvas.drawVariables.sampleHeight));
                if (drawCanvas.drawVariables.visiblestart != (short) (Main.drawScroll.getVerticalScrollBar()
                        .getValue() / drawCanvas.drawVariables.sampleHeight)) {
                    if (!drawCanvas.sidebar) {
                        drawCanvas.drawVariables.visiblestart = (short) (Main.drawScroll.getVerticalScrollBar()
                                .getValue() / drawCanvas.drawVariables.sampleHeight);
                    }
                    if (drawCanvas.splits.size() > 1) {
                        for (int i = 0; i < drawCanvas.splits.size(); i++) {
                            drawCanvas.splits.get(i).updateReads = true;
                        }
                    } else {
                        Draw.updateReads = true;
                        Draw.updatevars = true;
                    }

                    Draw.updatevars = true;
                    Main.drawCanvas.repaint();
                }

            }

        });

        zoomout.addActionListener(this);

        FileRead.head = new VarNode(0, (byte) 0, "N", (short) 0, (short) 0, false, (float) 0, (float) 0, null,
                null, new Sample("", (short) 1, null), null, null);
        drawCanvas.current = FileRead.head;

        frame.addComponentListener(this);
        frame.addMouseListener(this);
        frame.setGlassPane(glassPane);
        glassPane.setOpaque(false);
        glassPane.setVisible(false);

        positionField.setText("chr1:1-" + MethodLibrary.formatNumber(drawCanvas.splits.get(0).chromEnd));
        positionField.setToolTipText("Current chromosomal region");
        widthLabel.setText(MethodLibrary.formatNumber(drawCanvas.splits.get(0).chromEnd) + "bp");
        widthLabel.setToolTipText("Current region width in base pairs");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:simMPLS.ui.simulator.JVentanaHija.java

private void crearEInsertarGraficas(String nombre) {
    GridBagConstraints gbc = null;
    this.panelAnalisis.removeAll();
    this.etiquetaEstadisticasTituloEscenario.setText(this.nombreEscenario.getText());
    this.etiquetaEstadisticasNombreAutor.setText(this.nombreAutor.getText());
    this.areaEstadisticasDescripcion.setText(this.descripcionEscenario.getText());
    this.etiquetaNombreElementoEstadistica.setText(nombre);
    TNode nt = this.escenario.getTopology().setFirstNodeNamed(nombre);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;/*from w  w  w. j a v  a2s.c  o m*/
    gbc.gridy = 0;
    gbc.insets = new Insets(10, 10, 10, 5);
    gbc.anchor = java.awt.GridBagConstraints.NORTH;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    this.panelFijo.add(this.etiquetaEstadisticasTituloEscenario, gbc);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.insets = new Insets(10, 5, 10, 5);
    gbc.anchor = java.awt.GridBagConstraints.NORTH;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    this.panelFijo.add(this.etiquetaEstadisticasNombreAutor, gbc);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.insets = new Insets(10, 5, 10, 5);
    gbc.anchor = java.awt.GridBagConstraints.NORTH;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    this.panelFijo.add(this.areaEstadisticasDescripcion, gbc);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.insets = new Insets(10, 5, 10, 5);
    gbc.anchor = java.awt.GridBagConstraints.NORTH;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    this.panelFijo.add(this.etiquetaNombreElementoEstadistica, gbc);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(10, 10, 10, 5);
    gbc.anchor = java.awt.GridBagConstraints.NORTH;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    this.panelAnalisis.add(this.panelFijo, gbc);
    if (nt != null) {
        if (nt.getNodeType() == TNode.SENDER) {
            this.etiquetaNombreElementoEstadistica
                    .setIcon(this.dispensadorDeImagenes.obtenerIcono(TImagesBroker.EMISOR));
        } else if (nt.getNodeType() == TNode.RECEIVER) {
            this.etiquetaNombreElementoEstadistica
                    .setIcon(this.dispensadorDeImagenes.obtenerIcono(TImagesBroker.RECEPTOR));
        } else if (nt.getNodeType() == TNode.LER) {
            this.etiquetaNombreElementoEstadistica
                    .setIcon(this.dispensadorDeImagenes.obtenerIcono(TImagesBroker.LER));
        } else if (nt.getNodeType() == TNode.LERA) {
            this.etiquetaNombreElementoEstadistica
                    .setIcon(this.dispensadorDeImagenes.obtenerIcono(TImagesBroker.LERA));
        } else if (nt.getNodeType() == TNode.LSR) {
            this.etiquetaNombreElementoEstadistica
                    .setIcon(this.dispensadorDeImagenes.obtenerIcono(TImagesBroker.LSR));
        } else if (nt.getNodeType() == TNode.LSRA) {
            this.etiquetaNombreElementoEstadistica
                    .setIcon(this.dispensadorDeImagenes.obtenerIcono(TImagesBroker.LSRA));
        }

        int numeroGraficos = nt.getStats().obtenerNumeroGraficas();

        if (numeroGraficos > 0) {
            grafico1 = ChartFactory.createXYLineChart(nt.getStats().obtenerTitulo1(), TStats.TIEMPO,
                    TStats.NUMERO_DE_PAQUETES, (XYSeriesCollection) nt.getStats().obtenerDatosGrafica1(),
                    PlotOrientation.VERTICAL, true, true, true);

            grafico1.getPlot().setBackgroundPaint(Color.WHITE);
            grafico1.getPlot().setForegroundAlpha((float) 0.5);
            grafico1.getPlot().setOutlinePaint(new Color(14, 69, 125));
            grafico1.getXYPlot().setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5, 5, 5, 5));
            grafico1.setBackgroundPaint(new Color(210, 226, 242));
            grafico1.setBorderPaint(Color.BLACK);
            grafico1.getTitle().setPaint(new Color(79, 138, 198));
            this.panelGrafico1 = new ChartPanel(grafico1);
            panelGrafico1.setBorder(new LineBorder(Color.BLACK));
            panelGrafico1.setPreferredSize(new Dimension(600, 300));
            gbc = new java.awt.GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = 1;
            gbc.insets = new Insets(10, 5, 10, 5);
            gbc.anchor = java.awt.GridBagConstraints.NORTH;
            gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
            this.panelAnalisis.add(panelGrafico1, gbc);
        }
        if (numeroGraficos > 1) {
            grafico2 = ChartFactory.createXYLineChart(nt.getStats().obtenerTitulo2(), TStats.TIEMPO,
                    TStats.NUMERO_DE_PAQUETES, (XYSeriesCollection) nt.getStats().obtenerDatosGrafica2(),
                    PlotOrientation.VERTICAL, true, true, true);
            grafico2.getPlot().setBackgroundPaint(Color.WHITE);
            grafico2.getPlot().setForegroundAlpha((float) 0.5);
            grafico2.getPlot().setOutlinePaint(new Color(14, 69, 125));
            grafico2.getXYPlot().setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5, 5, 5, 5));
            grafico2.setBackgroundPaint(new Color(210, 226, 242));
            grafico2.setBorderPaint(Color.BLACK);
            grafico2.getTitle().setPaint(new Color(79, 138, 198));
            this.panelGrafico2 = new ChartPanel(grafico2);
            panelGrafico2.setPreferredSize(new Dimension(600, 300));
            panelGrafico2.setBorder(new LineBorder(Color.BLACK));
            gbc = new java.awt.GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = 2;
            gbc.insets = new Insets(10, 5, 10, 5);
            gbc.anchor = java.awt.GridBagConstraints.NORTH;
            gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
            this.panelAnalisis.add(panelGrafico2, gbc);
        }
        if (numeroGraficos > 2) {
            grafico3 = ChartFactory.createXYLineChart(nt.getStats().obtenerTitulo3(), TStats.TIEMPO,
                    TStats.NUMERO_DE_PAQUETES, (XYSeriesCollection) nt.getStats().obtenerDatosGrafica3(),
                    PlotOrientation.VERTICAL, true, true, true);
            grafico3.getPlot().setBackgroundPaint(Color.WHITE);
            grafico3.getPlot().setForegroundAlpha((float) 0.5);
            grafico3.getPlot().setOutlinePaint(new Color(14, 69, 125));
            grafico3.getXYPlot().setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5, 5, 5, 5));
            grafico3.setBackgroundPaint(new Color(210, 226, 242));
            grafico3.setBorderPaint(Color.BLACK);
            grafico3.getTitle().setPaint(new Color(79, 138, 198));
            this.panelGrafico3 = new ChartPanel(grafico3);
            panelGrafico3.setBorder(new LineBorder(Color.BLACK));
            panelGrafico3.setPreferredSize(new Dimension(600, 300));
            gbc = new java.awt.GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = 3;
            gbc.insets = new Insets(10, 5, 10, 5);
            gbc.anchor = java.awt.GridBagConstraints.NORTH;
            gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
            this.panelAnalisis.add(panelGrafico3, gbc);
        }
        if (numeroGraficos > 3) {
            grafico4 = ChartFactory.createBarChart(nt.getStats().obtenerTitulo4(), TStats.DESCRIPCION,
                    TStats.NUMERO, (DefaultCategoryDataset) nt.getStats().obtenerDatosGrafica4(),
                    PlotOrientation.VERTICAL, true, true, true);
            grafico4.getPlot().setBackgroundPaint(Color.WHITE);
            grafico4.getPlot().setForegroundAlpha((float) 0.5);
            grafico4.getPlot().setOutlinePaint(new Color(14, 69, 125));
            grafico4.setBackgroundPaint(new Color(210, 226, 242));
            grafico4.setBorderPaint(Color.BLACK);
            grafico4.getTitle().setPaint(new Color(79, 138, 198));
            this.panelGrafico4 = new ChartPanel(grafico4);
            panelGrafico4.setBorder(new LineBorder(Color.BLACK));
            panelGrafico4.setPreferredSize(new Dimension(600, 300));
            gbc = new java.awt.GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = 4;
            gbc.insets = new Insets(10, 5, 10, 5);
            gbc.anchor = java.awt.GridBagConstraints.NORTH;
            gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
            this.panelAnalisis.add(panelGrafico4, gbc);
        }
        if (numeroGraficos > 4) {
            grafico5 = ChartFactory.createBarChart(nt.getStats().obtenerTitulo5(), TStats.DESCRIPCION,
                    TStats.NUMERO, (DefaultCategoryDataset) nt.getStats().obtenerDatosGrafica5(),
                    PlotOrientation.VERTICAL, true, true, true);
            grafico5.getPlot().setBackgroundPaint(Color.WHITE);
            grafico5.getPlot().setForegroundAlpha((float) 0.5);
            grafico5.getPlot().setOutlinePaint(new Color(14, 69, 125));
            grafico5.setBackgroundPaint(new Color(210, 226, 242));
            grafico5.setBorderPaint(Color.BLACK);
            grafico5.getTitle().setPaint(new Color(79, 138, 198));
            this.panelGrafico5 = new ChartPanel(grafico5);
            panelGrafico5.setBorder(new LineBorder(Color.BLACK));
            panelGrafico5.setPreferredSize(new Dimension(600, 300));
            gbc = new java.awt.GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = 5;
            gbc.insets = new Insets(10, 5, 10, 5);
            gbc.anchor = java.awt.GridBagConstraints.NORTH;
            gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
            this.panelAnalisis.add(panelGrafico5, gbc);
        }
        if (numeroGraficos > 5) {
            grafico6 = ChartFactory.createXYLineChart(nt.getStats().obtenerTitulo6(), TStats.TIEMPO,
                    TStats.NUMERO_DE_PAQUETES, (XYSeriesCollection) nt.getStats().obtenerDatosGrafica6(),
                    PlotOrientation.VERTICAL, true, true, true);
            grafico6.getPlot().setBackgroundPaint(Color.WHITE);
            grafico6.getPlot().setForegroundAlpha((float) 0.5);
            grafico6.getPlot().setOutlinePaint(new Color(14, 69, 125));
            grafico6.getXYPlot().setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5, 5, 5, 5));
            grafico6.setBackgroundPaint(new Color(210, 226, 242));
            grafico6.setBorderPaint(Color.BLACK);
            grafico6.getTitle().setPaint(new Color(79, 138, 198));
            this.panelGrafico6 = new ChartPanel(grafico6);
            panelGrafico6.setBorder(new LineBorder(Color.BLACK));
            panelGrafico6.setPreferredSize(new Dimension(600, 300));
            gbc = new java.awt.GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = 6;
            gbc.insets = new Insets(10, 5, 10, 10);
            gbc.anchor = java.awt.GridBagConstraints.NORTH;
            gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
            this.panelAnalisis.add(panelGrafico6, gbc);
        }
    }
    this.panelAnalisis.repaint();
}

From source file:interfaces.InterfazPrincipal.java

private void TablaDeProductosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TablaDeProductosMouseClicked
    // TODO add your handling code here:
    int fila = TablaDeProductos.getSelectedRow();
    final int identificacion = (int) TablaDeProductos.getValueAt(fila, 1);

    final ControladorProducto controladorP = new ControladorProducto();
    ArrayList<Productos> listaProductos = controladorP.getProducto(" where producto_id = " + identificacion);
    final Productos productoActual = listaProductos.get(0);

    final JDialog dialogoEditar = new JDialog(this);

    dialogoEditar.setTitle("Editar clientes");
    dialogoEditar.setSize(600, 310);/*  ww w  . ja  va  2 s  .  co m*/
    dialogoEditar.setResizable(false);

    JPanel panelDialogo = new JPanel();

    panelDialogo.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel editarTextoPrincipalDialogo = new JLabel("Editar producto");
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 4;
    c.insets = new Insets(15, 200, 40, 0);
    c.ipadx = 100;
    Font textoGrande = new Font("Arial", 1, 18);
    editarTextoPrincipalDialogo.setFont(textoGrande);
    panelDialogo.add(editarTextoPrincipalDialogo, c);

    c.insets = new Insets(0, 5, 10, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 40;
    JLabel editarNombreClienteDialogo = new JLabel("Nombre:");
    panelDialogo.add(editarNombreClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);
    final JTextField valorEditarNombreClienteDialogo = new JTextField();
    valorEditarNombreClienteDialogo.setText(productoActual.getNombre());
    panelDialogo.add(valorEditarNombreClienteDialogo, c);

    final JTextField valorEditarUnidadesProductoDialogo = new JTextField();
    valorEditarUnidadesProductoDialogo.setText(String.valueOf(productoActual.getUnidadesDisponibles()));
    panelDialogo.add(valorEditarUnidadesProductoDialogo, c);

    c.gridx = 2;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 15, 10, 0);
    JLabel editarTelefonoClienteDialogo = new JLabel("Precio");
    panelDialogo.add(editarTelefonoClienteDialogo, c);

    c.gridx = 3;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 0, 10, 0);

    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarCelularClienteDialogo = new JLabel("Descripcion:");
    panelDialogo.add(editarCelularClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);

    final JTextField valorEditarDescripcionProductoDialogo = new JTextField();
    valorEditarDescripcionProductoDialogo.setText(productoActual.getDescripcion());
    panelDialogo.add(valorEditarDescripcionProductoDialogo, c);
    c.gridx = 2;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarMontoClienteDialogo = new JLabel("Unidades");
    panelDialogo.add(editarMontoClienteDialogo, c);

    c.gridx = 3;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);

    final JTextField valorEditarPrecioProductoDialogo = new JTextField();
    valorEditarPrecioProductoDialogo.setText(productoActual.getPrecio() + "");
    panelDialogo.add(valorEditarPrecioProductoDialogo, c);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarCodigoBarrasProyecto = new JLabel("Cdigo de barras:");
    panelDialogo.add(editarCodigoBarrasProyecto, c);

    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);

    final JTextField valorCodigoDeBarras = new JTextField();
    valorCodigoDeBarras.setText(productoActual.getCodigoBarras());
    panelDialogo.add(valorCodigoDeBarras, c);

    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.ipadx = 100;
    c.insets = new Insets(15, 40, 0, 0);
    JButton botonGuardarProductoDialogo = new JButton("Guardar");
    panelDialogo.add(botonGuardarProductoDialogo, c);

    c.gridx = 2;
    c.gridy = 4;
    c.gridwidth = 2;
    c.insets = new Insets(15, 40, 0, 0);
    c.ipadx = 100;

    JButton botonCerrarProductoDialogo = new JButton("Cancelar");
    panelDialogo.add(botonCerrarProductoDialogo, c);

    dialogoEditar.add(panelDialogo);

    botonCerrarProductoDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialogoEditar.dispose();
        }
    });

    botonGuardarProductoDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {

                String[] selection = { "nombre", "descripcion", "unidades", "precio", "codigoBarras" };
                String[] value = { valorEditarNombreClienteDialogo.getText(),
                        valorEditarDescripcionProductoDialogo.getText(),
                        valorEditarUnidadesProductoDialogo.getText(),
                        valorEditarPrecioProductoDialogo.getText(), valorCodigoDeBarras.getText() };
                String[] type_value = { "varchar", "varchar", "int", "double", "varchar" };
                String restriction = " where producto_id = " + identificacion;
                controladorP.updateProduct(selection, value, type_value, restriction);
                JOptionPane.showMessageDialog(dialogoEditar, "Se ha editado el producto xitosamente");
                dialogoEditar.dispose();

                //Refrescar busqueda actual
                jButton2ActionPerformed(null);

            } catch (Exception event) {

                JOptionPane.showMessageDialog(dialogoEditar, "El valor del monto debe ser numrico");

            }

        }
    });

    dialogoEditar.setVisible(true);
}