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: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);//w  ww . j  ava2  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);
}

From source file:rhinova.gui.dataentry.reserve.ReserveDataEntryPanel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    vSpacer6 = new JPanel(null);
    label1 = new JLabel();
    hSpacer1 = new JPanel(null);
    label2 = new JLabel();
    txtName = new JTextField();
    vSpacer1 = new JPanel(null);
    label3 = new JLabel();
    txtXPos = new JTextField();
    vSpacer2 = new JPanel(null);
    label4 = new JLabel();
    txtYPos = new JTextField();
    hSpacer2 = new JPanel(null);
    vSpacer3 = new JPanel(null);
    label8 = new JLabel();
    txtMin = new JTextField();
    vSpacer4 = new JPanel(null);
    label5 = new JLabel();
    txtMax = new JTextField();
    vSpacer5 = new JPanel(null);
    label6 = new JLabel();
    txtCur = new JTextField();
    vSpacer9 = new JPanel(null);
    label7 = new JLabel();
    txtReg = new JTextField();
    vSpacer7 = new JPanel(null);
    btnCreateReserve = new JButton();
    vSpacer8 = new JPanel(null);

    //======== this ========
    setBorder(new TitledBorder("Reserve"));
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 0, 65, 145, 0, 0 };
    ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0 };//from  w  w w.  ja va2 s  .c om
    ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    add(vSpacer6, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label1 ----
    label1.setText("Reserve Entry Panel");
    label1.setFont(new Font("Tahoma", Font.PLAIN, 16));
    add(label1, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label2 ----
    label2.setText("name");
    add(label2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtName, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer1, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label3 ----
    label3.setText("x - position");
    add(label3, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtXPos, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer2, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label4 ----
    label4.setText("y - position");
    add(label4, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtYPos, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer2, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
    add(vSpacer3, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label8 ----
    label8.setText("minimum population");
    add(label8, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtMin, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer4, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label5 ----
    label5.setText("maximum population");
    add(label5, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtMax, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer5, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label6 ----
    label6.setText("current population");
    add(label6, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtCur, new GridBagConstraints(2, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer9, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label7 ----
    label7.setText("regeneration rate");
    add(label7, new GridBagConstraints(1, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtReg, new GridBagConstraints(2, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer7, new GridBagConstraints(1, 15, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- btnCreateReserve ----
    btnCreateReserve.setText("Create Reserve");
    btnCreateReserve.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnCreateReserveActionPerformed(e);
        }
    });
    add(btnCreateReserve, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer8, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

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

private void updateImportSPDXList() {
    getJPanelImportSPDX().removeAll();/*from  w w w .j  av a 2 s  . com*/
    int index = 0;
    for (index = 0; index < getJPanSPDXLocationList().size(); index++) {
        JPanLocation tmpLocation = getJPanSPDXLocationList().get(index);
        if (tmpLocation != null) {
            GridBagConstraints tmpGridBagConstraints = new GridBagConstraints();
            tmpGridBagConstraints.insets = new Insets(5, 5, 0, 5); //Insets(int top, int left, int bottom, int right) 
            tmpGridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
            tmpGridBagConstraints.gridx = 0;
            tmpGridBagConstraints.gridy = index;

            getJPanelImportSPDX().add(tmpLocation, tmpGridBagConstraints);
        }
    }

    GridBagConstraints tmpGridBagConstraints = new GridBagConstraints();
    tmpGridBagConstraints.fill = GridBagConstraints.BOTH;
    tmpGridBagConstraints.gridx = 0;
    tmpGridBagConstraints.gridy = index;
    tmpGridBagConstraints.weighty = 1.0;
    getJPanelImportSPDX().add(new JLabel(), tmpGridBagConstraints);

    checkValid();

    getJPanelImportSPDX().updateUI();
}

From source file:ListDataEventDemo.java

public ListDataEventDemo() {
    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);//w  w  w  .j  a va 2  s .  c  om
    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);
}

From source file:net.sf.jabref.gui.fieldeditors.FileListEditor.java

public FileListEditor(JabRefFrame frame, BibDatabaseContext databaseContext, String fieldName, String content,
        EntryEditor entryEditor) {/*w  w w .  j ava2s.c  om*/
    this.frame = frame;
    this.databaseContext = databaseContext;
    this.fieldName = fieldName;
    this.entryEditor = entryEditor;
    label = new FieldNameLabel(fieldName);
    tableModel = new FileListTableModel();
    setText(content);
    setModel(tableModel);
    JScrollPane sPane = new JScrollPane(this);
    setTableHeader(null);
    addMouseListener(new TableClickListener());

    JButton add = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon());
    add.setToolTipText(Localization.lang("New file link (INSERT)"));
    JButton remove = new JButton(IconTheme.JabRefIcon.REMOVE_NOBOX.getSmallIcon());
    remove.setToolTipText(Localization.lang("Remove file link (DELETE)"));
    JButton up = new JButton(IconTheme.JabRefIcon.UP.getSmallIcon());

    JButton down = new JButton(IconTheme.JabRefIcon.DOWN.getSmallIcon());
    auto = new JButton(Localization.lang("Get fulltext"));
    JButton download = new JButton(Localization.lang("Download from URL"));
    add.setMargin(new Insets(0, 0, 0, 0));
    remove.setMargin(new Insets(0, 0, 0, 0));
    up.setMargin(new Insets(0, 0, 0, 0));
    down.setMargin(new Insets(0, 0, 0, 0));
    add.addActionListener(e -> addEntry());
    remove.addActionListener(e -> removeEntries());
    up.addActionListener(e -> moveEntry(-1));
    down.addActionListener(e -> moveEntry(1));
    auto.addActionListener(e -> autoSetLinks());
    download.addActionListener(e -> downloadFile());

    FormBuilder builder = FormBuilder.create()
            .layout(new FormLayout("fill:pref,1dlu,fill:pref,1dlu,fill:pref", "fill:pref,fill:pref"));
    builder.add(up).xy(1, 1);
    builder.add(add).xy(3, 1);
    builder.add(auto).xy(5, 1);
    builder.add(down).xy(1, 2);
    builder.add(remove).xy(3, 2);
    builder.add(download).xy(5, 2);
    panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(sPane, BorderLayout.CENTER);
    panel.add(builder.getPanel(), BorderLayout.EAST);

    TransferHandler transferHandler = new FileListEditorTransferHandler(frame, entryEditor, null);
    setTransferHandler(transferHandler);
    panel.setTransferHandler(transferHandler);

    // Add an input/action pair for deleting entries:
    getInputMap().put(KeyStroke.getKeyStroke("DELETE"), "delete");
    getActionMap().put("delete", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            int row = getSelectedRow();
            removeEntries();
            row = Math.min(row, getRowCount() - 1);
            if (row >= 0) {
                setRowSelectionInterval(row, row);
            }
        }
    });

    // Add an input/action pair for inserting an entry:
    getInputMap().put(KeyStroke.getKeyStroke("INSERT"), "insert");
    getActionMap().put("insert", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            addEntry();
        }
    });

    // Add input/action pair for moving an entry up:
    getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.FILE_LIST_EDITOR_MOVE_ENTRY_UP), "move up");
    getActionMap().put("move up", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            moveEntry(-1);
        }
    });

    // Add input/action pair for moving an entry down:
    getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.FILE_LIST_EDITOR_MOVE_ENTRY_DOWN), "move down");
    getActionMap().put("move down", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            moveEntry(1);
        }
    });

    JMenuItem openLink = new JMenuItem(Localization.lang("Open"));
    menu.add(openLink);
    openLink.addActionListener(e -> openSelectedFile());

    JMenuItem openFolder = new JMenuItem(Localization.lang("Open folder"));
    menu.add(openFolder);
    openFolder.addActionListener(e -> {
        int row = getSelectedRow();
        if (row >= 0) {
            FileListEntry entry = tableModel.getEntry(row);
            try {
                String path = "";
                // absolute path
                if (Paths.get(entry.link).isAbsolute()) {
                    path = Paths.get(entry.link).toString();
                } else {
                    // relative to file folder
                    for (String folder : databaseContext.getFileDirectory()) {
                        Path file = Paths.get(folder, entry.link);
                        if (Files.exists(file)) {
                            path = file.toString();
                            break;
                        }
                    }
                }
                if (!path.isEmpty()) {
                    JabRefDesktop.openFolderAndSelectFile(path);
                } else {
                    JOptionPane.showMessageDialog(frame, Localization.lang("File not found"),
                            Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
                }
            } catch (IOException ex) {
                LOGGER.debug("Cannot open folder", ex);
            }
        }
    });

    JMenuItem rename = new JMenuItem(Localization.lang("Move/Rename file"));
    menu.add(rename);
    rename.addActionListener(new MoveFileAction(frame, entryEditor, this, false));

    JMenuItem moveToFileDir = new JMenuItem(Localization.lang("Move file to file directory"));
    menu.add(moveToFileDir);
    moveToFileDir.addActionListener(new MoveFileAction(frame, entryEditor, this, true));

    JMenuItem deleteFile = new JMenuItem(Localization.lang("Delete local file"));
    menu.add(deleteFile);
    deleteFile.addActionListener(e -> {
        int row = getSelectedRow();
        // no selection
        if (row != -1) {

            FileListEntry entry = tableModel.getEntry(row);
            // null if file does not exist
            Optional<File> file = FileUtil.expandFilename(databaseContext, entry.link);

            // transactional delete and unlink
            try {
                if (file.isPresent()) {
                    Files.delete(file.get().toPath());
                }
                removeEntries();
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(frame, Localization.lang("File permission error"),
                        Localization.lang("Cannot delete file"), JOptionPane.ERROR_MESSAGE);
                LOGGER.warn("File permission error while deleting: " + entry.link, ex);
            }
        }
    });
    adjustColumnWidth();
}

