Package javax.swing.table

Examples of javax.swing.table.TableColumn


      JScrollPane tableScrollPane;
      {
        table = new JTable(new DefaultTableModel(null, new String[]{"Attribute","Value"}));
        {
          table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
          TableColumn column0 = table.getColumnModel().getColumn(0);
          {
            column0.setCellRenderer(new CellRenderer());
            column0.setMinWidth(200);
            column0.setMaxWidth(200);
          }
          TableColumn column1 = table.getColumnModel().getColumn(1);
          {
            column1.setCellRenderer(new CellRenderer());
          }
          table.getColumnModel().addColumnModelListener(
            new TableColumnModelListener()
            {
              @Override
View Full Code Here


  };

  renderer.setHorizontalAlignment(JLabel.RIGHT);

  // Setup Track# column
  TableColumn col = getColumn("Track#");
  col.setCellRenderer(renderer);
  // In Swing 1.0.1 this will never work.
  // These is a swing bug.
  // col.sizeWidthToFit();
  col.setCellRenderer(renderer);
  col.setResizable(false);

  // Setup  Media file column
  col = getColumn("Media");
  TableCellEditor cellEditor = new DefaultCellEditor(new JTextField());
  MediaFileCellEditorListener mcl =
      new MediaFileCellEditorListener();
  cellEditor.addCellEditorListener(mcl);
        col.setCellEditor(cellEditor);
  MediaFileCellRenderer m_renderer = new MediaFileCellRenderer();
  col.setCellRenderer(m_renderer);

  // Setup StartTime column
  col = getColumn("Start Time");
  cellEditor = new DefaultCellEditor(new JTextField());
  StartCellEditorListener scl = new StartCellEditorListener(this);
  cellEditor.addCellEditorListener(scl);
        col.setCellEditor(cellEditor);
        col.setResizable(false);
  col.setCellRenderer(renderer);

  // Setup PlayingTime column
  col = getColumn("Play Time");
  cellEditor = new DefaultCellEditor(new JTextField());
  PlayingTimeCellEditorListener dcl = new PlayingTimeCellEditorListener();
  cellEditor.addCellEditorListener(dcl);
        col.setCellEditor(cellEditor);
  col.setResizable(false);
  col.setCellRenderer(renderer);
    }
View Full Code Here

    setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN);

    final TableColumnModel tcm = new DefaultTableColumnModel();
    for (int i = 0; i < s_columnWidths.length; ++i)
    {
      final TableColumn col = new TableColumn(i, s_columnWidths[i]);
      col.setHeaderValue(s_hdgs[i]);
      tcm.addColumn(col);
    }
    setColumnModel(tcm);
  }
View Full Code Here

      setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN);

      final TableColumnModel tcm = new DefaultTableColumnModel();
      JComboBox _actionComboBox = new JComboBox();
    for (int i = 0; i < model.getColumnCount(); ++i) {
         final TableColumn col = new TableColumn(i, model.getColumnWidth(i));
         col.setHeaderValue(model.getColumnName(i));
         if (i == 3) {
            col.setCellEditor(new DefaultCellEditor(initCbo(_actionComboBox)));
         }
         tcm.addColumn(col);
      }
      setColumnModel(tcm);
      initPopup();
View Full Code Here

        public ListViewModel() {
        }

        public void setWidths() {
            TableColumn column = null;

            for (int i = 0; i < getColumnCount(); i++) {
                column = table.getColumnModel().getColumn(i);
                if (i == 0) {
                    column.setPreferredWidth(300);
                } else if (i == 3)
                    column.setPreferredWidth(150);
                else
                    column.setPreferredWidth(100);
            }

            table.validate();
        }
View Full Code Here

      TableColumnModel tcm = new DefaultTableColumnModel();
      dataScaleTable.setColumnModel(tcm);

      for (int i = 0; i < DataScaleTableModel.getColumnNames().length; i++)
      {
         TableColumn col = new TableColumn(i);
         col.setHeaderValue(DataScaleTableModel.getColumnNames()[i]);
         if (DataScaleTableModel.COL_NAME_COLUMN.equals(DataScaleTableModel.getColumnNames()[i]))
         {
            col.setPreferredWidth(dataScaleTableModel.getColumnWidthForColName(DataScaleTableModel.COL_NAME_COLUMN));
         }
         else if (DataScaleTableModel.COL_NAME_DATA.equals(DataScaleTableModel.getColumnNames()[i]))
         {
            col.setPreferredWidth(dataScaleTableModel.getColumnWidthForColName(DataScaleTableModel.COL_NAME_DATA));
         }
         tcm.addColumn(col);
      }

      _overviewHolder.setOverview(dataScaleTable);
View Full Code Here

     *@param  table  the table that this model represents
     */
    public void setTable(JTable table) {
        this.table = table;

        TableColumn column = null;

        // set the default column widths
        for (int i = 0; i < getColumnCount(); i++) {
            column = table.getColumnModel().getColumn(i);
            if (i < 2) {
                column.setPreferredWidth(150);
            }
            // sport column is bigger
            else {
                column.setPreferredWidth(50);
            }
        }
    }
View Full Code Here

        if (colWidth > IDataSetViewer.MAX_COLUMN_WIDTH * _multiplier)
        {
          colWidth = IDataSetViewer.MAX_COLUMN_WIDTH * _multiplier;
        }

        TableColumn col = new TableColumn(i, colWidth,
          CellComponentFactory.getTableCellRenderer(colDefs[i]), null);
        col.setHeaderValue(colDef.getColumnName());
        cm.addColumn(col);
      }

      setColumnModel(cm);

View Full Code Here

      //int modelCol = getTable().convertColumnIndexToModel(col);
      String retStr = null;

      if (col >= 0)
      {
         TableColumn tcol = getColumnModel().getColumn(col);
         int colWidth = tcol.getWidth();
         TableCellRenderer h = tcol.getHeaderRenderer();

         if (h == null)
         {
            h = getDefaultRenderer();
         }

         Component c = h.getTableCellRendererComponent(table, tcol.getHeaderValue(), false, false, -1, col);

         int prefWidth = c.getPreferredSize().width;
         if (prefWidth > colWidth)
         {
            retStr = tcol.getHeaderValue().toString();
         }
      }
      return retStr;
   }
View Full Code Here

      int newWidth = 20;

      if(includeColHeaders)
      {
         TableColumn column = getTable().getColumnModel().getColumn(colIx);
         TableCellRenderer headerRenderer = column.getHeaderRenderer();
         if(null == headerRenderer)
         {
            headerRenderer = getTable().getTableHeader().getDefaultRenderer();
         }

         Component headerComp = headerRenderer.getTableCellRendererComponent(getTable(), null, false, false, 0, colIx);
         FontMetrics headerFontMetrics = headerComp.getFontMetrics(headerComp.getFont());

         Rectangle2D bounds = headerFontMetrics.getStringBounds("" + column.getHeaderValue(), headerComp.getGraphics());

         newWidth = Math.max(newWidth, bounds.getBounds().width);
      }

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.