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:org.n52.oxf.ui.swing.ChartDialog.java

/**
 * initializes (or updates) the JFreeChart->ChartPanel.
 * //from   w  w  w. j  a  va  2  s  . c o  m
 * @param parameters
 * @param selectedfeatures
 */
private void initChartPanel(OXFFeatureCollection observations, ParameterContainer paramCon) {

    MyGridBagLayout mainLayout = (MyGridBagLayout) getContentPane().getLayout();

    int chartPanelPosition = 3;

    if (getContentPane().getComponentCount() > chartPanelPosition) {
        getContentPane().remove(chartPanelPosition);
    }

    JFreeChart chart = chartRenderer.renderChart(observations, paramCon);
    org.jfree.chart.ChartPanel chartPanel = new org.jfree.chart.ChartPanel(chart);
    chartPanel.setMouseZoomable(true, true);

    mainLayout.addComponent(chartPanelPosition, chartPanel, 0, 0, 2, 1, 100, 100, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(9, 9, 9, 9));

    getContentPane().validate();
}

From source file:be.ac.ua.comp.scarletnebula.gui.addserverwizard.ChooseImagePage.java

private JPanel getSearchPanel(final TableRowSorter<MachineImageTableModel> sorter) {
    final JPanel searchPanel = new JPanel(new GridBagLayout());
    searchPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));

    add(searchPanel, BorderLayout.NORTH);
    final PlatformComboBox platformComboBox = new PlatformComboBox();

    final GridBagConstraints c = new GridBagConstraints();
    c.weightx = 0.0;// www.  j  ava  2  s.c  o  m
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 5);

    searchPanel.add(platformComboBox, c);
    final ArchitectureComboBox architectureComboBox = new ArchitectureComboBox();

    c.gridx = 1;
    searchPanel.add(architectureComboBox, c);

    final BetterTextField searchField = new BetterTextField();
    searchField.setPlaceHolder("Search terms");

    searchField.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    c.gridx = 2;
    c.weightx = 1.0;
    c.insets = new Insets(0, 0, 0, 0);
    searchPanel.add(searchField, c);

    searchField.addActionListener(
            new SearchFieldListener(architectureComboBox, sorter, platformComboBox, searchField));

    return searchPanel;
}

From source file:width.java

public Insets getInsets() {
    return new Insets(3,3,3,3);
}

From source file:com.idealista.solrmeter.view.statistic.CacheHistoryPanel.java

/**
 * Creates the left panel, with the combo boxes to select wether to see hit ratio
 * or specific cache data, and if specific cache data is selected, will also show
 * the combo box to select the cache and the cumulative information
 * @return/*from   w  ww . j a  va 2 s. c o  m*/
 */
private Component createLeftPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.insets = new Insets(1, 1, 1, 1);
    for (Component component : this.createControlPanel()) {
        panel.add(component, constraints);
        constraints.gridy++;
    }
    cumulativeDataPanel = this.createCumulativeDataPanel();
    panel.add(cumulativeDataPanel, constraints);
    constraints.gridy++;
    constraints.weighty = 2.0;
    panel.add(Box.createVerticalGlue(), constraints);
    panel.setMaximumSize(new Dimension(100, Integer.MAX_VALUE));

    return panel;
}

From source file:logdruid.ui.RecordingList.java

/**
 * Create the panel.//www .java 2s  . c o m
 */
public RecordingList(final Repository rep) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}

From source file:net.datacrow.console.windows.itemformsettings.TabDesignPanel.java

private void build() {
    setLayout(Layout.getGBL());//from w w w .j av a2s .com
    pnlFields = new FieldSelectionPanel(module, false, true, true);
    pnlFields.setFieldSelectionListener(this);

    add(pnlFields, Layout.getGBC(0, 0, 1, 1, 40.0, 40.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
            new Insets(0, 5, 5, 5), 0, 0));
}

From source file:com.hammurapi.jcapture.CaptureFrame.java

