Package javax.swing.table

Examples of javax.swing.table.DefaultTableCellRenderer


        table.getColumnModel().getColumn(1).setPreferredWidth(30);
        table.getColumnModel().getColumn(2).setPreferredWidth(50);
        table.getColumnModel().getColumn(3).setPreferredWidth(50);
        table.getColumnModel().getColumn(4).setPreferredWidth(20);

        table.getColumn(model.getColumnName(0)).setCellRenderer(new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table,
                                                           final Object value,
                                                           final boolean isSelected,
                                                           final boolean hasFocus,
                                                           final int row,
                                                           final int column) {

                File renderingFile = (File)getModel().getElementAt(row);
                String displayValue = getFileChooser().getName(renderingFile);

                JLabel result = (JLabel)super.getTableCellRendererComponent(table, displayValue, isSelected, hasFocus, row, column);
                result.setIcon(getFileChooser().getIcon(renderingFile));

                return result;
            }
        });
        table.getColumn(model.getColumnName(1)).setCellRenderer(new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table,
                                                           final Object value,
                                                           final boolean isSelected,
                                                           final boolean hasFocus,
                                                           final int row,
                                                           final int column) {

                JLabel result = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                result.setHorizontalAlignment(SwingConstants.RIGHT);
                return result;
            }
        });
        table.getColumn(model.getColumnName(3)).setCellRenderer(new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table,
                                                           final Object value,
                                                           final boolean isSelected,
                                                           final boolean hasFocus,
                                                           final int row,
View Full Code Here


        table.getColumnModel().getColumn(1).setPreferredWidth(30);
        table.getColumnModel().getColumn(2).setPreferredWidth(50);
        table.getColumnModel().getColumn(3).setPreferredWidth(50);
        table.getColumnModel().getColumn(4).setPreferredWidth(20);

        table.getColumn(model.getColumnName(0)).setCellRenderer(new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table,
                                                           final Object value,
                                                           final boolean isSelected,
                                                           final boolean hasFocus,
                                                           final int row,
                                                           final int column) {

                File renderingFile = (File)getModel().getElementAt(row);
                String displayValue = getFileChooser().getName(renderingFile);

                JLabel result = (JLabel)super.getTableCellRendererComponent(table, displayValue, isSelected, hasFocus, row, column);
                result.setIcon(getFileChooser().getIcon(renderingFile));

                return result;
            }
        });
        table.getColumn(model.getColumnName(1)).setCellRenderer(new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table,
                                                           final Object value,
                                                           final boolean isSelected,
                                                           final boolean hasFocus,
                                                           final int row,
                                                           final int column) {

                JLabel result = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                result.setHorizontalAlignment(SwingConstants.RIGHT);
                return result;
            }
        });
        table.getColumn(model.getColumnName(3)).setCellRenderer(new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table,
                                                           final Object value,
                                                           final boolean isSelected,
                                                           final boolean hasFocus,
                                                           final int row,
View Full Code Here

    // This is weird - if I don't set this the column header doesn't line up
    // with the column contents.
    corner.getColumnModel().getColumn(0).setMinWidth(200);

    final DefaultTableCellRenderer tcrColumn = new DefaultTableCellRenderer();
    tcrColumn.setHorizontalAlignment(SwingConstants.CENTER);
    corner.getColumnModel().getColumn(0).setCellRenderer(tcrColumn);
    corner.getColumnModel().getColumn(1).setCellRenderer(tcrColumn);

    final JPanel cornerPanel = new JPanel();
    cornerPanel.setLayout(new BorderLayout());
View Full Code Here

          @Override
          public void run() {
            JTable table = new JTable(model);
            table.getTableHeader().setReorderingAllowed(false);
            table.getTableHeader().setResizingAllowed(false);
            table.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() {
              public Component getTableCellRendererComponent(JTable renderTable, Object value,
                  boolean isSelected, boolean hasFocus, int row, int column) {
                Component c = super.getTableCellRendererComponent(renderTable,value,isSelected,hasFocus,row,column);

                if(value instanceof DeviceIf) {
View Full Code Here

                    return false;
                }
            };
            tabvok.getColumn("Status").setCellRenderer(
                // Standard-Renderer erweitern
                new DefaultTableCellRenderer() {
                    @Override
                    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
                        // Label der Oberklasse erweitern
                        JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                       
                        // Lediglich Text und Grafik anpassen
                        if (value != null) {
                            label.setText("");
                            label.setIcon((ImageIcon) value);
                        }
                   
                        return label;
                    }
                }
            );
               
            tabelle = new JScrollPane(tabvok);
            tabvok.setSelectionMode( ListSelectionModel.SINGLE_INTERVAL_SELECTION );
            tabvok.setColumnSelectionAllowed( false );
            tabvok.setRowSelectionAllowed( true );
            tabvok.getTableHeader().setReorderingAllowed( false );
            tabvok.getTableHeader().setResizingAllowed( true );
        }else{
            tabvok.setModel(model);
      tabvok.getColumn("Status").setCellRenderer(
                // Standard-Renderer erweitern
                new DefaultTableCellRenderer() {
                    @Override
                    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
                        // Label der Oberklasse erweitern
                        JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                       
View Full Code Here

        // Dialog anzeigen:
        JLabel message = new JLabel(msgHead);
        JLabel messageFoot = new JLabel(msgFoot);
        DefaultTableModel dtm = new DefaultTableModel(allEnd, column){
            protected void createDefaultRenderers(){
                new DefaultTableCellRenderer(){
                    @Override
                    public void setValue(Object value){
                        if(value.toString().substring(0,5).equals("icons/")){
                            ImageIcon img = new ImageIcon(value.toString());
                            setIcon((Icon)img.getImage());
View Full Code Here

      runModeComboBox.addItem(runMode.getValue());
    }

    runModeColumn.setCellEditor(new DefaultCellEditor(runModeComboBox));

    DefaultTableCellRenderer renderer =
      new DefaultTableCellRenderer();
    renderer.setToolTipText("Choose when to run...");
    runModeColumn.setCellRenderer(renderer);
  }
View Full Code Here

        TableColumn column = paramTable.getColumnModel().getColumn(columnIndex);

        TableCellRenderer cellRenderer = column.getCellRenderer();

        if(cellRenderer == null) {
            cellRenderer = new DefaultTableCellRenderer();
        }

        for(int row = 0; row < paramTable.getModel().getRowCount(); row++) {
            Component rendererComponent = cellRenderer.getTableCellRendererComponent(paramTable,
                paramTable.getModel().getValueAt(row, columnIndex),
View Full Code Here

        this.name = name;
        setEditor(cellEditor);
        setRenderer(cellRenderer);

        if (cellRenderer instanceof DefaultTableCellRenderer){
            DefaultTableCellRenderer dtce = (DefaultTableCellRenderer)cellRenderer;
            this.setAlignment(UIutils.javaAlignementToForte(dtce.getHorizontalAlignment()));
        }
    }
View Full Code Here

    }

    public int getAlignment() {
        int result;
        if (this.renderer instanceof DefaultTableCellRenderer) {
            DefaultTableCellRenderer dtcr = (DefaultTableCellRenderer) this.renderer;
            result = dtcr.getHorizontalAlignment();
        } else {
            result = SwingConstants.LEFT;
        }
        return UIutils.javaAlignementToForte(result);
    }
View Full Code Here

TOP

Related Classes of javax.swing.table.DefaultTableCellRenderer

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.