当前位置: 首页>>代码示例>>Java>>正文


Java DefaultTableCellRenderer类代码示例

本文整理汇总了Java中javax.swing.table.DefaultTableCellRenderer的典型用法代码示例。如果您正苦于以下问题:Java DefaultTableCellRenderer类的具体用法?Java DefaultTableCellRenderer怎么用?Java DefaultTableCellRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultTableCellRenderer类属于javax.swing.table包,在下文中一共展示了DefaultTableCellRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueAddedTaxPercentageRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
/**
 * Returns a renderer that displays the value added tax percentage property of a piece of furniture. 
 */
private TableCellRenderer getValueAddedTaxPercentageRenderer()
{
	return new DefaultTableCellRenderer()
	{
		@Override
		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
				boolean hasFocus, int row, int column)
		{
			BigDecimal valueAddedTaxPercentage = value != null
					? ((HomePieceOfFurniture) value).getValueAddedTaxPercentage() : null;
			if (valueAddedTaxPercentage != null)
			{
				NumberFormat percentInstance = DecimalFormat.getPercentInstance();
				percentInstance.setMinimumFractionDigits(valueAddedTaxPercentage.scale() - 2);
				value = percentInstance.format(valueAddedTaxPercentage);
			}
			else
			{
				value = null;
			}
			setHorizontalAlignment(JLabel.RIGHT);
			return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		}
	};
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:29,代码来源:FurnitureTable.java

示例2: TelaBuscarVeiculo

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
public TelaBuscarVeiculo() {
    initComponents();
    
    jtb_Veiculos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    
    ButtonGroup group = new ButtonGroup();
    group.add(jrb_Marca);
    group.add(jrb_Modelo);
    group.add(jrb_Ano);
    group.add(jrb_MenorPreco);
    group.add(jrb_MaiorPreco);
    
    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment( JLabel.CENTER );
    jtb_Veiculos.setDefaultRenderer(Object.class, centerRenderer);
    
}
 
开发者ID:Mentz,项目名称:PPRCarTrade,代码行数:18,代码来源:TelaBuscarVeiculo.java

示例3: atualizaTela

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
public void atualizaTela(){
    meusVeiculos = new ArrayList<>();
    
    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment( JLabel.CENTER );
    jtb_Veiculos.setDefaultRenderer(Object.class, centerRenderer);        
    
    jtb_Veiculos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    DefaultTableModel model = (DefaultTableModel)jtb_Veiculos.getModel();
    model.setRowCount(0);
    ArrayList<VendaVeiculo> aux = NegocioFacade.listaVeiculos();
    Usuario logado = NegocioFacade.getUsuarioLogado();
    for(VendaVeiculo a : aux){
        if(a.getProprietario().getCpf().equals(logado.getCpf())){
            model.addRow(new Object[]{ a.getVeiculo().getMarca(), a.getVeiculo().getModelo(), 
                                       a.getVeiculo().getCor(), a.getVeiculo().getAno(), a.getPreco()});
            meusVeiculos.add(a);
        }
    }
    jtb_Veiculos.setModel(model);
}
 
开发者ID:Mentz,项目名称:PPRCarTrade,代码行数:22,代码来源:TelaUsuarioVendas.java

示例4: getTableCellRendererComponent

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
    if (value == null) {
        return new DefaultTableCellRenderer().getTableCellRendererComponent(table, value,
                isSelected, hasFocus, row, column);
    }

    // This doesn't work in the presence of table row sorting:
    //boolean isTotalRow = row == table.getModel().getRowCount()-1;
    FileCoverageSummary summary = (FileCoverageSummary) table.getValueAt(row, -1);
    boolean isTotalRow = summary == ((CoverageTableModel)table.getModel()).total;
    setEmphasize(isTotalRow);
    setSelected(isSelected);

    float coverage = (Float) value;
    setCoveragePercentage(coverage);

    //setStats(summary.getLineCount(), summary.getExecutedLineCount(),
    //        summary.getInferredCount(), summary.getPartialCount());

    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CoverageReportTopComponent.java

