Search in sources :

Example 51 with JTableHeader

use of javax.swing.table.JTableHeader in project pcgen by PCGen.

the class ClassLevelTableModel method initializeTable.

public static void initializeTable(JTable classLevelTable) {
    JTableHeader tableHeader = classLevelTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    TableColumnModel columnModel = new DefaultTableColumnModel();
    TableCellRenderer headerRenderer = tableHeader.getDefaultRenderer();
    columnModel.addColumn(Utilities.createTableColumn(0, "Level", headerRenderer, false));
    columnModel.addColumn(Utilities.createTableColumn(1, "HP", headerRenderer, false));
    columnModel.addColumn(Utilities.createTableColumn(2, "Class (All Levels In Class)", headerRenderer, true));
    classLevelTable.setColumnModel(columnModel);
    classLevelTable.setAutoCreateColumnsFromModel(false);
    classLevelTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    classLevelTable.setFocusable(false);
    classLevelTable.setCellSelectionEnabled(false);
    classLevelTable.setRowHeight(20);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel)

Example 52 with JTableHeader

use of javax.swing.table.JTableHeader in project pcgen by PCGen.

the class StatTableModel method initializeTable.

public static void initializeTable(JTable statsTable) {
    JTableHeader tableHeader = statsTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    statsTable.setAutoCreateColumnsFromModel(false);
    DefaultTableColumnModel columnModel = new DefaultTableColumnModel();
    {
        TableColumn column = Utilities.createTableColumn(ABILITY_NAME, "Ability", new AbilityHeaderCellRenderer(), true);
        column.setIdentifier(ABILITY_COLUMN_ID);
        columnModel.addColumn(column);
        String htmlText = "<html><div align=\"center\">Final<br>Score</div></html>";
        column = Utilities.createTableColumn(FINAL_ABILITY_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText), false);
        column.setCellRenderer(new ValueRenderer());
        columnModel.addColumn(column);
        TableCellRenderer renderer = new ModRenderer();
        htmlText = "<html><div align=\"center\">Ability<br>Mod</div></html>";
        column = Utilities.createTableColumn(ABILITY_MOD, htmlText, new FixedHeaderCellRenderer(htmlText), false);
        column.setCellRenderer(renderer);
        columnModel.addColumn(column);
        htmlText = "<html><div align=\"center\">Editable<br>Score</div></html>";
        column = Utilities.createTableColumn(EDITABLE_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText), false);
        column.setIdentifier(EDITABLE_COLUMN_ID);
        columnModel.addColumn(column);
        htmlText = "<html><div align=\"center\">Race<br>Adj</div></html>";
        column = Utilities.createTableColumn(RACE_ADJ, htmlText, new FixedHeaderCellRenderer(htmlText), false);
        column.setCellRenderer(renderer);
        columnModel.addColumn(column);
        htmlText = "<html><div align=\"center\">Misc<br>Adj</div></html>";
        column = Utilities.createTableColumn(MISC_ADJ, htmlText, new FixedHeaderCellRenderer(htmlText), false);
        column.setCellRenderer(renderer);
        columnModel.addColumn(column);
    }
    statsTable.setColumnModel(columnModel);
    statsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    statsTable.setShowVerticalLines(false);
    statsTable.setCellSelectionEnabled(false);
    statsTable.setFocusable(false);
    // XXX this should be calculated relative to font size and the size of a jspinner
    statsTable.setRowHeight(27);
    statsTable.setOpaque(false);
    tableHeader.setFont(FontManipulation.title(statsTable.getFont()));
    FontManipulation.large(statsTable);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) JTableHeader(javax.swing.table.JTableHeader) TableColumn(javax.swing.table.TableColumn)

Example 53 with JTableHeader

use of javax.swing.table.JTableHeader in project pcgen by PCGen.

the class SkillCostTableModel method initializeTable.

