Search in sources :

Example 96 with TableCellRenderer

use of javax.swing.table.TableCellRenderer 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 97 with TableCellRenderer

use of javax.swing.table.TableCellRenderer 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 98 with TableCellRenderer

use of javax.swing.table.TableCellRenderer 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 99 with TableCellRenderer

use of javax.swing.table.TableCellRenderer 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 100 with TableCellRenderer

use of javax.swing.table.TableCellRenderer in project drmips by brunonova.

the class SupportedInstructionsTable method packFirstColumn.

/**
	 * Resizes the first column to the minimum width.
	 */
public void packFirstColumn() {
    int width = 0, num = getRowCount();
    TableCellRenderer renderer;
    Component comp;
    for (int r = 0; r < num; r++) {
        renderer = getCellRenderer(r, 0);
        comp = prepareRenderer(renderer, r, 0);
        width = Math.max(comp.getPreferredSize().width + getIntercellSpacing().width, width);
    }
    TableColumn col = getColumnModel().getColumn(0);
    getTableHeader().setResizingColumn(col);
    col.setWidth(width + SPACING);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn)

Aggregations

TableCellRenderer (javax.swing.table.TableCellRenderer)122 TableColumn (javax.swing.table.TableColumn)50 Component (java.awt.Component)47 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)24 JComponent (javax.swing.JComponent)20 JTable (javax.swing.JTable)20 TableColumnModel (javax.swing.table.TableColumnModel)18 JLabel (javax.swing.JLabel)17 JTableHeader (javax.swing.table.JTableHeader)17 MouseEvent (java.awt.event.MouseEvent)11 ColumnInfo (com.intellij.util.ui.ColumnInfo)8 ActionEvent (java.awt.event.ActionEvent)8 JButton (javax.swing.JButton)8 DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)8 MouseAdapter (java.awt.event.MouseAdapter)7 TableCellEditor (javax.swing.table.TableCellEditor)7 TableModel (javax.swing.table.TableModel)7 ActionListener (java.awt.event.ActionListener)6 List (java.util.List)6 JPanel (javax.swing.JPanel)6