Search in sources :

Example 11 with JTable

use of javax.swing.JTable in project smile by haifengl.

the class PlotCanvas method createPropertyDialog.

/**
     * Creates the property dialog.
     * @return the property dialog.
     */
private JDialog createPropertyDialog() {
    Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, this);
    JDialog dialog = new JDialog(frame, "Plot Properties", true);
    Action okAction = new PropertyDialogOKAction(dialog);
    Action cancelAction = new PropertyDialogCancelAction(dialog);
    JButton okButton = new JButton(okAction);
    JButton cancelButton = new JButton(cancelAction);
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
    String[] columnNames = { "Property", "Value" };
    if (base.dimension == 2) {
        Object[][] data = { { "Title", title }, { "Title Font", titleFont }, { "Title Color", titleColor }, { "X Axis Title", getAxis(0).getAxisLabel() }, { "X Axis Range", new double[] { base.getLowerBounds()[0], base.getUpperBounds()[0] } }, { "Y Axis Title", getAxis(1).getAxisLabel() }, { "Y Axis Range", new double[] { base.getLowerBounds()[1], base.getUpperBounds()[1] } } };
        propertyTable = new Table(data, columnNames);
    } else {
        Object[][] data = { { "Title", title }, { "Title Font", titleFont }, { "Title Color", titleColor }, { "X Axis Title", getAxis(0).getAxisLabel() }, { "X Axis Range", new double[] { base.getLowerBounds()[0], base.getUpperBounds()[0] } }, { "Y Axis Title", getAxis(1).getAxisLabel() }, { "Y Axis Range", new double[] { base.getLowerBounds()[1], base.getUpperBounds()[1] } }, { "Z Axis Title", getAxis(2).getAxisLabel() }, { "Z Axis Range", new double[] { base.getLowerBounds()[2], base.getUpperBounds()[2] } } };
        propertyTable = new Table(data, columnNames);
    }
    // There is a known issue with JTables whereby the changes made in a
    // cell editor are not committed when focus is lost.
    // This can result in the table staying in 'edit mode' with the stale
    // value in the cell being edited still showing, although the change
    // has not actually been committed to the model.
    //
    // In fact what should happen is for the method stopCellEditing()
    // on CellEditor to be called when focus is lost.
    // So the editor can choose whether to accept the new value and stop
    // editing, or have the editing cancelled without committing.
    // There is a magic property which you have to set on the JTable
    // instance to turn this feature on.
    propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    propertyTable.setFillsViewportHeight(true);
    JScrollPane tablePanel = new JScrollPane(propertyTable);
    dialog.getContentPane().add(tablePanel, BorderLayout.CENTER);
    dialog.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Frame(java.awt.Frame) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) FlowLayout(java.awt.FlowLayout) JTable(javax.swing.JTable) Table(smile.swing.Table) ActionMap(javax.swing.ActionMap) JButton(javax.swing.JButton) InputMap(javax.swing.InputMap) JDialog(javax.swing.JDialog)

Example 12 with JTable

use of javax.swing.JTable in project gitblit by gitblit.

the class Utils method newTable.

public static JTable newTable(TableModel model, String datePattern, final RowRenderer rowRenderer) {
    JTable table;
    if (rowRenderer == null) {
        table = new JTable(model);
    } else {
        table = new JTable(model) {

            @Override
            public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
                Component c = super.prepareRenderer(renderer, row, column);
                boolean isSelected = isCellSelected(row, column);
                rowRenderer.prepareRow(c, isSelected, row, column);
                return c;
            }
        };
    }
    table.setRowHeight(table.getFont().getSize() + 8);
    table.setCellSelectionEnabled(false);
    table.setRowSelectionAllowed(true);
    table.getTableHeader().setReorderingAllowed(false);
    table.setGridColor(new Color(0xd9d9d9));
    table.setBackground(Color.white);
    table.setDefaultRenderer(Date.class, new DateCellRenderer(datePattern, Color.orange.darker()));
    return table;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) JTable(javax.swing.JTable) Color(java.awt.Color) Component(java.awt.Component)

Example 13 with JTable

use of javax.swing.JTable in project gitblit by gitblit.

the class StatusPanel method initialize.