示例5: getTableCellRendererComponent

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if(value instanceof String[]) {
        this.box.setModel(new DefaultComboBoxModel((String[])(value)));
        this.box.setSelectedItem(((DatabaseAdvancedConnectionDialog.DriverPropertyInfoTableModel)table.getModel()).getComboValue(table.convertRowIndexToModel(row)));
        return this.box;
    } else {
        Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        if(component instanceof DefaultTableCellRenderer && table.convertColumnIndexToModel(column) == 0) {
            String tooltip = ((DatabaseAdvancedConnectionDialog.DriverPropertyInfoTableModel)table.getModel()).getTooltip(table.convertRowIndexToModel(row));
            tooltip = "<html><div width = 300px>" + tooltip + "</div></html>";
            ((DefaultTableCellRenderer)component).setToolTipText(tooltip);
        }

        return component;
    }
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:DatabaseAdvancedConnectionDialog.java

示例6: getCellRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
/**Returns combobox-styled cellrenderer if a multiple choice cell is to be rendered.
 * @return cell renderer*/
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
	//if this is type column, I must render it as a combo box instead of a jtextfield
	if (column == 1) {
		if (isLdEnabled()) {
			return LD_enabled_StationTypeCell;
		} else {
			return LD_disabled_StationTypeCell;
		}
	} else if (column == getColumnCount() - 1) {
		return deleteButtonCellRenderer;
	} else {
		return new DefaultTableCellRenderer();
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:18,代码来源:StationsPanel.java

示例7: getCellRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
/**Returns combobox-styled cellrenderer if a multiple choice cell is to be rendered.
 * @return cell renderer*/
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
	//if this is type column, I must render it as a combo box instead of a jtextfield
	if (column == 1) {
		if (LD_enabled_system) {
			return LD_enabled_StationTypeCell;
		} else {
			return LD_disabled_StationTypeCell;
		}
	} else if (column == getColumnCount() - 1) {
		return deleteButtonCellRenderer;
	} else {
		return new DefaultTableCellRenderer();
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:18,代码来源:StationsPanel.java

示例8: getCellRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
/**
 * The original getCellRenderer method is overwritten, since the table
 * displays in red the values that could not be calculated with the requested
 * precision
 * @param row the row of the cell
 * @param column the column of the cell
 * @return a the TableCellRenderer for the requested cell (row,column)
 */
public TableCellRenderer getCellRenderer(int row, int column) {
	dtcr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
	//Component c = null;
	Component c;
	if (column < values.size()) {
		c = dtcr.getTableCellRendererComponent(this, values.get(column), false, false, row, column);
		if (!((PAResultsModel.MeasureValueImpl) values.get(column)).isValid()) {
			c.setForeground(Color.RED);
		} else {
			c.setForeground(Color.BLACK);
		}

	} else {
		c = dtcr.getTableCellRendererComponent(this, "-", false, false, row, column);
		c.setForeground(Color.BLACK);
	}

	return dtcr;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:28,代码来源:PAResultsWindow.java

示例9: setUpSportColumn

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
public void setUpSportColumn(JTable table, TableColumn sportColumn) {
    // Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Snowboarding");
    comboBox.addItem("Rowing");
    comboBox.addItem("Knitting");
    comboBox.addItem("Speed reading");
    comboBox.addItem("Pool");
    comboBox.addItem("None of the above");
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));

    // Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    sportColumn.setCellRenderer(renderer);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:17,代码来源:TableRenderDemo.java

示例10: getCellRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
/**
 * The original getCellRenderer method is overwritten, since the table
 * displays in red the values that could not be calculated with the requested
 * precision
 * @param row the row of the cell
 * @param column the column of the cell
 * @return a the TableCellRenderer for the requested cell (row,column)
 */
public TableCellRenderer getCellRenderer(int row, int column) {
	dtcr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
	//Component c = null;
	Component c;
	if (column < values.size()) {
		c = dtcr.getTableCellRendererComponent(this, values.get(column), false, false, row, column);
		//if (!((Boolean)(validities.get(column))).booleanValue()) {
		if (!((PAResultsModel.MeasureValueImpl) values.get(column)).isValid()) {
			c.setForeground(Color.RED);
		} else {
			c.setForeground(Color.BLACK);
		}

	} else {
		c = dtcr.getTableCellRendererComponent(this, "-", false, false, row, column);
		c.setForeground(Color.BLACK);
	}

	return dtcr;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:29,代码来源:PAResultsWindow.java

示例11: getTableCellRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
@Override
public TableCellRenderer getTableCellRenderer(Engine engine,
                                              AccessRules rules, Attribute attribute) {
    return new DefaultTableCellRenderer() {
        /**
         *
         */
        private static final long serialVersionUID = -7922052040779840252L;

        {
            setHorizontalAlignment(SwingConstants.RIGHT);
        }

        @Override
        public Component getTableCellRendererComponent(JTable table,
                                                       Object value, boolean isSelected, boolean hasFocus,
                                                       int row, int column) {
            Component component = super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
            if (value != null)
                ((JLabel) component).setText(format(value));
            return component;
        }
    };
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:26,代码来源:PriceAttributePlugin.java

示例12: getTableCellRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
@Override
public TableCellRenderer getTableCellRenderer(Engine engine,
                                              AccessRules rules, Attribute attribute) {
    return new DefaultTableCellRenderer() {
        /**
         *
         */
        private static final long serialVersionUID = 6973511367750673696L;

        @Override
        public Component getTableCellRendererComponent(JTable table,
                                                       Object value, boolean isSelected, boolean hasFocus,
                                                       int row, int column) {
            return super.getTableCellRendererComponent(table,
                    MessageFormat
                            .format(GlobalResourcesManager
                                    .getString("EmptyPlugin.Name"), type
                                    .toString()), isSelected, hasFocus,
                    row, column);
        }
    };
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:23,代码来源:EmptyPlugin.java

示例13: PwnBackTable

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
PwnBackTable(PwnBackMediator mediator) {
    this.mediator = mediator;
    logTable.getModel().addTableModelListener(e -> {
        if (TableUtilities.isInsert(e)) {
            int viewRow = logTable.convertRowIndexToView(e.getFirstRow());
            logTable.scrollRectToVisible(logTable.getCellRect(viewRow, 0, true));
        }
    });
    logTable.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            final Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            c.setForeground(mediator.getLog().get(row).getRowColor());
            return c;
        }
    });


}
 
开发者ID:k4ch0w,项目名称:PwnBack,代码行数:20,代码来源:PwnBackTable.java

示例14: runTest

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
private static void runTest() {
    JDialog dialog = Util
                .createModalDialogWithPassFailButtons("Empty header showing \"...\"");
    String[] columnNames = {"", "", "", "", "Testing"};
    String[][] data = {{"1", "2", "3", "4", "5"}};
    JTable table = new JTable(data, columnNames);
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    int tableCellWidth = renderer.getFontMetrics(renderer.getFont())
            .stringWidth("test");
    table.setPreferredScrollableViewportSize(new Dimension(
            5 * tableCellWidth, 50));
    JPanel p = new JPanel();
    p.add(new JScrollPane(table));
    dialog.add(p, BorderLayout.NORTH);
    JTextArea area = new JTextArea();
    String txt  = "\nInstructions:\n\n";
           txt += "Only the last column header should show \"...\".";
    area.setText(txt);
    dialog.add(new JScrollPane(area), BorderLayout.CENTER);
    dialog.pack();
    dialog.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:bug6442918a.java

示例15: createTableCellRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入依赖的package包/类
private TableCellRenderer createTableCellRenderer() {
	return new DefaultTableCellRenderer() {
		private static final long serialVersionUID = 0L;
		
		@Override
		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
			Match match = (Match) value;
			
			String text = "";
			if(column == 0) {
				text = Integer.toString(match.getMatchNumber());
			} else if(column == 1) {
				text = match.getGameType();
			} else if(column == 2) {
				text = match.getPlayerOne().getPlayerName();
			} else if(column == 3) {
				text = match.getPlayerTwo().getPlayerName();
			}
			
			return super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
		}
	};
}
 
开发者ID:IcyPalm,项目名称:Hanze-TwoPlayerGameServer,代码行数:24,代码来源:MatchTable.java


注:本文中的javax.swing.table.DefaultTableCellRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。