Package javax.swing.table

Examples of javax.swing.table.TableColumn


    }

    private void hideColumn(String name) {
        Iterator it = mapTableColumnColumnKeeper.keySet().iterator();
        while (it.hasNext()) {
            TableColumn c = (TableColumn) it.next();
            String n = (String) c.getHeaderValue();
            if (n.equals(name)) {
                ColumnKeeper ck = (ColumnKeeper) mapTableColumnColumnKeeper
                        .get(c);
                if (ck.isShown)
                    ck.hide();
View Full Code Here


        ttModel.deleteCustomColumn(name);

        // newBB
        Iterator it2 = mapTableColumnColumnKeeper.keySet().iterator();
        while (it2.hasNext()) {
            TableColumn c = (TableColumn) it2.next();
            String n = (String) c.getHeaderValue();
            if (n.equals(name)) {
                mapTableColumnColumnKeeper.remove(c);
                break;
            }
        }
View Full Code Here

        ttModel.renameCustomColumn(name, newName);

        // newBB
        Iterator it = mapTableColumnColumnKeeper.keySet().iterator();
        while (it.hasNext()) {
            TableColumn c = (TableColumn) it.next();
            String n = (String) c.getHeaderValue();
            if (n.equals(name)) {
                ColumnKeeper ck = (ColumnKeeper) mapTableColumnColumnKeeper
                        .get(c);
                ((TableColumnExt) c).setTitle(newName);
                break;
View Full Code Here

                setFont(origFont);
            }
            setBorder(border);

            // get the original model column index (maybe columns were reordered by user)
            final TableColumn tableColumn = table.getColumnModel().getColumn(column);
            final int modelColumn = tableColumn.getModelIndex();

            if( modelColumn == 0 ) {
                setIcon(tblrow.getBoard().getStateIcon());
            } else {
                setIcon(null);
View Full Code Here

     * one put by the skin) for it to finish the job.
     */
    protected void initSortHeader() {
        Enumeration<TableColumn> enumeration = getColumnModel().getColumns();
        while (enumeration.hasMoreElements()) {
            TableColumn column = (TableColumn) enumeration.nextElement();
            column.setHeaderRenderer(columnHeadersRenderer);
        }
        getTableHeader().addMouseListener(new HeaderMouseListener());
    }
View Full Code Here

        final JComboBox comboBox = new JComboBox();
        for (int i = 0; i < roles.length; i++)
            comboBox.addItem(roles[i]);

        try {
            TableColumn roleColumn = this
                    .getColumn(ResourceTreeTableModel.strResourceRole);
            comboBox.setEditable(false);
            roleColumn.setCellEditor(new DefaultCellEditor(comboBox));
        } catch (IllegalArgumentException ex) {

        }
    }
View Full Code Here

        // comboBox.addItem(roles[i]);
        final JComboBox comboBox = new JComboBox(getRoleManager()
                .getEnabledRoles());

        try {
            TableColumn roleColumn = this
                    .getColumn(ResourceTreeTableModel.strResourceRoleForTask);
            comboBox.setEditable(false);
            roleColumn.setCellEditor(new DefaultCellEditor(comboBox));
        } catch (IllegalArgumentException ex) {

        }
    }
View Full Code Here

    add(new JLabel("Registration History"), BorderLayout.NORTH);
    JTable table = new JTable(new RegTableModel());
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      // Set the third visible column to 100 pixels wide
      int vColIndex = 2;
      TableColumn col = table.getColumnModel().getColumn(vColIndex);
      FontMetrics fontMetrics = getFontMetrics(getFont());
    int length = fontMetrics.stringWidth(reg.getCurrentEntry().getSummary());
      col.setPreferredWidth(length);
   
    add(new JScrollPane(table), BorderLayout.CENTER);
    add(new JLabel("Would you like to submit a registration?"),
        BorderLayout.SOUTH);
 
View Full Code Here

    return homeFurniture;
  }
 
  private String getRenderedDepth(JTable table, int row) {
    // Get index of detph column in model
    TableColumn depthColumn = table.getColumn(HomePieceOfFurniture.SortableProperty.DEPTH);

    // Get depth value at row
    TableModel model = table.getModel();
    Object cellValue = model.getValueAt(row, depthColumn.getModelIndex());
   
    // Get component used to render the depth cell at row
    int tableColumnIndex = table.getColumnModel().getColumnIndex(HomePieceOfFurniture.SortableProperty.DEPTH);
    TableCellRenderer renderer = table.getCellRenderer(row, tableColumnIndex);
    Component cellLabel = renderer.getTableCellRendererComponent(
View Full Code Here

    }

    public static void autoSizeTableColumns(JTable table) {

        TableModel  model        = table.getModel();
        TableColumn column       = null;
        Component   comp         = null;
        int         headerWidth  = 0;
        int         maxCellWidth = Integer.MIN_VALUE;
        int         cellWidth    = 0;
        TableCellRenderer headerRenderer =
            table.getTableHeader().getDefaultRenderer();

        for (int i = 0; i < table.getColumnCount(); i++) {
            column = table.getColumnModel().getColumn(i);
            comp = headerRenderer.getTableCellRendererComponent(table,
                    column.getHeaderValue(), false, false, 0, 0);
            headerWidth  = comp.getPreferredSize().width + 10;
            maxCellWidth = Integer.MIN_VALUE;

            for (int j = 0; j < Math.min(model.getRowCount(), 30); j++) {
                TableCellRenderer r = table.getCellRenderer(j, i);

                comp = r.getTableCellRendererComponent(table,
                                                       model.getValueAt(j, i),
                                                       false, false, j, i);
                cellWidth = comp.getPreferredSize().width;

                if (cellWidth >= maxCellWidth) {
                    maxCellWidth = cellWidth;
                }
            }

            column.setPreferredWidth(Math.max(headerWidth, maxCellWidth)
                                     + 10);
        }
    }
View Full Code Here

TOP

Related Classes of javax.swing.table.TableColumn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.