Package javax.swing.table

Examples of javax.swing.table.TableColumn


      HomePieceOfFurniture copiedPiece = (HomePieceOfFurniture)model.getValueAt(rowIndex, 0);
      for (int columnIndex = 0, n = this.columnModel.getColumnCount(); columnIndex < n; columnIndex++) {
        if (columnIndex > 0) {
          csv.append("\t");
        }
        TableColumn column = this.columnModel.getColumn(columnIndex);
        Object columnIdentifier = column.getIdentifier();
        if (columnIdentifier instanceof HomePieceOfFurniture.SortableProperty) {
          switch ((HomePieceOfFurniture.SortableProperty)columnIdentifier) {
            case CATALOG_ID :
              // Copy piece catalog id
              String catalogId = copiedPiece.getCatalogId();
              csv.append(catalogId != null ? catalogId : "");
              break;
            case NAME :
              // Copy piece name
              csv.append(copiedPiece.getName());
              break;
            case COLOR :
              if (copiedPiece.getColor() != null) {
                // Copy piece color at #xxxxxx format             
                csv.append("#" + Integer.toHexString(copiedPiece.getColor()).substring(2));
              }
              break;
            case TEXTURE :
              if (copiedPiece.getTexture() != null) {
                csv.append(copiedPiece.getTexture().getName());
              }
            case WIDTH :
            case DEPTH :
            case HEIGHT :
            case X :
            case Y :
            case ELEVATION :
            case ANGLE :
            case PRICE :
            case VALUE_ADDED_TAX_PERCENTAGE :
            case VALUE_ADDED_TAX :
            case PRICE_VALUE_ADDED_TAX_INCLUDED :
              // Copy numbers as they are displayed by their renderer
              csv.append(((JLabel)column.getCellRenderer().getTableCellRendererComponent(
                  this, copiedPiece, false, false, rowIndex, columnIndex)).getText());
              break;
            case MOVABLE :
              // Copy boolean as true or false
              csv.append(copiedPiece.isMovable());
              break;
            case DOOR_OR_WINDOW :
              csv.append(copiedPiece.isDoorOrWindow());
              break;
            case VISIBLE :
              csv.append(copiedPiece.isVisible());
              break;
          }
        } else {
          Component rendererComponent = column.getCellRenderer().getTableCellRendererComponent(
              this, copiedPiece, false, false, rowIndex, columnIndex);
          if (rendererComponent instanceof JLabel) {
            csv.append(((JLabel)rendererComponent).getText());             
          } else {
            csv.append(model.getValueAt(rowIndex, columnIndex));
View Full Code Here


            result.add(myEnum.nextElement());

        // Sort the columns based on the model index
        Collections.sort(result, new Comparator() {
            public int compare(Object a, Object b) {
                TableColumn c1 = (TableColumn) a;
                TableColumn c2 = (TableColumn) b;
                if (c1.getModelIndex() < c2.getModelIndex())
                    return -1;
                else if (c1.getModelIndex() == c2.getModelIndex())
                    return 0;
                else
                    return 1;
            }
        });
View Full Code Here

            setAlignmentY(CENTER_ALIGNMENT);

            final InnerTableMember tableMember = (InnerTableMember) tableModel.getRow(row);

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

            // defaults
            setFont(normalFont);
            if (!isSelected) {
                setForeground(Color.BLACK);
View Full Code Here

    public ResourcesTableModel getTableModel() {
        return myResourcesTableModel;
    }

    private void setUpCoordinatorBooleanColumn(final JTable resourceTable) {
        TableColumn resourcesColumn = resourceTable.getColumnModel().getColumn(
                3);
        resourcesColumn.setCellRenderer(new BooleanRenderer());
    }
View Full Code Here

        final JComboBox comboBox = new JComboBox();
        for (int i = 0; i < resources.size(); i++) {
            comboBox.addItem(resources.get(i));
        }

        TableColumn resourcesColumn = resourceTable.getColumnModel().getColumn(
                1);
        comboBox.setEditable(false);
        resourcesColumn.setCellEditor(new DefaultCellEditor(comboBox));
    }
View Full Code Here

        for (int i = 0; i < roles.length; i++) {
            Role role = (Role) roles[i];
            comboBox.addItem(role);
        }

        TableColumn rolesColumn = resourceTable.getColumnModel().getColumn(4);
        comboBox.setEditable(false);
        rolesColumn.setCellEditor(new DefaultCellEditor(comboBox));
        rolesColumn.setCellRenderer(new DefaultTableCellRenderer());
    }
View Full Code Here

    public void saveTableLayout() {
        final TableColumnModel tcm = modelTable.getTable().getColumnModel();
       
        for(int columnIndexInTable=0; columnIndexInTable < tcm.getColumnCount(); columnIndexInTable++) {
            final TableColumn tc = tcm.getColumn(columnIndexInTable);
            final int columnIndexInModel = tc.getModelIndex();
            final int columnIndexAll = mapCurrentColumntToPossibleColumn.get(columnIndexInModel);
           
            // save the current index in table for column with the fix index in model
            Core.frostSettings.setValue(CFGKEY_COLUMN_TABLEINDEX + columnIndexAll, columnIndexInTable);

            // save the current width of the column
            final int columnWidth = tc.getWidth();
            Core.frostSettings.setValue(CFGKEY_COLUMN_WIDTH + columnIndexAll, columnWidth);
        }

        if( Core.frostSettings.getBoolValue(SettingsClass.SAVE_SORT_STATES) && modelTable.getSortedColumn() > -1 ) {
            final int sortedColumn = modelTable.getSortedColumn();
View Full Code Here

                        }

                        public void columnMoved(TableColumnModelEvent e) {
                            DefaultTableColumnModel o = (DefaultTableColumnModel) e
                                    .getSource();
                            TableColumn tc = o.getColumn(e.getFromIndex());
                            ColumnKeeper ck = ((ColumnKeeper) mapTableColumnColumnKeeper
                                    .get(tc));
                            if (ck != null)
                                ck.setInitIndex(e.getToIndex());
                            if (Mediator.getGanttProjectSingleton() != null)
View Full Code Here

        //int nbCol = mapTableColumnColumnKeeper.keySet().size();
        for (Iterator entries = mapTableColumnColumnKeeper.entrySet().iterator(); entries.hasNext();) {
            // TableColumn column = tcModel.getColumn(i);
            Map.Entry nextEntry = (Entry) entries.next();
            TableColumn column = (TableColumn) nextEntry.getKey();
            JCheckBoxMenuItem jcbmi = new JCheckBoxMenuItem(column
                    .getHeaderValue().toString());

            ColumnKeeper ck = (ColumnKeeper)nextEntry.getValue();
            assert ck!=null;
            jcbmi.setSelected(ck.isShown);
View Full Code Here

            }
        }

        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 (indexView != -1)
                    ck.index = indexView;
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.