Example usage for java.awt Insets Insets

List of usage examples for java.awt Insets Insets

Introduction

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

Prototype

public Insets(int top, int left, int bottom, int right) 

Source Link

Document

Creates and initializes a new Insets object with the specified top, left, bottom, and right insets.

Usage

From source file:coolmap.canvas.datarenderer.renderer.impl.NumberToColor.java

public NumberToColor() {
    setName("Number to Color");
    setDescription("Use color to represent numeric values");

    //initialize UI
    configUI.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;//from   w  ww. j a v  a 2  s  .  co  m
    c.gridy = 0;
    c.ipadx = 5;
    c.ipady = 5;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 2;
    //        c.weightx = 0.8;

    editor = new GradientEditorPanel();
    configUI.add(editor, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    //        JButton button = new JButton("Apply");
    //        configUI.add(button, c);
    //        button.setToolTipText("Apply preset gradient");
    //
    //        button.addActionListener(new ActionListener() {
    //
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //
    //                try {
    //                    GradientItem item = (GradientItem) presetColorComboBox.getSelectedItem();
    //
    //                    editor.clearColors();
    //
    //                    Color c[] = item.getColors();
    //                    float p[] = item.getPositions();
    //
    //                    editor.setStart(c[0]);
    //                    editor.setEnd(c[c.length - 1]);
    //
    //                    if (c.length > 2) {
    //                        for (int i = 1; i < c.length - 1; i++) {
    //                            editor.addColor(c[i], p[i]);
    //                        }
    //                    }
    //
    //                } catch (Exception ex) {
    //                    editor.clearColors();
    //                    editor.setStart(DEFAULT_MIN_COLOR);
    //                    editor.setEnd(DEFAULT_MAX_COLOR);
    //                }
    //
    //                updateRenderer();
    //            }
    //        });
    configUI.add(new JLabel("Preset palette:"), c);

    c.gridx = 1;
    c.gridwidth = 1;
    presetColorComboBox = new JComboBox();

    presetColorComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {

            try {
                GradientItem item = (GradientItem) presetColorComboBox.getSelectedItem();
                presetColorComboBox.setToolTipText(item.getToolTip());

                editor.clearColors();

                Color c[] = item.getColors();
                float p[] = item.getPositions();

                editor.setStart(c[0]);
                editor.setEnd(c[c.length - 1]);

                if (c.length > 2) {
                    for (int i = 1; i < c.length - 1; i++) {
                        editor.addColor(c[i], p[i]);
                    }
                }

                try {
                    Double[] ranges = item.getRanges();
                    if (ranges != null) {
                        minValueField.setText(ranges[0].toString());
                        maxValueField.setText(ranges[1].toString());
                        editor.setMinValue(ranges[0].floatValue());
                        editor.setMaxValue(ranges[1].floatValue());
                    }
                } catch (Exception ex) {
                    minValueField.setText("-1");
                    maxValueField.setText("1");
                    editor.setMinValue(-1);
                    editor.setMaxValue(1);
                }

            } catch (Exception ex) {
                editor.clearColors();
                editor.setStart(DEFAULT_MIN_COLOR);
                editor.setEnd(DEFAULT_MAX_COLOR);
            }
        }
    });

    //       
    configUI.add(presetColorComboBox, c);
    presetColorComboBox.setRenderer(new GradientComboItemRenderer());

    presetColorComboBox
            .addItem(new GradientItem(new Color[] { DEFAULT_MIN_COLOR, Color.BLACK, DEFAULT_MAX_COLOR },
                    new float[] { 0f, 0.5f, 1f }, "TBP", "Teal - Black - Pink"));

    presetColorComboBox.addItem(new GradientItem(new Color[] { Color.GREEN, Color.RED }, new float[] { 0f, 1f },
            "GR", "Green - Red"));

    presetColorComboBox.addItem(new GradientItem(new Color[] { Color.GREEN, Color.BLACK, Color.RED },
            new float[] { 0f, 0.5f, 1f }, "RBG", "Red - Black - Green"));

    presetColorComboBox.addItem(new GradientItem(new Color[] { Color.ORANGE, Color.BLUE },
            new float[] { 0f, 1f }, "OB", "Orange - Blue"));

    presetColorComboBox.addItem(new GradientItem(new Color[] { Color.ORANGE, Color.BLACK, Color.BLUE },
            new float[] { 0f, 0.5f, 1f }, "OBB", "Orange - Black - Blue"));

    presetColorComboBox.addItem(new GradientItem(new Color[] { Color.BLACK, Color.GREEN },
            new float[] { 0f, 1f }, "BG", "Black - Green"));

    presetColorComboBox
            .addItem(new GradientItem(new Color[] { Color.RED, UI.colorAKABENI, Color.BLACK, Color.BLACK },
                    new float[] { 0f, 0.05f, 0.051f, 1f }, "P.05", 0d, 1d, "P-value @ 0.05, Red to Black"));

    presetColorComboBox.setToolTipText(((GradientItem) presetColorComboBox.getSelectedItem()).getToolTip());

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    //        button = new JButton("Apply");
    //        
    //        button.setToolTipText("Apply preset data ranges");
    //        button.addActionListener(new ActionListener() {
    //
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //                try {
    //                    MinMaxItem item = (MinMaxItem) (presetRangeComboBox.getSelectedItem());
    //                    minValueField.setText(item.getMinMax().lowerEndpoint().toString());
    //                    maxValueField.setText(item.getMinMax().upperEndpoint().toString());
    //                } catch (Exception ex) {
    //                    minValueField.setText("-1");
    //                    maxValueField.setText("1");
    //                }
    //
    //                updateRenderer();
    //            }
    //        });
    //        configUI.add(button, c);
    configUI.add(new JLabel("Preset range:"), c);

    c.gridx = 1;
    c.gridwidth = 1;
    presetRangeComboBox = new JComboBox();
    configUI.add(presetRangeComboBox, c);
    presetRangeComboBox.addItem(new DataMinMaxItem());
    presetRangeComboBox.addItem(new DefinedMinMaxItem(-1, 1));
    presetRangeComboBox.addItem(new DefinedMinMaxItem(0, 1));
    presetRangeComboBox.addItem(new DefinedMinMaxItem(-1, 0));
    presetRangeComboBox.addItem(new DefinedMinMaxItem(0, 100));

    presetRangeComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            try {
                MinMaxItem item = (MinMaxItem) (presetRangeComboBox.getSelectedItem());
                minValueField.setText(item.getMinMax().lowerEndpoint().toString());
                maxValueField.setText(item.getMinMax().upperEndpoint().toString());
            } catch (Exception ex) {
                minValueField.setText("-1");
                maxValueField.setText("1");
            }
        }
    });

    ////////////////////////////////////////////////////////////////////////////////
    //        c.weightx = 0.2;
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(new JLabel("Min value: "), c);
    c.gridx = 1;
    //        c.weightx = 0.3;
    configUI.add(minValueField, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(new JLabel("Max value: "), c);
    c.gridx = 1;
    configUI.add(maxValueField, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    JLabel label = Tools.createJLabel("Draw Sub-heatmap:", null,
            "Draw sub-heatmaps for collapsed ontology nodes", null);
    configUI.add(label, c);

    c.gridx = 1;
    drawSubMap = new JCheckBox();
    configUI.add(drawSubMap, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 3;

    JButton button = new JButton("Update", UI.getImageIcon("refresh"));
    configUI.add(button, c);
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //hit button, redraw!

            updateRenderer();
        }
    });

    //        editor.applyButton.addActionListener(new ActionListener() {
    //
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //                updateRenderer();
    //            }
    //        });
    toolTipLabel = new JLabel();
    toolTipLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    toolTipLabel.setBackground(UI.colorGrey3);
    toolTipLabel.setOpaque(true);
    toolTipLabel.setForeground(UI.colorBlack2);
    toolTipLabel.setFont(UI.fontPlain.deriveFont(12f));
}

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

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

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

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

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

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

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

    return (c);
}

