Search in sources :

Example 1 with SpinnerRenderer

use of pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer in project pcgen by PCGen.

the class SkillInfoTab method initComponents.

private void initComponents() {
    setOrientation(VERTICAL_SPLIT);
    setResizeWeight(0.70);
    JSpinner spinner = new JSpinner();
    //$NON-NLS-1$
    spinner.setEditor(new JSpinner.NumberEditor(spinner, "#0.#"));
    skillTable.setDefaultRenderer(Float.class, new SpinnerRenderer(spinner));
    skillTable.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    skillTable.setDefaultRenderer(String.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    skillTable.setRowHeight(26);
    FilterBar<CharacterFacade, SkillFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    //$NON-NLS-1$
    cFilterButton.setText(LanguageBundle.getString("in_classString"));
    cFilterButton.setEnabled(false);
    filterBar.addDisplayableFilter(cFilterButton);
    //$NON-NLS-1$
    trainedFilterButton.setText(LanguageBundle.getString("in_trained"));
    trainedFilterButton.setEnabled(false);
    filterBar.addDisplayableFilter(trainedFilterButton);
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(skillTable, filterBar);
    availPanel.setPreferredSize(new Dimension(650, 300));
    JScrollPane tableScrollPane;
    JPanel tablePanel = new JPanel(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    constraints.fill = java.awt.GridBagConstraints.BOTH;
    constraints.weightx = 1.0;
    constraints.ipady = 0;
    constraints.weighty = 1.0;
    SkillPointTableModel.initializeTable(skillpointTable);
    tableScrollPane = new JScrollPane(skillpointTable);
    tablePanel.add(tableScrollPane, constraints);
    htmlPane.setOpaque(false);
    htmlPane.setEditable(false);
    htmlPane.setFocusable(false);
    //$NON-NLS-1$
    htmlPane.setContentType("text/html");
    skillFilterBox.setRenderer(new DefaultListCellRenderer());
    JScrollPane selScrollPane = new JScrollPane(htmlPane);
    JPanel skillPanel = new JPanel(new BorderLayout());
    skillPanel.add(skillFilterBox, BorderLayout.NORTH);
    skillPanel.add(selScrollPane, BorderLayout.CENTER);
    selScrollPane.setPreferredSize(new Dimension(530, 300));
    FlippingSplitPane topPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, availPanel, skillPanel, "SkillTop");
    setTopComponent(topPane);
    FlippingSplitPane bottomPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, "SkillBottom");
    bottomPane.setLeftComponent(tablePanel);
    tablePanel.setPreferredSize(new Dimension(650, 100));
    bottomPane.setRightComponent(infoPane);
    infoPane.setPreferredSize(new Dimension(530, 100));
    setBottomComponent(bottomPane);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) SkillFacade(pcgen.facade.core.SkillFacade) Dimension(java.awt.Dimension) SpinnerRenderer(pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer) CharacterFacade(pcgen.facade.core.CharacterFacade) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) TableCellUtilities(pcgen.gui2.util.table.TableCellUtilities) FilterBar(pcgen.gui2.filter.FilterBar) BorderLayout(java.awt.BorderLayout) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) JSpinner(javax.swing.JSpinner) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel)

Example 2 with SpinnerRenderer

use of pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer 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

BorderLayout (java.awt.BorderLayout)2 JScrollPane (javax.swing.JScrollPane)2 JSpinner (javax.swing.JSpinner)2 SpinnerRenderer (pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer)2 Container (java.awt.Container)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 Box (javax.swing.Box)1 DefaultListCellRenderer (javax.swing.DefaultListCellRenderer)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 JTable (javax.swing.JTable)1 SpinnerNumberModel (javax.swing.SpinnerNumberModel)1 JTableHeader (javax.swing.table.JTableHeader)1 CharacterFacade (pcgen.facade.core.CharacterFacade)1 SkillFacade (pcgen.facade.core.SkillFacade)1 FilterBar (pcgen.gui2.filter.FilterBar)1