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:com.stefanbrenner.droplet.ui.ActionPanel.java

/**
 * Create the panel./*from w  ww .ja va  2s .c om*/
 */
public ActionPanel(final IActionDevice device, final T action) {

    setDevice(device);
    setAction(action);

    setLayout(new GridBagLayout());
    setBackground(DropletColors.getBackgroundColor(getDevice()));

    GridBagConstraints gbc = UiUtils.createGridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(2, 2, 2, 2);

    BeanAdapter<IAction> adapter = new BeanAdapter<IAction>(action, true);

    // enabled checkbox
    cbEnable = BasicComponentFactory.createCheckBox(adapter.getValueModel(IAction.PROPERTY_ENABLED),
            StringUtils.EMPTY);
    cbEnable.setToolTipText(Messages.getString("ActionPanel.enableAction.tooltip")); //$NON-NLS-1$
    cbEnable.setFocusable(false);
    UiUtils.editGridBagConstraints(gbc, 0, 0, 0, 0);
    add(cbEnable, gbc);

    // offset spinner
    spOffset = new MouseWheelSpinner(true);
    spOffset.setToolTipText(Messages.getString("ActionPanel.Offset.Tooltip")); //$NON-NLS-1$
    spOffset.setModel(SpinnerAdapterFactory.createNumberAdapter(adapter.getValueModel(IAction.PROPERTY_OFFSET),
            0, 0, ActionPanel.MAX_TIME_INPUT, 1));
    ((JSpinner.DefaultEditor) spOffset.getEditor()).getTextField().setColumns(4);
    UiUtils.editGridBagConstraints(gbc, 1, 0, 0, 0);
    add(spOffset, gbc);

    // duration spinner
    spDuration = new MouseWheelSpinner(true);
    spDuration.setToolTipText(Messages.getString("ActionPanel.Duration.Tooltip")); //$NON-NLS-1$
    if (action instanceof IDurationAction) {
        spDuration.setModel(SpinnerAdapterFactory.createNumberAdapter(
                adapter.getValueModel(IDurationAction.PROPERTY_DURATION), 0, 0, ActionPanel.MAX_TIME_INPUT, 1));
        ((JSpinner.DefaultEditor) spDuration.getEditor()).getTextField().setColumns(4);
        UiUtils.editGridBagConstraints(gbc, 2, 0, 0, 0);
        add(spDuration, gbc);
    }

    // remove button
    btnRemove = new JButton(Messages.getString("ActionPanel.removeAction")); //$NON-NLS-1$
    btnRemove.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            remove();
        }
    });
    btnRemove.setToolTipText(Messages.getString("ActionPanel.removeAction.tooltip")); //$NON-NLS-1$
    btnRemove.setFocusable(false);
    UiUtils.editGridBagConstraints(gbc, 3, 0, 0, 0);
    add(btnRemove, gbc);

}

From source file:Main.java

public Main() {
    super(new BorderLayout());
    task = new LongTask();

    //Create the demo's UI.
    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(this);

    taskOutput = new JTextArea(5, 20);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);//  w w w  .  j a va  2s.c  o m

    add(startButton, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    //Create a timer.
    timer = new Timer(ONE_SECOND, new TimerListener());
}

From source file:MouseEventDemo.java

public MouseEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;/*from   w ww .  ja  v a2  s .  c  o m*/
    c.weighty = 1.0;

    c.insets = new Insets(1, 1, 1, 1);
    blankArea = new BlankArea(new Color(0.98f, 0.97f, 0.85f));
    gridbag.setConstraints(blankArea, c);
    add(blankArea);

    c.insets = new Insets(0, 0, 0, 0);
    textArea = new JTextArea();
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(200, 75));
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    //Register for mouse events on blankArea and the panel.
    blankArea.addMouseListener(this);
    addMouseListener(this);

    setPreferredSize(new Dimension(450, 450));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:components.ScrollDemo.java