From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanelHeader.java

/**
 * Create the panel./*w w w . j a  va  2  s .  c  o  m*/
 */
public Hl7ConnectionPanelHeader() {
    setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Outbound Message Sender",
            TitledBorder.CENTER, TitledBorder.TOP, null, new Color(0, 0, 0)));
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 138, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0 };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    setLayout(gridBagLayout);

    myNameBox = new JTextField();
    myNameBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            myIgnoreNameChanges = true;
            try {
                myConnection.setNameExplicitly(myNameBox.getText());
            } finally {
                myIgnoreNameChanges = false;
            }
        }
    });

    myRememberAsCheckBox = new JCheckBox("Save With Name:");
    myRememberAsCheckBox
            .setToolTipText("If checked, this connection will be saved for the next time you start TestPanel");
    myRememberAsCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myConnection.setPersistent(myRememberAsCheckBox.isSelected());
            updateRememberAsUi();
        }
    });
    GridBagConstraints gbc_RememberAsCheckBox = new GridBagConstraints();
    gbc_RememberAsCheckBox.insets = new Insets(0, 0, 5, 5);
    gbc_RememberAsCheckBox.gridx = 0;
    gbc_RememberAsCheckBox.gridy = 0;
    add(myRememberAsCheckBox, gbc_RememberAsCheckBox);
    GridBagConstraints gbc_NameBox = new GridBagConstraints();
    gbc_NameBox.insets = new Insets(0, 0, 5, 0);
    gbc_NameBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_NameBox.gridx = 1;
    gbc_NameBox.gridy = 0;
    add(myNameBox, gbc_NameBox);
    myNameBox.setColumns(10);

    JPanel panel_5 = new JPanel();
    GridBagConstraints gbc_panel_5 = new GridBagConstraints();
    gbc_panel_5.anchor = GridBagConstraints.WEST;
    gbc_panel_5.fill = GridBagConstraints.VERTICAL;
    gbc_panel_5.gridx = 1;
    gbc_panel_5.gridy = 1;
    add(panel_5, gbc_panel_5);

    myStartButton = new JButton("Start");
    myStartButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myConnection.start();
        }
    });
    panel_5.add(myStartButton);

    myStopButton = new JButton("Stop");
    myStopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myConnection.stop();
        }
    });
    panel_5.add(myStopButton);

    myStatusLabel = new JLabel("New label");
    panel_5.add(myStatusLabel);

}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