From source file:net.sf.texprinter.utils.UIUtils.java

/**
 * Formats a button to a label with wider margins. In short, this
 * method is similar to the button/label one, but with wider margins.
 *
 * @param button The button. Nothing new here.
 *///w ww .j  ava  2  s . c o m
public static void formatButtonAsList(JButton button) {

    // disable focus paint
    button.setFocusPainted(false);

    // fix the margins
    button.setMargin(new Insets(0, 0, 0, 5));

    // disable content area fill
    button.setContentAreaFilled(false);

    // disable border paint
    button.setBorderPainted(false);

    // disable property
    button.setOpaque(false);
}

From source file:com.game.ui.views.CharacterEditor.java

/**
 * This method draws up the gui on the panel.
 *///from  w w w .  j  a v a 2s .  co m
public void doGui() {
    JPanel outerPane = new JPanel();
    outerPane.setLayout(new GridBagLayout());
    //        setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(lblContent);
    noteLbl.setAlignmentX(0);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 4;
    c.gridy = 0;
    c.gridx = 0;
    outerPane.add(noteLbl, c);
    System.out.println(c.gridy);
    c.gridy++;
    System.out.println(c.gridy);
    c.gridx = 0;
    c.gridwidth = 1;
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    outerPane.add(comboBox, c);
    c.gridy++;
    JLabel nameLbl = new JLabel("Name : ");
    outerPane.add(nameLbl, c);
    c.gridx++;
    name = new JTextField();
    name.setColumns(20);
    outerPane.add(name, c);
    c.gridx = 0;
    c.gridy++;
    JLabel imageLbl = new JLabel("Image Path : ");
    outerPane.add(imageLbl, c);
    c.gridx++;
    imgPath = new JTextField();
    imgPath.setColumns(20);
    outerPane.add(imgPath, c);
    c.gridx = 0;
    c.gridy++;
    JLabel hitPtsLbl = new JLabel("Hit Points : ");
    outerPane.add(hitPtsLbl, c);
    c.gridx++;
    hitPoints = new JTextField();
    hitPoints.setColumns(20);
    outerPane.add(hitPoints, c);
    c.gridx = 0;
    c.gridy++;
    JLabel lvl = new JLabel("Level : ");
    outerPane.add(lvl, c);
    c.gridx++;
    level = new JTextField();
    level.setColumns(20);
    /*if(!isEnemy){
    level.setText("1");
    level.setEnabled(false);
    }*/
    outerPane.add(level, c);
    c.gridx = 0;
    c.gridy++;
    JLabel mlWpn = new JLabel("Melee Weapon : ");
    outerPane.add(mlWpn, c);
    c.gridx++;
    model = new DefaultComboBoxModel();
    LinkedList<String> meleeWpnList = new LinkedList<String>();
    LinkedList<String> rngdWpnList = new LinkedList<String>();
    for (Item item : GameBean.weaponDetails) {
        Weapon wpn = (Weapon) item;
        if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[0])) {
            meleeWpnList.add(wpn.getName());
        } else {
            rngdWpnList.add(wpn.getName());
        }
        weaponMap.put(wpn.getName(), wpn);
    }
    meleeWeapon = new JComboBox(new DefaultComboBoxModel(meleeWpnList.toArray()));
    meleeWeapon.setSelectedIndex(-1);
    meleeWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(meleeWeapon, c);
    c.gridx++;
    JLabel rngdWpn = new JLabel("Ranged Weapon : ");
    outerPane.add(rngdWpn, c);
    c.gridx++;
    rangedWeapon = new JComboBox(new DefaultComboBoxModel(rngdWpnList.toArray()));
    rangedWeapon.setSelectedIndex(-1);
    rangedWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(rangedWeapon, c);
    c.gridy++;
    c.gridx = 0;
    JLabel armourLbl = new JLabel("Armour : ");
    outerPane.add(armourLbl, c);
    c.gridx++;
    LinkedList<String> armourList = new LinkedList<String>();
    LinkedList<String> shildList = new LinkedList<String>();
    for (Item item : GameBean.armourDetails) {
        Armour temp = (Armour) item;
        if (temp.getArmourType() != null) {
            if (temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[1])) {
                armourList.add(temp.getName());
            } else {
                shildList.add(temp.getName());
            }
        } else {
            armourList.add(temp.getName());
            //            else if(temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[2]))
            shildList.add(temp.getName());
        }
        armorMap.put(temp.getName(), temp);
    }
    armour = new JComboBox(new DefaultComboBoxModel(armourList.toArray()));
    armour.setSelectedIndex(-1);
    armour.setMaximumSize(new Dimension(100, 30));
    outerPane.add(armour, c);
    c.gridx++;
    JLabel shieldLbl = new JLabel("Shield : ");
    outerPane.add(shieldLbl, c);
    c.gridx++;
    shield = new JComboBox(new DefaultComboBoxModel(shildList.toArray()));
    shield.setSelectedIndex(-1);
    shield.setMaximumSize(new Dimension(100, 30));
    outerPane.add(shield, c);
    ta = new JTextArea(10, 50);
    ta.setRows(40);
    ta.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    JScrollPane scrollPane = new JScrollPane(ta);
    scrollPane.setPreferredSize(new Dimension(600, 250));
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = 4;
    c.gridheight = 4;
    c.weightx = .5;
    c.weighty = 1;
    outerPane.add(scrollPane, c);
    c.gridy += 4;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.gridheight = 1;
    c.gridwidth = 1;
    JButton generate = new JButton("Generate");
    JButton submit = new JButton("Submit");
    outerPane.add(generate, c);
    submit.addActionListener(this);
    generate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            ta.setText("");
            HashSet<Integer> set = new HashSet<Integer>();
            int strength = getUniqueVal(set);
            int constitution = getUniqueVal(set);
            int dext = getUniqueVal(set);
            int intel = getUniqueVal(set);
            int charisma = getUniqueVal(set);
            int wisdom = getUniqueVal(set);
            if (character == null) {
                builder = new CharacterBuilder(isEnemy);
            } else {
                builder = new CharacterBuilder(character);
            }
            builder.setStrength(strength);
            builder.setConstitution(constitution);
            builder.setDexterity(dext);
            builder.setIntelligence(intel);
            builder.setCharisma(charisma);
            builder.setWisdom(wisdom);
            int strModifier = GameUtils.calculateAbilityModifier(strength);
            int conModifier = GameUtils.calculateAbilityModifier(constitution);
            int dexModifier = GameUtils.calculateAbilityModifier(dext);
            int wisModifier = GameUtils.calculateAbilityModifier(wisdom);
            int intModifier = GameUtils.calculateAbilityModifier(intel);
            int chaModifier = GameUtils.calculateAbilityModifier(charisma);
            builder.setStrengthModifier(strModifier);
            builder.setConstitutionModifier(conModifier);
            builder.setCharismaModifier(chaModifier);
            builder.setWisdomModifier(wisModifier);
            builder.setIntelligenceModifier(intModifier);
            builder.setDexterityModifier(dexModifier);
            String type = null;
            if (constitution < strength && constitution > dext) {
                type = "Bully";
                builder.setType("Bully");
            } else if (dext > constitution && constitution > strength) {
                builder.setType("Nimble");
                type = "Nimble";
            } else {
                builder.setType("Tank");
                type = "Tank";
            }
            ta.append("Strength : " + strength);
            ta.append("\nDexterity : " + dexModifier);
            ta.append("\nConstitution : " + constitution);
            ta.append("\nIntelligence : " + intel);
            ta.append("\nCharisma: " + charisma);
            ta.append("\nWisdom : " + wisdom);
            ta.append("\nType :" + type);
            ta.append("\nStrength Modifier :" + strModifier);
            ta.append("\nConstitution Modifier :" + conModifier);
            ta.append("\nDexterity Modifier :" + dexModifier);
            generated = true;
            if (character != null) {
                character = builder.build();
            }
        }
    });
    c.gridx++;
    outerPane.add(submit, c);
    validationMess = new JLabel();
    validationMess.setForeground(Color.red);
    //        validationMess.setVisible(false);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 4;
    outerPane.add(validationMess, c);
    JScrollPane outerScrollPane = new JScrollPane(outerPane);
    setLayout(new BorderLayout());
    add(outerScrollPane, BorderLayout.CENTER);
}

