Search in sources :

Example 11 with TableColumn

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

the class JTreeViewTable method createTableColumnModel.

private DynamicTableColumnModel createTableColumnModel(TreeView<?> startingView, DataView<?> dataView) {
    @SuppressWarnings("unchecked") ListMap<Visibility, TableColumn, List<TableColumn>> listMap = CollectionMaps.createListMap(HashMap.class, ArrayList.class);
    int index = 1;
    for (DataViewColumn column : dataView.getDataColumns()) {
        TableColumn tableColumn = new TableColumn(index++);
        tableColumn.setHeaderValue(column.getName());
        Visibility vis = column.getVisibility();
        listMap.add(vis, tableColumn);
    }
    List<TableColumn> columns = listMap.get(Visibility.ALWAYS_VISIBLE);
    if (columns == null) {
        columns = Collections.emptyList();
    }
    PrefTableColumnModel model = new PrefTableColumnModel(this.viewModel.getDataView().getPrefsKey(), columns.size() + 1);
    TableColumn viewColumn = new TableColumn();
    viewColumn.setHeaderValue(startingView.getViewName());
    viewColumn.setIdentifier(TREE_VIEW_COL_PREFS_KEY);
    model.addColumn(viewColumn, true, 150);
    for (TableColumn column : columns) {
        model.addColumn(column, true, 75);
    }
    columns = listMap.get(Visibility.INITIALLY_VISIBLE);
    if (columns != null) {
        for (TableColumn column : columns) {
            model.addColumn(column, true, 75);
        }
    }
    columns = listMap.get(Visibility.INITIALLY_INVISIBLE);
    if (columns != null) {
        for (TableColumn column : columns) {
            model.addColumn(column, false, 75);
        }
    }
    return model;
}
Also used : PrefTableColumnModel(pcgen.gui2.tools.PrefTableColumnModel) DataViewColumn(pcgen.gui2.util.treeview.DataViewColumn) Visibility(pcgen.gui2.util.treeview.DataViewColumn.Visibility) ArrayList(java.util.ArrayList) List(java.util.List) TableColumn(javax.swing.table.TableColumn)

Example 12 with TableColumn

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

the class Utilities method createTableColumn.

public static TableColumn createTableColumn(int index, String headerValue, TableCellRenderer headerRenderer, boolean resizable) {
    TableColumn column = new TableColumn(index);
    if (headerValue.startsWith("in_")) {
        column.setHeaderValue(LanguageBundle.getString(headerValue));
    } else {
        column.setHeaderValue(headerValue);
    }
    column.setHeaderRenderer(headerRenderer);
    if (!resizable) {
        column.sizeWidthToFit();
        column.setMaxWidth(column.getMaxWidth() + 10);
        column.setPreferredWidth(column.getPreferredWidth() + 10);
    }
    column.setResizable(resizable);
    return column;
}
Also used : TableColumn(javax.swing.table.TableColumn)

Example 13 with TableColumn

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

the class DomainInfoTab method createDomainColumnModel.

public DynamicTableColumnModel createDomainColumnModel() {
    PrefTableColumnModel model = new PrefTableColumnModel("DomainList", 1);
    TableColumn column = new TableColumn(0);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_domains"));
    model.addColumn(column, true, 150);
    column = new TableColumn(1);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_descrip"));
    model.addColumn(column, false, 150);
    column = new TableColumn(2);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_source"));
    model.addColumn(column, true, 150);
    return model;
}
Also used : PrefTableColumnModel(pcgen.gui2.tools.PrefTableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 14 with TableColumn

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

the class EquipmentModel method initializeTreeTable.

public static void initializeTreeTable(JTreeTable treeTable) {
    treeTable.getTree().setRowHeight(0);
    treeTable.setFocusable(false);
    treeTable.getTree().putClientProperty("JTree.lineStyle", "Horizontal");
    normFont = treeTable.getFont();
    headerFont = FontManipulation.title(normFont);
    biggerFont = FontManipulation.title(FontManipulation.xxlarge(normFont));
    lessFont = FontManipulation.less(normFont);
    treeTable.setAutoCreateColumnsFromModel(false);
    {
        DefaultTableColumnModel model = new DefaultTableColumnModel();
        CellRenderer renderer = new CellRenderer();
        TableColumn column = new TableColumn(0);
        column.setResizable(true);
        model.addColumn(column);
        model.addColumn(createFixedColumn(1, 75, renderer));
        model.addColumn(createFixedColumn(2, 75, renderer));
        model.addColumn(createFixedColumn(3, 50, renderer));
        model.addColumn(createFixedColumn(4, 50, renderer));
        treeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        treeTable.setColumnModel(model);
        treeTable.getTableHeader().setResizingAllowed(false);
    }
    treeTable.setTreeCellRenderer(new TreeRenderer());
}
Also used : DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) CharacterTreeCellRenderer(pcgen.gui2.tabs.models.CharacterTreeCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumn(javax.swing.table.TableColumn)

Example 15 with TableColumn

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

the class CompanionInfoTab method initComponents.

private void initComponents() {
    {
        DefaultTableColumnModel model = new DefaultTableColumnModel();
        TableColumn column = new TableColumn(0);
        column.setResizable(true);
        model.addColumn(column);
        column = new TableColumn(1, 120, new ButtonCellRenderer(), null);
        column.setMaxWidth(120);
        column.setResizable(false);
        model.addColumn(column);
        companionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        companionsTable.getTableHeader().setResizingAllowed(false);
        companionsTable.setAutoCreateColumnsFromModel(false);
        companionsTable.setColumnModel(model);
    }
    companionsTable.setIntercellSpacing(new Dimension(0, 0));
    companionsTable.setFocusable(false);
    companionsTable.setRowHeight(23);
    companionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setLeftComponent(new JScrollPane(companionsTable));
    JPanel rightPane = new JPanel(new BorderLayout());
    infoPane.setOpaque(false);
    infoPane.setEditable(false);
    infoPane.setFocusable(true);
    //$NON-NLS-1$
    infoPane.setContentType("text/html");
    rightPane.add(new JScrollPane(infoPane), BorderLayout.CENTER);
    JPanel buttonPane = new JPanel(new FlowLayout());
    buttonPane.add(loadButton);
    rightPane.add(buttonPane, BorderLayout.SOUTH);
    setRightComponent(rightPane);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) BorderLayout(java.awt.BorderLayout) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn)

Aggregations

TableColumn (javax.swing.table.TableColumn)215 TableColumnModel (javax.swing.table.TableColumnModel)66 JTable (javax.swing.JTable)44 JScrollPane (javax.swing.JScrollPane)37 JPanel (javax.swing.JPanel)31 TableCellRenderer (javax.swing.table.TableCellRenderer)30 BoxLayout (javax.swing.BoxLayout)25 JLabel (javax.swing.JLabel)24 Component (java.awt.Component)21 ActionEvent (java.awt.event.ActionEvent)20 FlowLayout (java.awt.FlowLayout)16 ActionListener (java.awt.event.ActionListener)16 DefaultCellEditor (javax.swing.DefaultCellEditor)16 JButton (javax.swing.JButton)16 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)15 JComboBox (javax.swing.JComboBox)14 Dimension (java.awt.Dimension)13 DefaultTableModel (javax.swing.table.DefaultTableModel)12 JTableHeader (javax.swing.table.JTableHeader)12 XTableColumnModel (jmri.util.swing.XTableColumnModel)12