private GridBagConstraints constraintsForSecondColumnCheckbox() {
    GridBagConstraints gbc;/*from   w w  w  .j av  a2  s.  c  o  m*/
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(INNER_GAP, INDENT, 0, 0);
    gbc.anchor = GridBagConstraints.LINE_START;
    return gbc;
}

From source file:net.sf.jabref.gui.PreviewPanel.java

private JToolBar createToolBar() {
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setMargin(new Insets(0, 0, 0, 2));
    toolBar.setFloatable(false);/*from ww  w .ja  va 2 s  .c om*/

    // Add actions (and thus buttons)
    toolBar.add(this.closeAction);
    toolBar.addSeparator();
    toolBar.add(this.copyPreviewAction);
    toolBar.addSeparator();
    toolBar.add(this.printAction);

    Component[] comps = toolBar.getComponents();

    for (Component comp : comps) {
        ((JComponent) comp).setOpaque(false);
    }

    return toolBar;
}

From source file:edu.harvard.mcz.imagecapture.LoginDialog.java

/**
 * This method initializes jPanel   /*w  w  w.j a  v  a  2  s.c  o m*/
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
        gridBagConstraints17.gridx = 1;
        gridBagConstraints17.anchor = GridBagConstraints.WEST;
        gridBagConstraints17.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints17.gridy = 16;
        jLabel6 = new JLabel();
        jLabel6.setText("");
        GridBagConstraints gridBagConstraints62 = new GridBagConstraints();
        gridBagConstraints62.gridx = 0;
        gridBagConstraints62.gridwidth = 2;
        gridBagConstraints62.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints62.anchor = GridBagConstraints.WEST;
        gridBagConstraints62.gridy = 6;
        GridBagConstraints gridBagConstraints51 = new GridBagConstraints();
        gridBagConstraints51.gridx = 0;
        gridBagConstraints51.gridy = 4;
        GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
        gridBagConstraints41.fill = GridBagConstraints.BOTH;
        gridBagConstraints41.gridy = 3;
        gridBagConstraints41.weightx = 1.0;
        gridBagConstraints41.anchor = GridBagConstraints.WEST;
        gridBagConstraints41.gridx = 1;
        GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
        gridBagConstraints31.gridx = 0;
        gridBagConstraints31.anchor = GridBagConstraints.EAST;
        gridBagConstraints31.gridy = 3;
        jLabel9 = new JLabel();
        jLabel9.setText("Password");
        GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
        gridBagConstraints21.gridx = 0;
        gridBagConstraints21.anchor = GridBagConstraints.EAST;
        gridBagConstraints21.gridy = 2;
        jLabel8 = new JLabel();
        jLabel8.setText("email");
        GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
        gridBagConstraints16.fill = GridBagConstraints.BOTH;
        gridBagConstraints16.gridy = 2;
        gridBagConstraints16.weightx = 1.0;
        gridBagConstraints16.anchor = GridBagConstraints.WEST;
        gridBagConstraints16.gridx = 1;
        GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
        gridBagConstraints15.gridx = 1;
        gridBagConstraints15.gridy = 12;
        GridBagConstraints gridBagConstraints61 = new GridBagConstraints();
        gridBagConstraints61.gridx = 0;
        gridBagConstraints61.gridwidth = 1;
        gridBagConstraints61.anchor = GridBagConstraints.NORTHEAST;
        gridBagConstraints61.gridheight = 4;
        gridBagConstraints61.fill = GridBagConstraints.NONE;
        gridBagConstraints61.weighty = 1.0;
        gridBagConstraints61.insets = new Insets(0, 0, 0, 0);
        gridBagConstraints61.gridy = 10;
        jLabel7 = new JLabel();
        URL iconFile = this.getClass().getResource("/edu/harvard/mcz/imagecapture/resources/key_small.png");
        try {
            //this.setIconImage(new ImageIcon(iconFile).getImage());
            jLabel7.setIcon(new ImageIcon(iconFile));
        } catch (Exception e) {
            System.out.println("Can't open icon file: " + iconFile);
        }
        jLabel7.setText(" ");
        GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
        gridBagConstraints12.gridx = 1;
        gridBagConstraints12.anchor = GridBagConstraints.NORTH;
        gridBagConstraints12.fill = GridBagConstraints.NONE;
        gridBagConstraints12.gridy = 1;
        jLabel5 = new JLabel();
        jLabel5.setText("Connect to Database");
        jLabel4 = new JLabel();
        jLabel4.setText("Dialect");
        jLabel3 = new JLabel();
        jLabel3.setText("Connection");
        jLabel2 = new JLabel();
        jLabel2.setText("Driver");
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.gridy = 2;
        jLabel1 = new JLabel();
        jLabel1.setText("DBPassword");
        jLabel = new JLabel();
        jLabel.setText("Schema");
        jPanel = new JPanel();

        jPanel.setLayout(new GridBagLayout());
        jPanel.add(jLabel5, gridBagConstraints12);
        jPanel.add(jLabel7, gridBagConstraints61);
        jPanel.add(getJPanel1(), gridBagConstraints15);
        jPanel.add(getJTextFieldEmail(), gridBagConstraints16);
        jPanel.add(jLabel8, gridBagConstraints21);
        jPanel.add(jLabel9, gridBagConstraints31);
        jPanel.add(getJPasswordFieldUser(), gridBagConstraints41);
        jPanel.add(getJButton2(), gridBagConstraints51);
        jPanel.add(getJPanelAdvanced(), gridBagConstraints62);
        jPanel.add(jLabel6, gridBagConstraints17);
    }
    return jPanel;
}

