當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。