Search in sources :

Example 1 with JTable

use of javax.swing.JTable in project qi4j-sdk by Qi4j.

the class APIPane method $$$setupUI$$$.

/**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     */
private void $$$setupUI$$$() {
    contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout(0, 0));
    final JScrollPane scrollPane1 = new JScrollPane();
    contentPane.add(scrollPane1, BorderLayout.CENTER);
    apiTable = new JTable();
    apiTable.setShowVerticalLines(true);
    scrollPane1.setViewportView(apiTable);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable)

Example 2 with JTable

use of javax.swing.JTable in project pcgen by PCGen.

the class TableUtils method createDefaultTable.

public static JTable createDefaultTable() {
    JTable table = new JTable();
    table.setFillsViewportHeight(true);
    return table;
}
Also used : JTable(javax.swing.JTable)

Example 3 with JTable

use of javax.swing.JTable in project pcgen by PCGen.

the class CampaignPanel method setupDisplay.

/**
	 * @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
	 */
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(new GridBagLayout());
    JLabel introLabel = new JLabel("Please select the Campaign(s) to Convert:");
    GridBagConstraints gbc = new GridBagConstraints();
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
    gbc.insets = new Insets(25, 25, 5, 25);
    panel.add(introLabel, gbc);
    final CampaignTableModel model = new CampaignTableModel(gameModeCampaigns, folderName);
    final JTable table = new JTable(model) {

        //Implement table cell tool tips.
        @Override
        public String getToolTipText(MouseEvent e) {
            java.awt.Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);
            int colIndex = columnAtPoint(p);
            String tip = String.valueOf(getValueAt(rowIndex, colIndex));
            return tip;
        }
    };
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent event) {
            pc.removeListFor(ListKey.CAMPAIGN);
            int[] selRows = table.getSelectedRows();
            if (selRows.length == 0) {
                saveSourceSelection(pc);
                fireProgressEvent(ProgressEvent.NOT_ALLOWED);
            } else {
                for (int row : selRows) {
                    Campaign selCampaign = (Campaign) model.getValueAt(row, 0);
                    pc.addToListFor(ListKey.CAMPAIGN, selCampaign);
                }
                saveSourceSelection(pc);
                fireProgressEvent(ProgressEvent.ALLOWED);
            }
        }
    });
    JScrollPane listScroller = new JScrollPane(table);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0);
    gbc.fill = GridBagConstraints.BOTH;
    panel.add(listScroller, gbc);
    initSourceSelection(model, table);
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JLabel(javax.swing.JLabel) ListSelectionListener(javax.swing.event.ListSelectionListener) Campaign(pcgen.core.Campaign) JTable(javax.swing.JTable)

Example 4 with JTable

use of javax.swing.JTable in project pcgen by PCGen.

the class CharacterHPDialog method initComponents.

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == 5) {
                //TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row)).getHD();
                int max = NumberUtils.toInt(hd);
                return new IntegerEditor(1, max);
            } else {
                return super.getCellEditor(row, column);
            }
        }
    };
    table.setDefaultRenderer(JButton.class, new Renderer());
    table.setDefaultEditor(JButton.class, new Editor());
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new IntegerEditor(1, 10).getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);
    Box box = Box.createHorizontalBox();
    box.add(new JLabel("Total Hp:"));
    box.add(Box.createHorizontalStrut(3));
    final ReferenceListener<Integer> hpListener = new ReferenceListener<Integer>() {

        @Override
        public void referenceChanged(ReferenceEvent<Integer> e) {
            totalHp.setText(e.getNewReference().toString());
        }
    };
    ReferenceFacade<Integer> hpRef = character.getTotalHPRef();
    totalHp.setText(hpRef.get().toString());
    hpRef.addReferenceListener(hpListener);
    box.add(totalHp);
    box.add(Box.createHorizontalStrut(5));
    JButton button = new JButton("Reroll All");
    button.setActionCommand("Reroll");
    button.addActionListener(this);
    box.add(button);
    box.add(Box.createHorizontalGlue());
    button = new JButton("Close");
    button.setActionCommand("Close");
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
            character.getTotalHPRef().removeReferenceListener(hpListener);
        }
    });
    Utility.installEscapeCloseOperation(this);
}
Also used : JScrollPane(javax.swing.JScrollPane) IntegerEditor(pcgen.gui2.util.table.IntegerEditor) JButton(javax.swing.JButton) JTableHeader(javax.swing.table.JTableHeader) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Box(javax.swing.Box) ReferenceListener(pcgen.facade.util.event.ReferenceListener) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) ReferenceEvent(pcgen.facade.util.event.ReferenceEvent) JTable(javax.swing.JTable) WindowEvent(java.awt.event.WindowEvent) TableCellRenderer(javax.swing.table.TableCellRenderer) TableCellEditor(javax.swing.table.TableCellEditor) AbstractCellEditor(javax.swing.AbstractCellEditor) IntegerEditor(pcgen.gui2.util.table.IntegerEditor)

Example 5 with JTable

use of javax.swing.JTable in project pcgen by PCGen.

the class PostLevelUpDialog method initComponents.

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
                //TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row + oldLevel)).getHD();
                int max = NumberUtils.toInt(hd);
                return new SpinnerEditor(new SpinnerNumberModel(1, 1, max, 1));
            }
            return super.getCellEditor(row, column);
        }

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
                return new SpinnerRenderer();
            }
            return super.getCellRenderer(row, column);
        }
    };
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new JSpinner().getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    //$NON-NLS-1$
    JButton button = new JButton(LanguageBundle.getString("in_close"));
    //$NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
    //$NON-NLS-1$
    button.setActionCommand("Close");
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
        }
    });
    Utility.installEscapeCloseOperation(this);
}
Also used : JScrollPane(javax.swing.JScrollPane) SpinnerEditor(pcgen.gui2.util.table.TableCellUtilities.SpinnerEditor) JButton(javax.swing.JButton) JTableHeader(javax.swing.table.JTableHeader) WindowAdapter(java.awt.event.WindowAdapter) Box(javax.swing.Box) SpinnerRenderer(pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer) SpinnerNumberModel(javax.swing.SpinnerNumberModel) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) WindowEvent(java.awt.event.WindowEvent) JSpinner(javax.swing.JSpinner)

Aggregations

JTable (javax.swing.JTable)584 JScrollPane (javax.swing.JScrollPane)282 JPanel (javax.swing.JPanel)217 Dimension (java.awt.Dimension)145 JButton (javax.swing.JButton)139 BorderLayout (java.awt.BorderLayout)133 JLabel (javax.swing.JLabel)129 ActionEvent (java.awt.event.ActionEvent)109 ActionListener (java.awt.event.ActionListener)81 TableColumn (javax.swing.table.TableColumn)79 DefaultTableModel (javax.swing.table.DefaultTableModel)75 Component (java.awt.Component)66 BoxLayout (javax.swing.BoxLayout)66 FlowLayout (java.awt.FlowLayout)58 MouseEvent (java.awt.event.MouseEvent)58 JTextField (javax.swing.JTextField)57 TableColumnModel (javax.swing.table.TableColumnModel)52 GridBagConstraints (java.awt.GridBagConstraints)46 TableCellRenderer (javax.swing.table.TableCellRenderer)43 Test (org.junit.Test)43