Package javax.swing.table

Examples of javax.swing.table.TableCellRenderer


    int occurenceCounter = 0;
    for (int rowIndex = 0; rowIndex < pTable.getModel().getRowCount(); ++rowIndex )
    {
      //format model value
      Object cellValue = pTable.getModel().getValueAt(rowIndex, pColumnIndex);
      TableCellRenderer renderer = pTable.getCellRenderer(rowIndex, pColumnIndex);
      Component c = renderer.getTableCellRendererComponent(pTable, cellValue, false, false, rowIndex, pColumnIndex);
      String valueRepresentation;
      if ( c instanceof Label )
      {
        LOGGER.debug("cell is represented by a Label");
        valueRepresentation = ((Label)c).getText();
View Full Code Here


    int counter = 0;
    for (int rowIndex = 0; rowIndex < pTable.getModel().getRowCount(); ++rowIndex )
    {
      //format model value
      Object cellValue = pTable.getModel().getValueAt(rowIndex, pColumnIndex);
      TableCellRenderer renderer = pTable.getCellRenderer(rowIndex, pColumnIndex);
      Component c = renderer.getTableCellRendererComponent(pTable, cellValue, false, false, rowIndex, pColumnIndex);
      String valueRepresentation;
      if ( c instanceof Label )
      {
        LOGGER.debug("cell is represented by a Label");
        valueRepresentation = ((Label)c).getText();
View Full Code Here

    }

    // table.setFillsViewportHeight(true);
    table.setSelectionBackground(Color.cyan);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    TableCellRenderer cellRenderer = new TableCellRenderer() {

      public Component getTableCellRendererComponent(JTable table,
          Object value, boolean isSelected, boolean hasFocus, int row,
          int column) {
        JLabel field = new JLabel((String) value);
View Full Code Here

     * Gets the special renderer for single- and multi-valued association.
     * Otherwise uses the super classes' renderer defined by the field type.   
     */
    public TableCellRenderer getCellRenderer(int row, int column) {
        Attribute<?,?> attr = ((EntityDataModel)getModel()).getAttribute(column);
        TableCellRenderer renderer = null;
        if (attr == null) {
            renderer = super.getCellRenderer(row, column);
        } else if (attr.isAssociation()) {
            renderer = instanceCellRenderer;
        } else if (attr.isCollection()) {
View Full Code Here

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

        for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++) {
            int cellWidth = 0;
            column = getColumnModel().getColumn(columnIndex);

            comp = headerRenderer.getTableCellRendererComponent(
                                 null, column.getHeaderValue(),
                                 false, false, 0, 0);
            headerWidth = comp.getPreferredSize().width;
            TableCellRenderer renderer = getCellRenderer(0, columnIndex);
            int rowCount = Math.min(model.getRowCount(), 10);
            for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
                Object value = model.getValueAt(rowIndex, columnIndex);
                comp = renderer.getTableCellRendererComponent(
                                 this, value,
                                 false, false, rowIndex, columnIndex);
                cellWidth = Math.max(comp.getPreferredSize().width, cellWidth);
            }
            column.setPreferredWidth(Math.max(headerWidth, cellWidth));
View Full Code Here

        updateStyle(table);
    }

    private TableCellRenderer installRendererIfPossible(Class objectClass,
                                     TableCellRenderer renderer) {
        TableCellRenderer currentRenderer = table.getDefaultRenderer(
                                 objectClass);
        if (currentRenderer instanceof UIResource) {
            table.setDefaultRenderer(objectClass, renderer);
        }
        return currentRenderer;
View Full Code Here

            Component component = table.getEditorComponent();
            component.setBounds(cellRect);
            component.validate();
        }
        else {
            TableCellRenderer renderer = table.getCellRenderer(row, column);
            Component component = table.prepareRenderer(renderer, row, column);
            Color b = component.getBackground();
            if ((b == null || b instanceof UIResource
                    || component instanceof SynthBooleanTableCellRenderer)
                    && !table.isCellSelected(row, column)) {
View Full Code Here

        updateStyle(table);
    }

    private TableCellRenderer installRendererIfPossible(Class objectClass,
                                     TableCellRenderer renderer) {
        TableCellRenderer currentRenderer = table.getDefaultRenderer(
                                 objectClass);
        if (currentRenderer instanceof UIResource) {
            table.setDefaultRenderer(objectClass, renderer);
        }
        return currentRenderer;
View Full Code Here

    TableModel tm = getModel();
    TableColumnModel colModel = getColumnModel();

    for (int col = tm.getColumnCount()-1; col >=0; col--) {
      TableColumn column = colModel.getColumn(col);
      TableCellRenderer renderer = column.getHeaderRenderer();
      if (renderer == null) {
        renderer = getTableHeader().getDefaultRenderer();
      }
      //Set the cell Width to the width of the header
      int cellWidth = renderer.getTableCellRendererComponent(this,
          column.getHeaderValue(), false, false, -1, col).getPreferredSize().
          width;

      renderer = getDefaultRenderer(tm.getColumnClass(col));

      for (int row = tm.getRowCount()-1; row>=0; row--) {
        int tmpWidth = renderer.getTableCellRendererComponent(this,
            tm.getValueAt(row, col), false, false, row, col).getPreferredSize().
            width;
        if (tmpWidth > cellWidth)
          cellWidth = tmpWidth;
      }
View Full Code Here

    chkShowInStandard.setHorizontalAlignment(SwingConstants.CENTER);

    final Color unselectedBg = (new JTextField()).getBackground();
    final Color selectedBg = (new JTextField()).getSelectionColor();

    TableCellRenderer chkRenderer =
      new TableCellRenderer()
      {
        public Component getTableCellRendererComponent(JTable table, Object value,
                                        boolean isSelected, boolean hasFocus,
                                        int row, int column)
        {
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.