From source file:com.microsoft.alm.plugin.idea.common.ui.common.tabs.TabFormImpl.java

/**
 * Create the tab view if not already done
 *//*from www.  j av  a2 s  . c om*/
protected void ensureInitialized() {
    if (!initialized) {
        createCustomView();
        createFilterToolbar();

        //toolbars
        final JPanel toolBarPanel;
        if (ApplicationManager.getApplication() != null) {
            final ActionToolbar prActionsToolbar = createToolbar(createActionsGroup());
            final ActionToolbar feedbackActionsToolbar = createToolbar(createFeedbackGroup());
            final ActionToolbar optionsActionsToolbar = createToolbar(createOptionsGroup());

            // left panel of the top toolbar
            final FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 0, JBUI.scale(3)); // give vertical padding
            final JPanel toolBarPanelLeft = new JPanel(flowLayout);
            toolBarPanelLeft.add(prActionsToolbar.getComponent());
            toolBarPanelLeft.add(searchFilter);
            addCustomTools(toolBarPanelLeft);

            // middle panel of the top toolbar
            final FlowLayout flowLayout2 = new FlowLayout(FlowLayout.LEFT, 0, JBUI.scale(3)); // give vertical padding
            final JPanel toolBarPanelMiddle = new JPanel(flowLayout2);
            toolBarPanelMiddle.add(optionsActionsToolbar.getComponent());
            SwingHelper.setMargin(toolBarPanelMiddle, new Insets(JBUI.scale(2), JBUI.scale(15), 0, 0));

            //entire top toolbar
            toolBarPanel = new JPanel(new BorderLayout());
            toolBarPanel.add(toolBarPanelLeft, BorderLayout.LINE_START);
            toolBarPanel.add(toolBarPanelMiddle, BorderLayout.CENTER);
            toolBarPanel.add(feedbackActionsToolbar.getComponent(), BorderLayout.LINE_END);
        } else {
            //skip setup when called from unit tests
            toolBarPanel = new JPanel();
        }

        //status panel with label and link
        final JPanel statusPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        statusLabel = new JLabel();
        statusLink = new Hyperlink();
        statusLink.setActionCommand(CMD_STATUS_LINK);
        statusPanel.add(statusLabel);
        statusPanel.add(statusLink);

        //tabPanel
        tabPanel = new JPanel(new BorderLayout());
        tabPanel.add(toolBarPanel, BorderLayout.PAGE_START);
        tabPanel.add(scrollPanel, BorderLayout.CENTER);
        tabPanel.add(statusPanel, BorderLayout.PAGE_END);
        this.initialized = true;
    }
}

