Example usage for java.awt FlowLayout setHgap

List of usage examples for java.awt FlowLayout setHgap

Introduction

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

Prototype

public void setHgap(int hgap) 

Source Link

Document

Sets the horizontal gap between components and between the components and the borders of the Container .

Usage

From source file:FlowLayoutSettingGaps.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame("This is a Flow Layout");
    aWindow.setBounds(30, 30, 300, 300); // Size
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    FlowLayout flow = new FlowLayout(); // Create a layout manager
    flow.setHgap(35); // Set the horizontal gap
    Container content = aWindow.getContentPane(); // Get the content pane
    content.setLayout(flow); // Set the container layout mgr
    // Now add six button components
    for (int i = 1; i <= 6; i++) {
        content.add(new JButton("Press " + i)); // Add a Button to content pane
    }/* w w w  . j  a  v  a2 s.  com*/
    aWindow.setVisible(true); // Display the window
}

From source file:Main.java

public Main() {

    FlowLayout flowLayout = new FlowLayout();
    setLayout(flowLayout);//from  w w w .  jav a  2  s  . c  o m

    add(new JButton("w w w.j a v a 2 s . c o m"));
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    flowLayout.setHgap(10);
    flowLayout.setVgap(12);
}

From source file:Main.java

public Main() {

    FlowLayout flowLayout = new FlowLayout(FlowLayout.RIGHT, 10, 3);
    setLayout(flowLayout);/*from w  w w  .ja v a2  s. co m*/

    add(new JButton("w w w.j a v a 2 s . c o m"));
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    flowLayout.setHgap(10);
    flowLayout.setVgap(12);
}

From source file:au.org.ala.delta.editor.ui.ActionSetsDialog.java