From source file:KjellDirdalNotepad.java

private Insets getScrollPaneInsets() {
    JScrollPane scrollPane = getScrollPane();
    if (scrollPane == null)
        return new Insets(0, 0, 0, 0);
    else/*w  ww. ja v  a  2  s.com*/
        return getScrollPane().getBorder().getBorderInsets(scrollPane);
}

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

private JPanel buildUiBodyStatePanel() {
    // Create a grid bag constraints configuration
    GridBagConstraints c = new GridBagConstraints();

    // Body state panel
    final JPanel bodyStatePanel = new JPanel(new GridBagLayout());
    bodyStatePanel.setBorder(new CompoundBorder(BorderFactory.createTitledBorder("BMI tool"),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));

    // Add the student panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;//from w  ww  . j a v a2  s .  co m
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridheight = 2;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    bodyStatePanel.add(buildUiStudentPanel(), c);

    // Add the input panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridheight = 1;
    c.insets = new Insets(0, 16, 0, 0);
    c.anchor = GridBagConstraints.NORTH;
    bodyStatePanel.add(buildUiChartPanel(), c);

    // Add the input panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridheight = 1;
    c.insets = new Insets(32, 16, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    bodyStatePanel.add(buildUiStudentBodyStatesPanel(), c);

    // Return the body state panel
    return bodyStatePanel;
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java

private JPanel getJPanelDocumentExportInfo() {
    if (jPanelDocumentExportInfo == null) {
        jPanelDocumentExportInfo = new JPanel();
        jPanelDocumentExportInfo.setLayout(new GridBagLayout());

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridx = 0;/*  w w  w  .j av a  2s.c o  m*/
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.insets = new Insets(0, 5, 0, 5);
        jPanelDocumentExportInfo.add(getJTextFieldReportLocation(), gridBagConstraints1);

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 1;
        gridBagConstraints2.gridy = 0;
        jPanelDocumentExportInfo.add(getJButtonCreateExplorer(), gridBagConstraints2);
    }
    return jPanelDocumentExportInfo;
}