public ScrollDemo() {
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

    //Get the image to use.
    ImageIcon bee = createImageIcon("images/flyingBee.jpg");

    //Create the row and column headers.
    columnView = new Rule(Rule.HORIZONTAL, true);
    rowView = new Rule(Rule.VERTICAL, true);

    if (bee != null) {
        columnView.setPreferredWidth(bee.getIconWidth());
        rowView.setPreferredHeight(bee.getIconHeight());
    } else {/*from ww w.j  a v  a 2 s .  co m*/
        columnView.setPreferredWidth(320);
        rowView.setPreferredHeight(480);
    }

    //Create the corners.
    JPanel buttonCorner = new JPanel(); //use FlowLayout
    isMetric = new JToggleButton("cm", true);
    isMetric.setFont(new Font("SansSerif", Font.PLAIN, 11));
    isMetric.setMargin(new Insets(2, 2, 2, 2));
    isMetric.addItemListener(this);
    buttonCorner.add(isMetric);

    //Set up the scroll pane.
    picture = new ScrollablePicture(bee, columnView.getIncrement());
    JScrollPane pictureScrollPane = new JScrollPane(picture);
    pictureScrollPane.setPreferredSize(new Dimension(300, 250));
    pictureScrollPane.setViewportBorder(BorderFactory.createLineBorder(Color.black));

    pictureScrollPane.setColumnHeaderView(columnView);
    pictureScrollPane.setRowHeaderView(rowView);

    //Set the corners.
    //In theory, to support internationalization you would change
    //UPPER_LEFT_CORNER to UPPER_LEADING_CORNER,
    //LOWER_LEFT_CORNER to LOWER_LEADING_CORNER, and
    //UPPER_RIGHT_CORNER to UPPER_TRAILING_CORNER.  In practice,
    //bug #4467063 makes that impossible (in 1.4, at least).
    pictureScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, buttonCorner);
    pictureScrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, new Corner());
    pictureScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new Corner());

    //Put it in this panel.
    add(pictureScrollPane);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:ProgressMonitorDemo.java

public ProgressMonitorDemo() {
    super(new BorderLayout());
    task = new LongTask();

    //Create the demo's UI.
    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(this);

    taskOutput = new JTextArea(5, 20);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);//from ww  w.ja  v  a2  s  .c o  m

    add(startButton, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    //Create a timer.
    timer = new Timer(ONE_SECOND, new TimerListener());
}

From source file:SwingMouseMotionEventDemo.java

public SwingMouseMotionEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;/*w  w w .  ja v a  2  s . c om*/
    c.weighty = 1.0;

    c.insets = new Insets(1, 1, 1, 1);
    blankArea = new BlankArea(new Color(0.98f, 0.97f, 0.85f));
    gridbag.setConstraints(blankArea, c);
    add(blankArea);

    c.insets = new Insets(0, 0, 0, 0);
    textArea = new JTextArea();
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setPreferredSize(new Dimension(200, 75));
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    //Register for mouse events on blankArea and panel.
    blankArea.addMouseMotionListener(this);
    addMouseMotionListener(this);

    setPreferredSize(new Dimension(450, 450));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:Demo.HistGraph.java

public HistGraph(List<String> paraType_list) {
    this.paraType_list = paraType_list;

    // widgets: charts(JFreeChart), parameter selector (JList)
    chartPane = new ChartPanel(null);
    charts = new JFreeChart[paraType_list.size()];

    DefaultListModel modelOfList = new DefaultListModel();
    paraSelector = new JList(modelOfList);

    for (int i = 0; i < paraType_list.size(); i++) {
        modelOfList.addElement(paraType_list.get(i));
        charts[i] = null;//from   w  w  w . j a v  a  2s  . c o  m
    }

    paraSelector.setSelectedIndex(0);

    charts[0] = CreateChart(paraType_list.get(0));
    chartPane.setChart(charts[0]);

    JScrollPane selectorPanel = new JScrollPane();
    selectorPanel.setViewportView(paraSelector);

    paraSelector.addMouseListener(this);

    // layout
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;

    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.WEST;

    gbc.insets = new Insets(5, 20, 5, 5);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 20;
    add(new JLabel("Distribution:"), gbc);

    gbc.insets = new Insets(5, 5, 5, 20);
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1;
    add(new JLabel("Parameters:"), gbc);

    gbc.weighty = 14;

    gbc.insets = new Insets(5, 20, 5, 5);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 20;
    add(chartPane, gbc);

    gbc.insets = new Insets(5, 5, 15, 20);
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 1;
    add(selectorPanel, gbc);
}

From source file:FocusEventDemo.java