private void createUI() {
    setName("actionSetsDialog");

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    conforTable = new JTable();
    tabbedPane.addTab(_resources.getString("directiveTypeConfor.text"), new JScrollPane(conforTable));

    intkeyTable = new JTable();
    tabbedPane.addTab(_resources.getString("directiveTypeIntkey.text"), new JScrollPane(intkeyTable));

    distTable = new JTable();
    tabbedPane.addTab(_resources.getString("directiveTypeDist.text"), new JScrollPane(distTable));

    keyTable = new JTable();
    tabbedPane.addTab(_resources.getString("directiveTypeKey.text"), new JScrollPane(keyTable));

    JPanel buttonPanel = new JPanel();
    getContentPane().add(buttonPanel, BorderLayout.EAST);

    runButton = new JButton();

    addButton = new JButton();

    editButton = new JButton();

    deleteButton = new JButton();

    doneButton = new JButton();
    GroupLayout gl_buttonPanel = new GroupLayout(buttonPanel);
    gl_buttonPanel.setHorizontalGroup(gl_buttonPanel.createParallelGroup(Alignment.LEADING)
            .addComponent(runButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(addButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(editButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(deleteButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(doneButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    gl_buttonPanel.setVerticalGroup(gl_buttonPanel.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_buttonPanel.createSequentialGroup().addComponent(runButton).addComponent(addButton)
                    .addComponent(editButton).addComponent(deleteButton).addComponent(doneButton)));
    buttonPanel.setLayout(gl_buttonPanel);

    JPanel labelPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) labelPanel.getLayout();
    flowLayout.setHgap(20);
    flowLayout.setAlignment(FlowLayout.LEFT);
    getContentPane().add(labelPanel, BorderLayout.NORTH);

    JLabel actionSetLabel = new JLabel();
    actionSetLabel.setName("actionSetsActionSetsLabel");
    labelPanel.add(actionSetLabel);//from  ww w.j av  a  2 s  .  c  o  m

    actionSetDetailsLabel = new JLabel("");
    labelPanel.add(actionSetDetailsLabel);
}

From source file:logdruid.ui.RecordingList.java

/**
 * Create the panel.//w  ww  .ja v a 2 s.  c om
 */
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:logdruid.ui.DateEditor.java

/**
 * Create the panel.//w  w w  . jav  a  2s  . c o  m
 */
public DateEditor(Repository rep) {
    repository = rep;
    model = new MyTableModel2(data, header);

    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 15, 550, 15 };
    gridBagLayout.rowHeights = new int[] { 152, 300 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0 };
    gridBagLayout.rowWeights = new double[] { 0.0, 1.0 };
    setLayout(gridBagLayout);

    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;
    add(panel_1, gbc_panel_1);
    panel_1.setLayout(new BorderLayout(0, 0));

    table = new JTable(model);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setBorder(UIManager.getBorder("TextPane.border"));
    table.setPreferredScrollableViewportSize(new Dimension(0, 0));
    table.setFillsViewportHeight(true);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            // ((table.getSelectedRow()!=-1)?table.convertRowIndexToModel(table.getSelectedRow()):-1)
            // persist repository
            // display selected row

            if (((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1) >= 0) {
                /*
                 * recEditor = new RecordingEditor(repository
                 * .getRecordings().get(((table.getSelectedRow()!=-1)?table.
                 * convertRowIndexToModel(table.getSelectedRow()):-1)),
                 * repository); jPanelDetail.removeAll();
                 */
                // jPanelDetail.add(recEditor, gbc_jPanelDetail);
                DateFormat df = repository.getDateFormat(
                        ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                                : -1));
                if (df != null) {
                    textFieldName.setText((String) df.getName());
                    textFieldPattern.setText((String) df.getPattern());
                    textField.setText((String) df.getDateFormat());
                }
                // jPanelDetail.revalidate();
                // jPanelDetail.repaint();
                // jPanelDetail.setVisible(true);
                // reloadTable(); those 2 ********
                // jPanelDetail.revalidate();
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    panel_1.add(scrollPane, BorderLayout.CENTER);
    // Set up column sizes.
    initColumnSizes(table);

    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 btnNew = new JButton("New");
    panel.add(btnNew);
    btnNew.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            DateFormat df = new DateFormat("name", "\\w{3}\\s[0-9]{1}/[0-9]{2}/[0-9]{2}\\s\\d\\d:\\d\\d:\\d\\d",
                    "EEE. MM/dd/yy HH:mm:ss");
            repository.addDateFormat(df);
            data.add(new Object[] { df.getName(), df.getPattern(), df.getDateFormat() });
            table.repaint();
        }
    });

    JButton btnDuplicate = new JButton("Duplicate");
    btnDuplicate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1) >= 0) {
                DateFormat df = repository.getDateFormat(
                        ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                                : -1));
                repository.addDateFormat(df);
                reloadTable();
                // data.add(new Object[] { table.getRowCount()+1,
                // df.getName(),df.getDateFormat()});
                table.repaint();
            }
        }
    });
    panel.add(btnDuplicate);

    JButton btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int selectedRow = ((table.getSelectedRow() != -1)
                    ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1);
            if (selectedRow >= 0) {
                repository.deleteDateFormat(
                        ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                                : -1));
                data.remove(
                        ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                                : -1));
                reloadTable();
                table.setRowSelectionInterval(selectedRow, selectedRow);
                table.repaint();
            }
        }
    });
    panel.add(btnDelete);

    jPanelDetail = new JPanel();
    gbc_jPanelDetail = new GridBagConstraints();
    gbc_jPanelDetail.anchor = GridBagConstraints.NORTH;
    gbc_jPanelDetail.fill = GridBagConstraints.HORIZONTAL;
    gbc_jPanelDetail.gridx = 1;
    gbc_jPanelDetail.gridy = 1;
    add(jPanelDetail, gbc_jPanelDetail);
    GridBagLayout gbl_jPanelDetail = new GridBagLayout();
    gbl_jPanelDetail.columnWidths = new int[] { 169 };
    gbl_jPanelDetail.rowHeights = new int[] { 0, 0, 0, 0, 150, 0 };
    gbl_jPanelDetail.columnWeights = new double[] { 1.0, 0.0 };
    gbl_jPanelDetail.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 };
    jPanelDetail.setLayout(gbl_jPanelDetail);

    JPanel panel_2 = new JPanel();
    panel_2.setBorder(null);
    GridBagConstraints gbc_panel_2 = new GridBagConstraints();
    gbc_panel_2.gridwidth = 2;
    gbc_panel_2.anchor = GridBagConstraints.NORTHWEST;
    gbc_panel_2.insets = new Insets(0, 0, 5, 0);
    gbc_panel_2.gridx = 0;
    gbc_panel_2.gridy = 0;
    jPanelDetail.add(panel_2, gbc_panel_2);
    panel_2.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));

    JLabel label = new JLabel("Name");
    panel_2.add(label);

    textFieldName = new JTextField();
    textFieldName.setColumns(20);
    panel_2.add(textFieldName);

    JPanel panel_3 = new JPanel();
    FlowLayout flowLayout_1 = (FlowLayout) panel_3.getLayout();
    flowLayout_1.setAlignment(FlowLayout.LEFT);
    panel_3.setBorder(null);
    GridBagConstraints gbc_panel_3 = new GridBagConstraints();
    gbc_panel_3.insets = new Insets(0, 0, 5, 0);
    gbc_panel_3.gridwidth = 2;
    gbc_panel_3.anchor = GridBagConstraints.NORTHWEST;
    gbc_panel_3.gridx = 0;
    gbc_panel_3.gridy = 1;
    jPanelDetail.add(panel_3, gbc_panel_3);

    labelPattern = new JLabel("Pattern");
    panel_3.add(labelPattern);

    textFieldPattern = new JTextField();
    textFieldPattern.setColumns(40);
    panel_3.add(textFieldPattern);

    JButton btnSave = new JButton("Save");
    btnSave.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DateFormat df1 = repository.getDateFormat(
                    ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                            : -1));
            df1.update(textFieldName.getText(), textFieldPattern.getText(), textField.getText());
            reloadTable();
        }
    });

    JPanel panel_4 = new JPanel();
    FlowLayout flowLayout_2 = (FlowLayout) panel_4.getLayout();
    flowLayout_2.setAlignment(FlowLayout.LEFT);
    GridBagConstraints gbc_panel_4 = new GridBagConstraints();
    gbc_panel_4.anchor = GridBagConstraints.WEST;
    gbc_panel_4.insets = new Insets(0, 0, 5, 5);
    gbc_panel_4.gridx = 0;
    gbc_panel_4.gridy = 2;
    jPanelDetail.add(panel_4, gbc_panel_4);

    JLabel lblFastDateFormat = new JLabel("FastDateFormat");
    panel_4.add(lblFastDateFormat);

    textField = new JTextField();
    panel_4.add(textField);
    textField.setColumns(30);

    JPanel panel_5 = new JPanel();
    FlowLayout flowLayout_3 = (FlowLayout) panel_5.getLayout();
    flowLayout_3.setAlignment(FlowLayout.LEFT);
    GridBagConstraints gbc_panel_5 = new GridBagConstraints();
    gbc_panel_5.insets = new Insets(0, 0, 5, 5);
    gbc_panel_5.fill = GridBagConstraints.BOTH;
    gbc_panel_5.gridx = 0;
    gbc_panel_5.gridy = 3;
    jPanelDetail.add(panel_5, gbc_panel_5);

    JLabel lblSampleLabel = new JLabel("Sample");
    panel_5.add(lblSampleLabel);

    JPanel panel_6 = new JPanel();
    panel_6.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagConstraints gbc_panel_6 = new GridBagConstraints();
    gbc_panel_6.ipady = 1;
    gbc_panel_6.ipadx = 1;
    gbc_panel_6.insets = new Insets(0, 0, 5, 5);
    gbc_panel_6.fill = GridBagConstraints.BOTH;
    gbc_panel_6.gridx = 0;
    gbc_panel_6.gridy = 4;
    jPanelDetail.add(panel_6, gbc_panel_6);
    panel_6.setLayout(new BorderLayout(0, 0));

    JTextPane textPane = new JTextPane();
    textPane.setBackground(UIManager.getColor("windowBorder"));
    panel_6.add(textPane);
    GridBagConstraints gbc_btnSave = new GridBagConstraints();
    gbc_btnSave.anchor = GridBagConstraints.WEST;
    gbc_btnSave.insets = new Insets(0, 0, 0, 5);
    gbc_btnSave.gridx = 0;
    gbc_btnSave.gridy = 5;
    jPanelDetail.add(btnSave, gbc_btnSave);
    reloadTable();
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private JPanel getJPanel1() {
    if (jPanel1 == null) {
        jPanel1 = new JPanel();
        FlowLayout jPanel1Layout = new FlowLayout();
        jPanel1Layout.setHgap(0);
        jPanel1Layout.setVgap(0);//from www .ja v a 2s  .  co  m
        jPanel1Layout.setAlignment(FlowLayout.LEFT);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1.add(getJZoomOutAutoRangeButton());
        jPanel1.add(getJZoomOutButton());
        jPanel1.add(getJButton1());
    }
    return jPanel1;
}