public static void initializeTable(JTable table) {
    table.setAutoCreateColumnsFromModel(false);
    JTableHeader header = table.getTableHeader();
    TableColumnModel columns = new DefaultTableColumnModel();
    TableCellRenderer headerRenderer = header.getDefaultRenderer();
    columns.addColumn(Utilities.createTableColumn(0, //$NON-NLS-1$
    LanguageBundle.getString("in_skillSkillCost"), headerRenderer, true));
    columns.addColumn(Utilities.createTableColumn(1, //$NON-NLS-1$
    LanguageBundle.getString("in_skillRankCost"), headerRenderer, false));
    columns.addColumn(Utilities.createTableColumn(2, //$NON-NLS-1$
    LanguageBundle.getString("in_skillMaxRanks"), headerRenderer, false));
    table.setColumnModel(columns);
    table.setFocusable(false);
    table.setCellSelectionEnabled(false);
    header.setReorderingAllowed(false);
    header.setResizingAllowed(false);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel)

Example 54 with JTableHeader

use of javax.swing.table.JTableHeader in project pcgen by PCGen.

the class SkillPointTableModel method initializeTable.

public static void initializeTable(JTable table) {
    table.setAutoCreateColumnsFromModel(false);
    JTableHeader header = table.getTableHeader();
    TableColumnModel columns = new DefaultTableColumnModel();
    TableCellRenderer headerRenderer = header.getDefaultRenderer();
    columns.addColumn(Utilities.createTableColumn(0, "in_level", headerRenderer, false));
    columns.addColumn(Utilities.createTableColumn(1, "in_class", headerRenderer, true));
    TableColumn remainCol = Utilities.createTableColumn(2, "in_iskRemain", headerRenderer, false);
    remainCol.setCellRenderer(new BoldNumberRenderer());
    columns.addColumn(remainCol);
    columns.addColumn(Utilities.createTableColumn(3, "in_gained", headerRenderer, false));
    table.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    table.setColumnModel(columns);
    table.setFocusable(false);
    header.setReorderingAllowed(false);
    header.setResizingAllowed(false);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) TableColumn(javax.swing.table.TableColumn) TableCellUtilities(pcgen.gui2.util.table.TableCellUtilities)

Example 55 with JTableHeader

use of javax.swing.table.JTableHeader in project beast-mcmc by beast-dev.

the class TaxonSetPanel method initTaxonSetsTable.

protected void initTaxonSetsTable(AbstractTableModel tableModel, final String[] columnToolTips) {
    taxonSetsTable = new JTable(tableModel) {

        //Implement table header tool tips.
        protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {

                public String getToolTipText(MouseEvent e) {
                    Point p = e.getPoint();
                    int index = columnModel.getColumnIndexAtX(p.x);
                    int realIndex = columnModel.getColumn(index).getModelIndex();
                    return columnToolTips[realIndex];
                }
            };
        }
    };
    taxonSetsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    taxonSetsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            taxonSetsTableSelectionChanged();
        }
    });
    taxonSetsTable.doLayout();
}
Also used : ListSelectionEvent(javax.swing.event.ListSelectionEvent) JTableHeader(javax.swing.table.JTableHeader) ListSelectionListener(javax.swing.event.ListSelectionListener)

Aggregations

JTableHeader (javax.swing.table.JTableHeader)61 TableCellRenderer (javax.swing.table.TableCellRenderer)18 JTable (javax.swing.JTable)15 Component (java.awt.Component)13 TableColumn (javax.swing.table.TableColumn)12 TableColumnModel (javax.swing.table.TableColumnModel)12 JLabel (javax.swing.JLabel)11 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)8 JComponent (javax.swing.JComponent)7 JScrollPane (javax.swing.JScrollPane)7 BorderLayout (java.awt.BorderLayout)6 MouseEvent (java.awt.event.MouseEvent)6 JPopupMenu (javax.swing.JPopupMenu)6 MouseAdapter (java.awt.event.MouseAdapter)5 JButton (javax.swing.JButton)5 JPanel (javax.swing.JPanel)5 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)4 DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)4 FormLayout (com.jgoodies.forms.layout.FormLayout)3 WindowAdapter (java.awt.event.WindowAdapter)3