Package javax.swing.table

Examples of javax.swing.table.TableCellRenderer


     */
    private void createColumns(FurnitureLibrary furnitureLibrary,
                               FurnitureLibraryUserPreferences preferences,
                               FurnitureLanguageController controller) {
        // Create the list of custom columns
      TableCellRenderer headerRenderer = getHeaderRenderer();
      for (String columnProperty : preferences.getEditedProperties()) {
        if (columnProperty != "MODEL_ROTATION"
            && columnProperty != "MODEL") {
          TableColumn tableColumn = new TableColumn();
          tableColumn.setIdentifier(columnProperty);
View Full Code Here


     */
    private TableCellRenderer getButtonRenderer(String propertyKey,
                                                final UserPreferences preferences) {
      if (FurnitureLibrary.FURNITURE_MODEL_PROPERTY.equals(propertyKey)
          || FurnitureLibrary.FURNITURE_MODEL_ROTATION_PROPERTY.equals(propertyKey)) {
        return new TableCellRenderer() {
          private JButton component = new JButton();
          public Component getTableCellRendererComponent(JTable table, Object value,
              boolean isSelected, boolean hasFocus, int row, int column) {
            component.setText(preferences.getLocalizedString(FurnitureLibraryTable.class, "modifyButton"));
            return component;
View Full Code Here

     * Returns column header renderer that displays an ascending or a descending icon
     * when column is sorted, beside column name.
     */
    private TableCellRenderer getHeaderRenderer() {
      // Return a table renderer that displays the icon matching current sort
      return new TableCellRenderer() {
          private TableCellRenderer headerRenderer;       
          private ImageIcon ascendingSortIcon = new ImageIcon(getClass().getResource("resources/ascending.png"));
          private ImageIcon descendingSortIcon = new ImageIcon(getClass().getResource("resources/descending.png"));
         
          public Component getTableCellRendererComponent(JTable table,
View Full Code Here

  }

  public void setTableHeader(JTableHeader tableHeader) {
    if (this.tableHeader != null) {
      this.tableHeader.removeMouseListener(mouseListener);
      TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
      if (defaultRenderer instanceof SortableHeaderRenderer) {
        this.tableHeader
            .setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
      }
    }
View Full Code Here

                /* (non-Javadoc)
                 * @see javax.swing.JTable#getCellRenderer(int, int)
                 */
                public TableCellRenderer getCellRenderer(int row, int column) {
                    //The result
                    TableCellRenderer result = null;
                    if (column == TableModelObjectInfo.NAME_COLUMN) {
                        result = super.getCellRenderer(row, column);
                    } else {
                        result = new TableCellRendererObjectInfo();
                    }
View Full Code Here

        DefaultTableColumnModel colModel = (DefaultTableColumnModel)table.getColumnModel();
        TableColumn col = colModel.getColumn(vColIndex);
        int width = 0;
   
        // Get width of column header
        TableCellRenderer renderer = col.getHeaderRenderer();
        if (renderer == null) {
            renderer = table.getTableHeader().getDefaultRenderer();
        }
        Component comp = renderer.getTableCellRendererComponent(
            table, col.getHeaderValue(), false, false, 0, 0);
        width = comp.getPreferredSize().width;
   
        // Get maximum width of column data
        for (int r=0; r<table.getRowCount(); r++) {
            renderer = table.getCellRenderer(r, vColIndex);
            comp = renderer.getTableCellRendererComponent(
                table, table.getValueAt(r, vColIndex), false, false, r, vColIndex);
            width = Math.max(width, comp.getPreferredSize().width);
        }
   
        // Add margin
View Full Code Here

      }
     
      private void init() {
          this.getColumnModel().
              getColumn(DownloadTableModel.PROGRESS_BAR).
              setCellRenderer( new TableCellRenderer() {
                public Component getTableCellRendererComponent(JTable table,
                                                           Object stringValue,
                                                           boolean isSelected,
                                                           boolean hasFocus,
                                                           int row,
View Full Code Here

      }
     
      private void init() {
        this.getColumnModel().
               getColumn(TableColumnChooserModel.COLUMN_NAME).
                 setCellRenderer(new TableCellRenderer() {
                  public Component getTableCellRendererComponent(JTable table,
                                                             Object stringValue,
                                                             boolean isSelected,
                                                             boolean hasFocus,
                                                             int row,
View Full Code Here

   }


   private TableCellRenderer createScaleDataCellRenderer(final DataScaleTableModel dataScaleTableModel)
   {
      return new TableCellRenderer()
      {
         @Override
         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
         {
            SortableTableModel sortableTableModel = (SortableTableModel) getModel();
View Full Code Here

      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();
View Full Code Here

TOP

Related Classes of javax.swing.table.TableCellRenderer

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.