From source file:au.org.ala.delta.intkey.Intkey.java

/**
 * Creates and shows the GUI. Called by the swing application framework
 *//* w ww.  ja v a  2  s.  c o  m*/
@Override
protected void startup() {
    final JFrame mainFrame = getMainFrame();
    _defaultGlassPane = mainFrame.getGlassPane();
    mainFrame.setTitle("Intkey");
    mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    mainFrame.setIconImages(IconHelper.getRedIconList());

    _helpController = new HelpController(HELPSET_PATH);

    _taxonformatter = new ItemFormatter(false, CommentStrippingMode.STRIP_ALL, AngleBracketHandlingMode.REMOVE,
            true, false, true);
    _context = new IntkeyContext(new IntkeyUIInterceptor(this), new DirectivePopulatorInterceptor(this));

    _advancedModeOnlyDynamicButtons = new ArrayList<JButton>();
    _normalModeOnlyDynamicButtons = new ArrayList<JButton>();
    _activeOnlyWhenCharactersUsedButtons = new ArrayList<JButton>();
    _dynamicButtonsFullHelp = new HashMap<JButton, String>();

    ActionMap actionMap = getContext().getActionMap();

    _rootPanel = new JPanel();
    _rootPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    _rootPanel.setBackground(SystemColor.control);
    _rootPanel.setLayout(new BorderLayout(0, 0));

    _globalOptionBar = new JPanel();
    _globalOptionBar.setBorder(new EmptyBorder(0, 5, 0, 5));
    _rootPanel.add(_globalOptionBar, BorderLayout.NORTH);
    _globalOptionBar.setLayout(new BorderLayout(0, 0));

    _pnlDynamicButtons = new JPanel();
    FlowLayout flowLayout_1 = (FlowLayout) _pnlDynamicButtons.getLayout();
    flowLayout_1.setVgap(0);
    flowLayout_1.setHgap(0);
    _globalOptionBar.add(_pnlDynamicButtons, BorderLayout.WEST);

    _btnContextHelp = new JButton();
    _btnContextHelp.setMinimumSize(new Dimension(30, 30));
    _btnContextHelp.setMaximumSize(new Dimension(30, 30));
    _btnContextHelp.setAction(actionMap.get("btnContextHelp"));
    _btnContextHelp.setPreferredSize(new Dimension(30, 30));
    _btnContextHelp.setMargin(new Insets(2, 5, 2, 5));
    _btnContextHelp.addActionListener(actionMap.get("btnContextHelp"));
    _globalOptionBar.add(_btnContextHelp, BorderLayout.EAST);

    _rootSplitPane = new JSplitPane();
    _rootSplitPane.setDividerSize(3);
    _rootSplitPane.setResizeWeight(0.5);
    _rootSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    _rootSplitPane.setContinuousLayout(true);
    _rootPanel.add(_rootSplitPane);

    _innerSplitPaneLeft = new JSplitPane();
    _innerSplitPaneLeft.setMinimumSize(new Dimension(25, 25));
    _innerSplitPaneLeft.setAlignmentX(Component.CENTER_ALIGNMENT);
    _innerSplitPaneLeft.setDividerSize(3);
    _innerSplitPaneLeft.setResizeWeight(0.5);

    _innerSplitPaneLeft.setContinuousLayout(true);
    _innerSplitPaneLeft.setOrientation(JSplitPane.VERTICAL_SPLIT);
    _rootSplitPane.setLeftComponent(_innerSplitPaneLeft);

    _pnlAvailableCharacters = new JPanel();
    _innerSplitPaneLeft.setLeftComponent(_pnlAvailableCharacters);
    _pnlAvailableCharacters.setLayout(new BorderLayout(0, 0));

    _sclPaneAvailableCharacters = new JScrollPane();
    _pnlAvailableCharacters.add(_sclPaneAvailableCharacters, BorderLayout.CENTER);

    _listAvailableCharacters = new JList();
    // _listAvailableCharacters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _listAvailableCharacters.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    _listAvailableCharacters.setCellRenderer(_availableCharactersListCellRenderer);
    _listAvailableCharacters.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                int selectedIndex = _listAvailableCharacters.getSelectedIndex();
                if (selectedIndex >= 0) {
                    try {
                        Character ch = (Character) _availableCharacterListModel.getElementAt(selectedIndex);
                        executeDirective(new UseDirective(), Integer.toString(ch.getCharacterId()));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
    });

    _sclPaneAvailableCharacters.setViewportView(_listAvailableCharacters);

    _pnlAvailableCharactersHeader = new JPanel();
    _pnlAvailableCharacters.add(_pnlAvailableCharactersHeader, BorderLayout.NORTH);
    _pnlAvailableCharactersHeader.setLayout(new BorderLayout(0, 0));

    _lblNumAvailableCharacters = new JLabel();
    _lblNumAvailableCharacters.setBorder(new EmptyBorder(0, 5, 0, 0));
    _lblNumAvailableCharacters.setFont(new Font("Tahoma", Font.PLAIN, 15));
    _lblNumAvailableCharacters.setText(MessageFormat.format(availableCharactersCaption, 0));
    _pnlAvailableCharactersHeader.add(_lblNumAvailableCharacters, BorderLayout.WEST);

    _pnlAvailableCharactersButtons = new JPanel();
    FlowLayout flowLayout = (FlowLayout) _pnlAvailableCharactersButtons.getLayout();
    flowLayout.setVgap(2);
    flowLayout.setHgap(2);
    _pnlAvailableCharactersHeader.add(_pnlAvailableCharactersButtons, BorderLayout.EAST);

    // All toolbar buttons should be disabled until a dataset is loaded.
    _btnRestart = new JButton();
    _btnRestart.setAction(actionMap.get("btnRestart"));
    _btnRestart.setPreferredSize(new Dimension(30, 30));
    _btnRestart.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnRestart);

    _btnBestOrder = new JButton();
    _btnBestOrder.setAction(actionMap.get("btnBestOrder"));
    _btnBestOrder.setPreferredSize(new Dimension(30, 30));
    _btnBestOrder.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnBestOrder);

    _btnSeparate = new JButton();
    _btnSeparate.setAction(actionMap.get("btnSeparate"));
    _btnSeparate.setVisible(_advancedMode);
    _btnSeparate.setPreferredSize(new Dimension(30, 30));
    _btnSeparate.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnSeparate);

    _btnNaturalOrder = new JButton();
    _btnNaturalOrder.setAction(actionMap.get("btnNaturalOrder"));
    _btnNaturalOrder.setPreferredSize(new Dimension(30, 30));
    _btnNaturalOrder.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnNaturalOrder);

    _btnDiffSpecimenTaxa = new JButton();
    _btnDiffSpecimenTaxa.setAction(actionMap.get("btnDiffSpecimenTaxa"));
    _btnDiffSpecimenTaxa.setEnabled(false);
    _btnDiffSpecimenTaxa.setPreferredSize(new Dimension(30, 30));
    _pnlAvailableCharactersButtons.add(_btnDiffSpecimenTaxa);

    _btnSetTolerance = new JButton();
    _btnSetTolerance.setAction(actionMap.get("btnSetTolerance"));
    _btnSetTolerance.setPreferredSize(new Dimension(30, 30));
    _btnSetTolerance.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnSetTolerance);

    _btnSetMatch = new JButton();
    _btnSetMatch.setAction(actionMap.get("btnSetMatch"));
    _btnSetMatch.setVisible(_advancedMode);
    _btnSetMatch.setPreferredSize(new Dimension(30, 30));
    _btnSetMatch.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnSetMatch);

    _btnSubsetCharacters = new JButton();
    _btnSubsetCharacters.setAction(actionMap.get("btnSubsetCharacters"));
    _btnSubsetCharacters.setPreferredSize(new Dimension(30, 30));
    _btnSubsetCharacters.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnSubsetCharacters);

    _btnFindCharacter = new JButton();
    _btnFindCharacter.setAction(actionMap.get("btnFindCharacter"));
    _btnFindCharacter.setPreferredSize(new Dimension(30, 30));
    _btnFindCharacter.setEnabled(false);
    _pnlAvailableCharactersButtons.add(_btnFindCharacter);

    _pnlAvailableCharactersButtons.setEnabled(false);

    _pnlUsedCharacters = new JPanel();
    _innerSplitPaneLeft.setRightComponent(_pnlUsedCharacters);
    _pnlUsedCharacters.setLayout(new BorderLayout(0, 0));

    _sclPnUsedCharacters = new JScrollPane();
    _pnlUsedCharacters.add(_sclPnUsedCharacters, BorderLayout.CENTER);

    _listUsedCharacters = new JList();
    _listUsedCharacters.setCellRenderer(_usedCharactersListCellRenderer);
    _listUsedCharacters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _listUsedCharacters.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                int selectedIndex = _listUsedCharacters.getSelectedIndex();
                if (selectedIndex >= 0) {
                    try {
                        Attribute attr = (Attribute) _usedCharacterListModel.getElementAt(selectedIndex);

                        if (_context.charactersFixed() && _context.getFixedCharactersList()
                                .contains(attr.getCharacter().getCharacterId())) {
                            return;
                        }

                        executeDirective(new ChangeDirective(),
                                Integer.toString(attr.getCharacter().getCharacterId()));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
    });

    _sclPnUsedCharacters.setViewportView(_listUsedCharacters);

    _pnlUsedCharactersHeader = new JPanel();
    _pnlUsedCharacters.add(_pnlUsedCharactersHeader, BorderLayout.NORTH);
    _pnlUsedCharactersHeader.setLayout(new BorderLayout(0, 0));

    _lblNumUsedCharacters = new JLabel();
    _lblNumUsedCharacters.setBorder(new EmptyBorder(7, 5, 7, 0));
    _lblNumUsedCharacters.setFont(new Font("Tahoma", Font.PLAIN, 15));
    _lblNumUsedCharacters.setText(MessageFormat.format(usedCharactersCaption, 0));
    _pnlUsedCharactersHeader.add(_lblNumUsedCharacters, BorderLayout.WEST);

    _innerSplitPaneRight = new JSplitPane();
    _innerSplitPaneRight.setMinimumSize(new Dimension(25, 25));
    _innerSplitPaneRight.setDividerSize(3);
    _innerSplitPaneRight.setResizeWeight(0.5);
    _innerSplitPaneRight.setContinuousLayout(true);
    _innerSplitPaneRight.setOrientation(JSplitPane.VERTICAL_SPLIT);
    _rootSplitPane.setRightComponent(_innerSplitPaneRight);

    _pnlRemainingTaxa = new JPanel();
    _innerSplitPaneRight.setLeftComponent(_pnlRemainingTaxa);
    _pnlRemainingTaxa.setLayout(new BorderLayout(0, 0));

    _sclPnRemainingTaxa = new JScrollPane();
    _pnlRemainingTaxa.add(_sclPnRemainingTaxa, BorderLayout.CENTER);

    _listRemainingTaxa = new JList();

    _listRemainingTaxa.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                displayInfoForSelectedTaxa();
            }
        }
    });

    _sclPnRemainingTaxa.setViewportView(_listRemainingTaxa);

    _pnlRemainingTaxaHeader = new JPanel();
    _pnlRemainingTaxa.add(_pnlRemainingTaxaHeader, BorderLayout.NORTH);
    _pnlRemainingTaxaHeader.setLayout(new BorderLayout(0, 0));

    _lblNumRemainingTaxa = new JLabel();
    _lblNumRemainingTaxa.setBorder(new EmptyBorder(0, 5, 0, 0));
    _lblNumRemainingTaxa.setFont(new Font("Tahoma", Font.PLAIN, 15));
    _lblNumRemainingTaxa.setText(MessageFormat.format(remainingTaxaCaption, 0));
    _pnlRemainingTaxaHeader.add(_lblNumRemainingTaxa, BorderLayout.WEST);

    _pnlRemainingTaxaButtons = new JPanel();
    FlowLayout fl_pnlRemainingTaxaButtons = (FlowLayout) _pnlRemainingTaxaButtons.getLayout();
    fl_pnlRemainingTaxaButtons.setVgap(2);
    fl_pnlRemainingTaxaButtons.setHgap(2);
    _pnlRemainingTaxaHeader.add(_pnlRemainingTaxaButtons, BorderLayout.EAST);

    // All toolbar buttons should be disabled until a dataset is loaded.
    _btnTaxonInfo = new JButton();
    _btnTaxonInfo.setAction(actionMap.get("btnTaxonInfo"));
    _btnTaxonInfo.setPreferredSize(new Dimension(30, 30));
    _btnTaxonInfo.setEnabled(false);
    _pnlRemainingTaxaButtons.add(_btnTaxonInfo);

    _btnDiffTaxa = new JButton();
    _btnDiffTaxa.setAction(actionMap.get("btnDiffTaxa"));
    _btnDiffTaxa.setPreferredSize(new Dimension(30, 30));
    _btnDiffTaxa.setEnabled(false);
    _pnlRemainingTaxaButtons.add(_btnDiffTaxa);

    _btnSubsetTaxa = new JButton();
    _btnSubsetTaxa.setAction(actionMap.get("btnSubsetTaxa"));
    _btnSubsetTaxa.setPreferredSize(new Dimension(30, 30));
    _btnSubsetTaxa.setEnabled(false);
    _pnlRemainingTaxaButtons.add(_btnSubsetTaxa);

    _btnFindTaxon = new JButton();
    _btnFindTaxon.setAction(actionMap.get("btnFindTaxon"));
    _btnFindTaxon.setPreferredSize(new Dimension(30, 30));
    _btnFindTaxon.setEnabled(false);
    _pnlRemainingTaxaButtons.add(_btnFindTaxon);

    _pnlEliminatedTaxa = new JPanel();
    _innerSplitPaneRight.setRightComponent(_pnlEliminatedTaxa);
    _pnlEliminatedTaxa.setLayout(new BorderLayout(0, 0));

    _sclPnEliminatedTaxa = new JScrollPane();
    _pnlEliminatedTaxa.add(_sclPnEliminatedTaxa, BorderLayout.CENTER);

    _listEliminatedTaxa = new JList();

    _listEliminatedTaxa.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                displayInfoForSelectedTaxa();
            }
        }
    });

    _sclPnEliminatedTaxa.setViewportView(_listEliminatedTaxa);

    _pnlEliminatedTaxaHeader = new JPanel();
    _pnlEliminatedTaxa.add(_pnlEliminatedTaxaHeader, BorderLayout.NORTH);
    _pnlEliminatedTaxaHeader.setLayout(new BorderLayout(0, 0));

    _lblEliminatedTaxa = new JLabel();
    _lblEliminatedTaxa.setBorder(new EmptyBorder(7, 5, 7, 0));
    _lblEliminatedTaxa.setFont(new Font("Tahoma", Font.PLAIN, 15));
    _lblEliminatedTaxa.setText(MessageFormat.format(eliminatedTaxaCaption, 0));
    _pnlEliminatedTaxaHeader.add(_lblEliminatedTaxa, BorderLayout.WEST);

    JMenuBar menuBar = buildMenus(_advancedMode);
    getMainView().setMenuBar(menuBar);

    _txtFldCmdBar = new JTextField();
    _txtFldCmdBar.setCaretColor(Color.WHITE);
    _txtFldCmdBar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            String cmdStr = _txtFldCmdBar.getText();

            cmdStr = cmdStr.trim();
            if (_cmdMenus.containsKey(cmdStr)) {
                JMenu cmdMenu = _cmdMenus.get(cmdStr);
                cmdMenu.doClick();
            } else {
                _context.parseAndExecuteDirective(cmdStr);
            }
            _txtFldCmdBar.setText(null);
        }
    });

    _txtFldCmdBar.setFont(new Font("Courier New", Font.BOLD, 13));
    _txtFldCmdBar.setForeground(SystemColor.text);
    _txtFldCmdBar.setBackground(Color.BLACK);
    _txtFldCmdBar.setOpaque(true);
    _txtFldCmdBar.setVisible(_advancedMode);
    _rootPanel.add(_txtFldCmdBar, BorderLayout.SOUTH);
    _txtFldCmdBar.setColumns(10);

    _logDialog = new RtfReportDisplayDialog(getMainFrame(), new SimpleRtfEditorKit(null), null, logDialogTitle);

    // Set context-sensitive help keys for toolbar buttons
    _helpController.setHelpKeyForComponent(_btnRestart, HELP_ID_CHARACTERS_TOOLBAR_RESTART);
    _helpController.setHelpKeyForComponent(_btnBestOrder, HELP_ID_CHARACTERS_TOOLBAR_BEST);
    _helpController.setHelpKeyForComponent(_btnSeparate, HELP_ID_CHARACTERS_TOOLBAR_SEPARATE);
    _helpController.setHelpKeyForComponent(_btnNaturalOrder, HELP_ID_CHARACTERS_TOOLBAR_NATURAL);
    _helpController.setHelpKeyForComponent(_btnDiffSpecimenTaxa,
            HELP_ID_CHARACTERS_TOOLBAR_DIFF_SPECIMEN_REMAINING);
    _helpController.setHelpKeyForComponent(_btnSetTolerance, HELP_ID_CHARACTERS_TOOLBAR_TOLERANCE);
    _helpController.setHelpKeyForComponent(_btnSetMatch, HELP_ID_CHARACTERS_TOOLBAR_SET_MATCH);
    _helpController.setHelpKeyForComponent(_btnSubsetCharacters, HELP_ID_CHARACTERS_TOOLBAR_SUBSET_CHARACTERS);
    _helpController.setHelpKeyForComponent(_btnFindCharacter, HELP_ID_CHARACTERS_TOOLBAR_FIND_CHARACTERS);

    _helpController.setHelpKeyForComponent(_btnTaxonInfo, HELP_ID_TAXA_TOOLBAR_INFO);
    _helpController.setHelpKeyForComponent(_btnDiffTaxa, HELP_ID_TAXA_TOOLBAR_DIFF_TAXA);
    _helpController.setHelpKeyForComponent(_btnSubsetTaxa, HELP_ID_TAXA_TOOLBAR_SUBSET_TAXA);
    _helpController.setHelpKeyForComponent(_btnFindTaxon, HELP_ID_TAXA_TOOLBAR_FIND_TAXA);

    // This mouse listener on the default glasspane is to assist with
    // context senstive help. It intercepts the mouse events,
    // determines what component was being clicked on, then takes the
    // appropriate action to provide help for the component
    _defaultGlassPane.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            // Determine what point has been clicked on
            Point glassPanePoint = e.getPoint();
            Point containerPoint = SwingUtilities.convertPoint(getMainFrame().getGlassPane(), glassPanePoint,
                    getMainFrame().getContentPane());
            Component component = SwingUtilities.getDeepestComponentAt(getMainFrame().getContentPane(),
                    containerPoint.x, containerPoint.y);

            // Get the java help ID for this component. If none has been
            // defined, this will be null
            String helpID = _helpController.getHelpKeyForComponent(component);

            // change the cursor back to the normal one and take down the
            // classpane
            mainFrame.setCursor(Cursor.getDefaultCursor());
            mainFrame.getGlassPane().setVisible(false);

            // If a help ID was found, display the related help page in the
            // help viewer
            if (_helpController.getHelpKeyForComponent(component) != null) {
                _helpController.helpAction().actionPerformed(new ActionEvent(component, 0, null));
                _helpController.displayHelpTopic(mainFrame, helpID);
            } else {
                // If a dynamically-defined toolbar button was clicked, show
                // the help for this button in the ToolbarHelpDialog.
                if (component instanceof JButton) {
                    JButton button = (JButton) component;
                    if (_dynamicButtonsFullHelp.containsKey(button)) {
                        String fullHelpText = _dynamicButtonsFullHelp.get(button);
                        if (fullHelpText == null) {
                            fullHelpText = noHelpAvailableCaption;
                        }
                        RTFBuilder builder = new RTFBuilder();
                        builder.startDocument();
                        builder.appendText(fullHelpText);
                        builder.endDocument();
                        ToolbarHelpDialog dlg = new ToolbarHelpDialog(mainFrame, builder.toString(),
                                button.getIcon());
                        show(dlg);
                    }
                }
            }
        }
    });

    show(_rootPanel);
}

From source file:com.peterbochs.PeterBochsDebugger.java

private JPanel getJPanel25() {
    if (jPanel25 == null) {
        jPanel25 = new JPanel();
        FlowLayout jPanel25Layout = new FlowLayout();
        jPanel25Layout.setHgap(0);
        jPanel25Layout.setVgap(0);/*  w  ww.ja va  2  s. c  o m*/
        jPanel25Layout.setAlignment(FlowLayout.LEFT);
        jPanel25.setLayout(jPanel25Layout);
        {
            jStatusLabel = new JLabel();
            jPanel25.add(jStatusLabel);
            jStatusLabel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
            jStatusLabel.setForeground(new java.awt.Color(255, 0, 0));
        }
        jPanel25.add(getJCPUModeLabel());
        jPanel25.add(getJBochsVersionLabel());
        jPanel25.add(getJLatestVersionLabel());
    }
    return jPanel25;
}