private void initialize() {
    JButton refreshStatus = new JButton(Translation.get("gb.refresh"));
    refreshStatus.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            refreshStatus();
        }
    });
    version = new JLabel();
    releaseDate = new JLabel();
    bootDate = new JLabel();
    url = new JLabel();
    servletContainer = new JLabel();
    heapMaximum = new JLabel();
    heapAllocated = new JLabel();
    heapUsed = new JLabel();
    JPanel fieldsPanel = new JPanel(new GridLayout(0, 1, 0, Utils.MARGIN)) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return Utils.INSETS;
        }
    };
    fieldsPanel.add(createFieldPanel("gb.version", version));
    fieldsPanel.add(createFieldPanel("gb.releaseDate", releaseDate));
    fieldsPanel.add(createFieldPanel("gb.bootDate", bootDate));
    fieldsPanel.add(createFieldPanel("gb.url", url));
    fieldsPanel.add(createFieldPanel("gb.servletContainer", servletContainer));
    fieldsPanel.add(createFieldPanel("gb.heapUsed", heapUsed));
    fieldsPanel.add(createFieldPanel("gb.heapAllocated", heapAllocated));
    fieldsPanel.add(createFieldPanel("gb.heapMaximum", heapMaximum));
    tableModel = new PropertiesTableModel();
    JTable propertiesTable = Utils.newTable(tableModel, Utils.DATE_FORMAT);
    String name = propertiesTable.getColumnName(PropertiesTableModel.Columns.Name.ordinal());
    NameRenderer nameRenderer = new NameRenderer();
    propertiesTable.getColumn(name).setCellRenderer(nameRenderer);
    JPanel centerPanel = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    centerPanel.add(fieldsPanel, BorderLayout.NORTH);
    centerPanel.add(new JScrollPane(propertiesTable), BorderLayout.CENTER);
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.CENTER, Utils.MARGIN, 0));
    controls.add(refreshStatus);
    header = new HeaderPanel(Translation.get("gb.status"), "health_16x16.png");
    setLayout(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    add(header, BorderLayout.NORTH);
    add(centerPanel, BorderLayout.CENTER);
    add(controls, BorderLayout.SOUTH);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) GridLayout(java.awt.GridLayout) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable)

Example 14 with JTable

use of javax.swing.JTable in project binnavi by google.

the class CGraphSelectionDialog method createGui.

/**
   * Creates the GUI of the dialog.
   *
   * @param views The views to be shown in the table.
   */
private void createGui(final List<INaviView> views) {
    setLayout(new BorderLayout());
    final JTextArea field = new JTextArea("The debugger stopped at an instruction that does not belong to any open graphs.\nPlease select a graph from the list to continue debugging.");
    field.setEditable(false);
    add(field, BorderLayout.NORTH);
    m_table = new JTable(new CGraphSelectionTableModel(views));
    m_table.addMouseListener(m_listener);
    add(new JScrollPane(m_table), BorderLayout.CENTER);
    final CPanelTwoButtons panel = new CPanelTwoButtons(m_listener, "OK", "Cancel");
    add(panel, BorderLayout.SOUTH);
    setSize(500, 300);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) CPanelTwoButtons(com.google.security.zynamics.zylib.gui.CPanelTwoButtons)

Example 15 with JTable

use of javax.swing.JTable in project binnavi by google.

the class CAddressSelectionDialog method createGui.

/**
   * Creates the GUI of the dialog.
   */
private void createGui(final List<INaviModule> modules) {
    setLayout(new BorderLayout());
    final JTextArea field = new JTextArea("The current graph has more then one module.\nPlease choose the one to search in.");
    field.setEditable(false);
    add(field, BorderLayout.NORTH);
    m_table = new JTable(new CAddressSelectionTableModel(modules));
    m_table.addMouseListener(m_listener);
    add(new JScrollPane(m_table), BorderLayout.CENTER);
    final CPanelTwoButtons panel = new CPanelTwoButtons(m_listener, "OK", "Cancel");
    add(panel, BorderLayout.SOUTH);
    setSize(500, 300);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) CPanelTwoButtons(com.google.security.zynamics.zylib.gui.CPanelTwoButtons)

Aggregations

JTable (javax.swing.JTable)223 JScrollPane (javax.swing.JScrollPane)127 JPanel (javax.swing.JPanel)100 JButton (javax.swing.JButton)68 JLabel (javax.swing.JLabel)68 Dimension (java.awt.Dimension)60 BorderLayout (java.awt.BorderLayout)58 BoxLayout (javax.swing.BoxLayout)48 ActionEvent (java.awt.event.ActionEvent)46 TableColumn (javax.swing.table.TableColumn)43 ActionListener (java.awt.event.ActionListener)38 TableColumnModel (javax.swing.table.TableColumnModel)33 FlowLayout (java.awt.FlowLayout)28 JTextField (javax.swing.JTextField)28 JComboBox (javax.swing.JComboBox)24 TableRowSorter (javax.swing.table.TableRowSorter)23 MouseEvent (java.awt.event.MouseEvent)21 ArrayList (java.util.ArrayList)16 Container (java.awt.Container)15 DefaultCellEditor (javax.swing.DefaultCellEditor)15