public CaptureFrame(final AbstractCaptureApplet applet) throws Exception {
    super("Screen capture");
    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("camera.png")));

    setUndecorated(true);/*from   w w  w  .  j  a  v a 2  s.co m*/

    Translucener.makeFrameTranslucent(this);

    setAlwaysOnTop(true);
    this.applet = applet;
    captureConfig = new CaptureConfig();
    captureConfig.load(applet.loadConfig());
    captureConfig.setBackgroundProcessor(applet.getBackgroundProcessor());

    //--- GUI construction ---

    capturePanel = new JPanel();

    final JLabel dimensionsLabel = new JLabel("");
    capturePanel.add(dimensionsLabel, BorderLayout.CENTER);

    capturePanel.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            super.componentResized(e);
            dimensionsLabel.setText(e.getComponent().getWidth() + " x " + e.getComponent().getHeight());
        }
    });

    JButton captureButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Rectangle bounds = capturePanel.getBounds();
            Point loc = bounds.getLocation();
            SwingUtilities.convertPointToScreen(loc, capturePanel);
            bounds.setLocation(loc);
            Properties props = captureConfig.setRecordingRectangle(bounds);
            if (props != null) {
                getApplet().storeConfig(props);
            }
            capturing.set(true);
            setVisible(false);
        }

    });
    captureButton.setText("Capture");
    captureButton.setToolTipText("Create a snapshot of the screen");
    capturePanel.add(captureButton, BorderLayout.CENTER);

    recordButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Rectangle bounds = capturePanel.getBounds();
            Point loc = bounds.getLocation();
            SwingUtilities.convertPointToScreen(loc, capturePanel);
            bounds.setLocation(loc);
            Properties props = captureConfig.setRecordingRectangle(bounds);
            if (props != null) {
                getApplet().storeConfig(props);
            }
            recording.set(true);
            setVisible(false);
        }

    });
    recordButton.setText("Record");
    setRecordButtonState();
    capturePanel.add(recordButton, BorderLayout.CENTER);

    JButton optionsButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new CaptureOptionsDialog(CaptureFrame.this).setVisible(true);
        }

    });
    optionsButton.setText("Options");
    capturePanel.add(optionsButton, BorderLayout.CENTER);

    JButton cancelButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            CaptureFrame.this.setVisible(false);
        }

    });
    cancelButton.setText("Cancel");
    capturePanel.add(cancelButton, BorderLayout.CENTER);

    getContentPane().add(capturePanel, BorderLayout.CENTER);

    capturePanel.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false));

    if (captureConfig.getRecordingRectangle() == null) {
        setSize(400, 300);
        setLocationRelativeTo(null);
    } else {
        setBounds(captureConfig.getRecordingRectangle());
    }

    Insets dragInsets = new Insets(5, 5, 5, 5);
    new ComponentResizer(dragInsets, this);

    ComponentMover cm = new ComponentMover();
    cm.registerComponent(this);
    cm.setDragInsets(dragInsets);

    addComponentListener(new ComponentListener() {

        @Override
        public void componentShown(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentResized(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentMoved(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentHidden(ComponentEvent e) {
            if (capturing.get()) {
                capturing.set(false);
                try {
                    capture();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else if (recording.get()) {
                recording.set(false);
                record();
            }
        }
    });

}

From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java

/**
 * Adds the strategic route message panels
 * @param notification the route notification
 *//*from  w  w  w. ja v a 2 s  .c  o  m*/
private void addStrategicRouteMessages(T notification) {
    messagesPanel.removeAll();

    if (notification == null) {
        return;
    }

    // for each route message
    Insets insets = new Insets(5, 5, 0, 5);
    StrategicRouteNegotiationData routeData = notification.get();
    for (int i = 0; i < routeData.getRouteMessage().size(); i++) {

        int routeIndex = routeData.getRouteMessage().size() - 1 - i;
        StrategicRouteMessage routeMessage = routeData.getRouteMessage().get(routeIndex);
        StrategicRouteMessage prevRouteMessage = (routeIndex == 0) ? null
                : routeData.getRouteMessage().get(routeIndex - 1);

        String routeChanges = (prevRouteMessage != null)
                ? StrategicRouteNotificationCommon.findChanges(new Route(prevRouteMessage.getRoute()),
                        new Route(routeMessage.getRoute()))
                : null;

        String title = getMessageViewTitle(routeMessage);
        StrategicNotificationMessageView messageView = new StrategicNotificationMessageView(title, routeMessage,
                routeChanges, i);

        messagesPanel.add(messageView,
                new GridBagConstraints(0, i + 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets, 0, 0));
    }

    // Add filler
    messagesPanel.add(new JLabel(" "), new GridBagConstraints(0, routeData.getRouteMessage().size() + 10, 1, 1,
            1.0, 1.0, WEST, BOTH, insets, 0, 0));
}

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

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

From source file:Main.java

public Main() {
    super(new BorderLayout());

    //Create and populate the list model.
    listModel = new DefaultListModel();
    listModel.addElement("Whistler, Canada");
    listModel.addElement("Jackson Hole, Wyoming");
    listModel.addElement("Squaw Valley, California");
    listModel.addElement("Telluride, Colorado");
    listModel.addElement("Taos, New Mexico");
    listModel.addElement("Snowbird, Utah");
    listModel.addElement("Chamonix, France");
    listModel.addElement("Banff, Canada");
    listModel.addElement("Arapahoe Basin, Colorado");
    listModel.addElement("Kirkwood, California");
    listModel.addElement("Sun Valley, Idaho");
    listModel.addListDataListener(new MyListDataListener());

    //Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    list.setSelectedIndex(0);//from   w ww.  j  ava 2 s .  c o  m
    list.addListSelectionListener(this);
    JScrollPane listScrollPane = new JScrollPane(list);

    //Create the list-modifying buttons.
    addButton = new JButton(addString);
    addButton.setActionCommand(addString);
    addButton.addActionListener(new AddButtonListener());

    deleteButton = new JButton(deleteString);
    deleteButton.setActionCommand(deleteString);
    deleteButton.addActionListener(new DeleteButtonListener());

    ImageIcon icon = createImageIcon("Up16");
    if (icon != null) {
        upButton = new JButton(icon);
        upButton.setMargin(new Insets(0, 0, 0, 0));
    } else {
        upButton = new JButton("Move up");
    }
    upButton.setToolTipText("Move the currently selected list item higher.");
    upButton.setActionCommand(upString);
    upButton.addActionListener(new UpDownListener());

    icon = createImageIcon("Down16");
    if (icon != null) {
        downButton = new JButton(icon);
        downButton.setMargin(new Insets(0, 0, 0, 0));
    } else {
        downButton = new JButton("Move down");
    }
    downButton.setToolTipText("Move the currently selected list item lower.");
    downButton.setActionCommand(downString);
    downButton.addActionListener(new UpDownListener());

    JPanel upDownPanel = new JPanel(new GridLayout(2, 1));
    upDownPanel.add(upButton);
    upDownPanel.add(downButton);

    //Create the text field for entering new names.
    nameField = new JTextField(15);
    nameField.addActionListener(new AddButtonListener());
    String name = listModel.getElementAt(list.getSelectedIndex()).toString();
    nameField.setText(name);

    //Create a control panel, using the default FlowLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.add(nameField);
    buttonPane.add(addButton);
    buttonPane.add(deleteButton);
    buttonPane.add(upDownPanel);

    //Create the log for reporting list data events.
    log = new JTextArea(10, 20);
    JScrollPane logScrollPane = new JScrollPane(log);

    //Create a split pane for the log and the list.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, listScrollPane, logScrollPane);
    splitPane.setResizeWeight(0.5);

    //Put everything together.
    add(buttonPane, BorderLayout.PAGE_START);
    add(splitPane, BorderLayout.CENTER);
}