public void addComponentsToPane(final Container pane) {
    GridBagLayout gridbag = new GridBagLayout();
    pane.setLayout(gridbag);/*from w  w w .j a  va  2s . co m*/

    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0; // Make column as wide as possible.
    JTextField textField = new JTextField("A TextField");
    textField.setMargin(new Insets(0, 2, 0, 2));
    textField.addFocusListener(this);
    gridbag.setConstraints(textField, c);
    add(textField);

    c.weightx = 0.1; // Widen every other column a bit, when possible.
    c.fill = GridBagConstraints.NONE;
    JLabel label = new JLabel("A Label");
    label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    label.addFocusListener(this);
    gridbag.setConstraints(label, c);
    add(label);

    String comboPrefix = "ComboBox Item #";
    final int numItems = 15;
    Vector<String> vector = new Vector<String>(numItems);
    for (int i = 0; i < numItems; i++) {
        vector.addElement(comboPrefix + i);
    }
    JComboBox comboBox = new JComboBox(vector);
    comboBox.addFocusListener(this);
    gridbag.setConstraints(comboBox, c);
    add(comboBox);

    c.gridwidth = GridBagConstraints.REMAINDER;
    JButton button = new JButton("A Button");
    button.addFocusListener(this);
    gridbag.setConstraints(button, c);
    add(button);

    c.weightx = 0.0;
    c.weighty = 0.1;
    c.fill = GridBagConstraints.BOTH;
    String listPrefix = "List Item #";
    Vector<String> listVector = new Vector<String>(numItems);
    for (int i = 0; i < numItems; i++) {
        listVector.addElement(listPrefix + i);
    }
    JList list = new JList(listVector);
    list.setSelectedIndex(1); // It's easier to see the focus change
    // if an item is selected.
    list.addFocusListener(this);
    JScrollPane listScrollPane = new JScrollPane(list);

    gridbag.setConstraints(listScrollPane, c);
    add(listScrollPane);

    c.weighty = 1.0; // Make this row as tall as possible.
    c.gridheight = GridBagConstraints.REMAINDER;
    // Set up the area that reports focus-gained and focus-lost events.
    display = new JTextArea();
    display.setEditable(false);
    // The setRequestFocusEnabled method prevents a
    // component from being clickable, but it can still
    // get the focus through the keyboard - this ensures
    // user accessibility.
    display.setRequestFocusEnabled(false);
    display.addFocusListener(this);
    JScrollPane displayScrollPane = new JScrollPane(display);

    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);
    setPreferredSize(new Dimension(450, 450));
    ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:cc.pinel.mangue.ui.ChaptersPanel.java

/**
 * @param main the main controller/*w  w  w .j a v  a2  s . c  o  m*/
 * @param manga the manga
 */
public ChaptersPanel(Main main, Manga manga) {
    super(new GridBagLayout());

    this.main = main;

    chaptersPages = new KPages(PageProviders.createKBoxLayoutProvider(KBoxLayout.Y_AXIS));
    chaptersPages.setFocusable(true);
    chaptersPages.setEnabled(true);
    chaptersPages.setPageKeyPolicy(KPages.PAGE_KEYS_LOCAL);

    chapterListener = new ChapterLabelActionListener();

    GridBagConstraints gc = new GridBagConstraints();
    gc.gridx = 0;
    gc.gridy = 0;
    gc.insets = new Insets(20, 20, 20, 20);
    gc.anchor = GridBagConstraints.NORTH;
    gc.weightx = 1.0;
    gc.weighty = 1.0;
    gc.fill = GridBagConstraints.BOTH;

    add(chaptersPages, gc);

    chaptersPages.first();

    loadChapters(manga);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.JPanMatchTypeSelection.java

private void init() {

    GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
    gridBagConstraints12.gridx = 3;/*from  w  ww .  java  2 s.c o m*/
    gridBagConstraints12.ipadx = 5;
    gridBagConstraints12.gridy = 0;
    jLabelArrow2 = new JLabel();
    jLabelArrow2.setText("");
    GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
    gridBagConstraints11.gridx = 1;
    gridBagConstraints11.ipadx = 5;
    gridBagConstraints11.gridy = 0;
    jLabelArrow1 = new JLabel();
    jLabelArrow1.setText("");
    GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
    gridBagConstraints8.ipadx = 10;
    gridBagConstraints8.insets = new Insets(10, 0, 10, 10);
    GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
    gridBagConstraints7.gridx = 4;
    gridBagConstraints7.ipadx = 5;
    gridBagConstraints7.gridy = 0;
    GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
    gridBagConstraints4.gridx = 2;
    gridBagConstraints4.ipadx = 18;
    gridBagConstraints4.insets = new Insets(0, 0, 0, 10);
    gridBagConstraints4.gridy = 0;

    this.setLayout(new GridBagLayout());
    this.add(getJButtonStringSearch(), gridBagConstraints8);
    this.add(getJButtonCodeMatch(), gridBagConstraints4);
    this.add(getJButtonPatternMatch(), gridBagConstraints7);
    this.add(jLabelArrow1, gridBagConstraints11);
    this.add(jLabelArrow2, gridBagConstraints12);
}