From source file:com.att.aro.ui.view.videotab.VideoTab.java

@Override
public JPanel layoutDataPanel() {
    if (mainPanel == null) {

        mainPanel = new JPanel(new GridBagLayout());
        mainPanel.setOpaque(false);/*  ww  w . j  a  v  a 2  s.  c  o m*/

        int section = 1;

        mainPanel.add(buildSummariesGroup(), new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0,
                GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

        graphPanelIndex = section++;
        addGraphPanel();

        mainPanel.add(buildManifestsGroup(), new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0,
                GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0));

        mainPanel.add(buildRequestsGroup(), new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0,
                GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0));
    }
    return mainPanel;
}

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

private Component getJPanelOkResetBtn() {
    if (jPanOKCancelBtn == null) {

        jPanOKCancelBtn = new JPanel();

        GridBagConstraints gridBagConstraintsOKBtn = new GridBagConstraints();
        gridBagConstraintsOKBtn.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsOKBtn.insets = new Insets(0, 0, 10, 0);
        gridBagConstraintsOKBtn.gridx = 0;
        gridBagConstraintsOKBtn.gridy = 0;

        GridBagConstraints gridBagConstraintsResetBtn = new GridBagConstraints();
        gridBagConstraintsResetBtn.gridx = 0;
        gridBagConstraintsResetBtn.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsResetBtn.insets = new Insets(0, 0, 10, 0);
        gridBagConstraintsResetBtn.gridy = 1;

        jPanOKCancelBtn.setLayout(new GridBagLayout());
        jPanOKCancelBtn.add(getJButtonOK(), gridBagConstraintsOKBtn);
        jPanOKCancelBtn.add(getJButtonReset(), gridBagConstraintsResetBtn);
    }/*  w ww .j  a  v a 2s  .  c o m*/
    return jPanOKCancelBtn;
}