當前位置: 首頁>>代碼示例>>Java>>正文


Java JTable.getDefaultRenderer方法代碼示例

本文整理匯總了Java中javax.swing.JTable.getDefaultRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Java JTable.getDefaultRenderer方法的具體用法?Java JTable.getDefaultRenderer怎麽用?Java JTable.getDefaultRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.getDefaultRenderer方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTableCellRendererComponent

import javax.swing.JTable; //導入方法依賴的package包/類
@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) {
        if (component instanceof JLabel)
            ((JLabel) component)
                    .setText(DateAttributePlugin.DATE_INSTANCE
                            .format(value));
        else {
            TableCellRenderer renderer = table
                    .getDefaultRenderer(Date.class);
            return renderer.getTableCellRendererComponent(table, value,
                    isSelected, hasFocus, row, column);
        }
    }
    return component;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:21,代碼來源:PriceEditComponent.java

示例2: getTableCellRendererComponent

import javax.swing.JTable; //導入方法依賴的package包/類
@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) {
        if (component instanceof JLabel)
            ((JLabel) component).setText(DATE_INSTANCE.format(value));
        else {
            TableCellRenderer renderer = table
                    .getDefaultRenderer(Date.class);
            return renderer.getTableCellRendererComponent(table, value,
                    isSelected, hasFocus, row, column);
        }
    }
    return component;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:19,代碼來源:DateAttributePlugin.java

示例3: apply

import javax.swing.JTable; //導入方法依賴的package包/類
/**
 * Applies DisablingCellRenderer to all cell renderers in the table.
 * @param t the table
 * @param disabled if the table content should be disabled
 */
public static void apply(JTable t, Color background) {
    int nc = t.getColumnModel().getColumnCount();
    for (int i = 0; i < nc; i++) {
        TableCellRenderer columnRenderer = t.getColumnModel().getColumn(i).getCellRenderer();
        if (columnRenderer == null) columnRenderer = t.getDefaultRenderer(t.getColumnClass(i));
        t.getColumnModel().getColumn(i).setCellRenderer(
            new DisablingCellRenderer(columnRenderer, t, background));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:DisablingCellRenderer.java

示例4: getTableCellRendererComponent

import javax.swing.JTable; //導入方法依賴的package包/類
public Component getTableCellRendererComponent(JTable table, Object value,
                                               boolean isSelected, boolean hasFocus,
                                               int row, int column) {

    if (impl == null) impl = table.getDefaultRenderer(table.getColumnClass(column));
    
    value = formatValue(table, value, isSelected, hasFocus, row, column);
    Component c = impl.getTableCellRendererComponent(table, value, isSelected,
                                                     hasFocus, row, column);
    updateRenderer(c, table, value, isSelected, hasFocus, row, column);

    return c;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:DetailsTableCellRenderer.java

示例5: getTableCellRendererComponent

import javax.swing.JTable; //導入方法依賴的package包/類
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    TableCellRenderer def = table.getDefaultRenderer(table.getColumnClass(column));
    if (!table.isEnabled()) {
        isSelected = hasFocus = false;
    }
    JComponent c = (JComponent)def.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    c.setEnabled(table.isEnabled());
    
    return c;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:ClassNameList.java

示例6: AttrTable

import javax.swing.JTable; //導入方法依賴的package包/類
public AttrTable(Window parent) {
	super(new BorderLayout());
	this.parent = parent;

	titleEnabled = true;
	title = new TitleLabel();
	title.setHorizontalAlignment(SwingConstants.CENTER);
	title.setVerticalAlignment(SwingConstants.CENTER);
	tableModel = new TableModelAdapter(parent, NULL_ATTR_MODEL);
	table = new JTable(tableModel);
	table.setDefaultEditor(Object.class, editor);
	table.setTableHeader(null);
	table.setRowHeight(20);

	Font baseFont = title.getFont();
	int titleSize = Math.round(baseFont.getSize() * 1.2f);
	Font titleFont = baseFont.deriveFont((float) titleSize).deriveFont(Font.BOLD);
	title.setFont(titleFont);
	Color bgColor = new Color(240, 240, 240);
	setBackground(bgColor);
	table.setBackground(bgColor);
	Object renderer = table.getDefaultRenderer(String.class);
	if (renderer instanceof JComponent) {
		((JComponent) renderer).setBackground(Color.WHITE);
	}

	JScrollPane tableScroll = new JScrollPane(table);

	this.add(title, BorderLayout.PAGE_START);
	this.add(tableScroll, BorderLayout.CENTER);
	LocaleManager.addLocaleListener(this);
	localeChanged();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:34,代碼來源:AttrTable.java


注:本文中的javax.swing.JTable.getDefaultRenderer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。