Package javax.swing.table

Examples of javax.swing.table.TableModel


    // Sets the preferred width of the visible column specified by vColIndex. The column
    // will be just wide enough to show the column head and the widest cell in the column.
    // margin pixels are added to the left and right
    // (resulting in an additional width of 2*margin pixels).
    public void packColumn(JTable table, int vColIndex, int margin) {
        TableModel model = table.getModel();
        DefaultTableColumnModel colModel = (DefaultTableColumnModel)table.getColumnModel();
        TableColumn col = colModel.getColumn(vColIndex);
        int width = 0;
   
        // Get width of column header
View Full Code Here


      }
   }

   DataScaleTableModel getDataScaleTableModel()
   {
      TableModel ret = ((SortableTableModel) getModel()).getActualModel();

      while(ret instanceof SortableTableModel)
      {
         ret = ((SortableTableModel)ret).getActualModel();
      }
View Full Code Here

         _pressed = false;
         if (!_dragged)
         {
            _currentSortedColumnIcon = null;
            int column = getTable().convertColumnIndexToModel(_pressedColumnIdx);
            TableModel tm = table.getModel();

            if (column > -1
               && column < tm.getColumnCount()
               && tm instanceof SortableTableModel)
            {
               ((SortableTableModel) tm).sortByColumn(column);
               if (((SortableTableModel)tm).isSortedAscending())
               {
View Full Code Here

   *
   */
  public NameFormatterTab(HelpDialog helpDialog) {
    setLayout(new BorderLayout());

    TableModel tm = new AbstractTableModel() {
      public int getRowCount() {
        return rowCount;
      }

      public int getColumnCount() {
View Full Code Here

    public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
        _prefs = prefs;
        this.frame = frame;
        setLayout(new BorderLayout());

        TableModel tm = new AbstractTableModel() {
                public int getRowCount() { return rowCount; }
                public int getColumnCount() { return 2; }
                public Object getValueAt(int row, int column) {
                  if (row == 0)
                    return (column==0 ? GUIGlobals.NUMBER_COL : ""+ncWidth);
View Full Code Here

   * Customization of external program paths.
   */
  public XmpPrefsTab() {
    setLayout(new BorderLayout());

    TableModel tm = new AbstractTableModel() {
      public int getRowCount() {
        return rowCount;
      }

      public int getColumnCount() {
View Full Code Here

          selectionByUser = true;
          int [] selectedRows = getSelectedRows();
          // Build the list of selected furniture
          List<HomePieceOfFurniture> selectedFurniture =
              new ArrayList<HomePieceOfFurniture>(selectedRows.length);
          TableModel tableModel = getModel();
          for (int index : selectedRows) {
            // Add to selectedFurniture table model value that stores piece
            selectedFurniture.add((HomePieceOfFurniture)tableModel.getValueAt(index, 0));
          }
          // Set the new selection in home with controller
          controller.setSelectedFurniture(selectedFurniture);
          selectionByUser = false;
        }
View Full Code Here

   * Updates table columns width from the content of its cells.
   */
  private void updateTableColumnsWidth() {
    int intercellWidth = getIntercellSpacing().width;
    TableColumnModel columnModel = getColumnModel();
    TableModel tableModel = getModel();
    for (int columnIndex = 0, n = columnModel.getColumnCount(); columnIndex < n; columnIndex++) {
      TableColumn column = columnModel.getColumn(columnIndex);
      int modelColumnIndex = convertColumnIndexToModel(columnIndex);
      int preferredWidth = column.getHeaderRenderer().getTableCellRendererComponent(
          this, column.getHeaderValue(), false, false, -1, columnIndex).getPreferredSize().width;
      int rowCount = tableModel.getRowCount();
      if (rowCount > 0) {
        for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
          preferredWidth = Math.max(preferredWidth,
              column.getCellRenderer().getTableCellRendererComponent(
                  this, tableModel.getValueAt(rowIndex, modelColumnIndex), false, false, -1, columnIndex).
                      getPreferredSize().width);
        }
      } else {
        preferredWidth = Math.max(preferredWidth, column.getPreferredWidth());
      }
View Full Code Here

    }
    csv.append(lineSeparator);
   
    // Selected values
    for (int rowIndex : getSelectedRows()) {
      TableModel model = getModel();
      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));
          }
        } 
      }
      csv.append(lineSeparator);
    }
View Full Code Here

    }


    try
    {
      final TableModel tableModel =
          sqlReportDataFactory.parametrizeAndQuery(computedParameterSet, sqlQuery, parameterNames);

      // now lets wrap up the model into a meta-data aware model ..
      final List<Selection> selections = queryObject.getSelections();
      if (selections.size() != tableModel.getColumnCount())
      {
        throw new ReportDataFactoryException("Whatever the query returned, it does not look familiar");
      }
      // cast is safe, as the SQL-Datasource is guaranteed to return a
      // MetaTableModel
View Full Code Here

TOP

Related Classes of javax.swing.table.TableModel

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.