javax.swing.JTable#getSelectionForeground ( )源码实例Demo

下面列出了javax.swing.JTable#getSelectionForeground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ramus   文件: SectorRowsEditor.java
public Component getTableCellRendererComponent(final JTable table,
                                               final Object value, final boolean isSelected,
                                               final boolean hasFocus, final int row, final int column) {
    if (isSelected) {
        super.setForeground(table.getSelectionForeground());
        super.setBackground(table.getSelectionBackground());
    } else {
        super.setForeground(table.getForeground());
        super.setBackground(table.getBackground());
    }

    setFont(table.getFont());

    if (hasFocus) {
        Border border = null;
        if (isSelected) {
            border = UIManager
                    .getBorder("Table.focusSelectedCellHighlightBorder");
        }
        if (border == null) {
            border = UIManager
                    .getBorder("Table.focusCellHighlightBorder");
        }
        setBorder(border);
    } else {
        setBorder(noFocusBorder);
    }
    return this;
}
 
源代码2 项目: javamelody   文件: MBooleanTableCellRenderer.java
/** {@inheritDoc} */
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value,
		final boolean isSelected, final boolean hasFocus, final int row, final int column) {

	if (isSelected) {
		super.setForeground(table.getSelectionForeground());
		super.setBackground(table.getSelectionBackground());
	} else {
		super.setForeground(table.getForeground());
		if (MTable.BICOLOR_LINE != null && row % 2 == 0) {
			super.setBackground(MTable.BICOLOR_LINE);
		} else {
			super.setBackground(table.getBackground());
		}
	}

	if (hasFocus) {
		setBorder(BORDER);
	} else {
		setBorder(null);
	}

	setEnabled(table.isCellEditable(row, column));

	if (value instanceof Boolean) {
		final boolean selected = ((Boolean) value).booleanValue();
		this.setSelected(selected);
		// this.setToolTipText(selected ? "vrai" : "false");
		return this;
	}
	final JLabel label = (JLabel) table.getDefaultRenderer(String.class)
			.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);
	if (value == null) {
		label.setText(null);
	} else {
		label.setText("??");
	}
	return label;
}
 
源代码3 项目: RipplePower   文件: YesNoRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {
	if (isSelected) {
		super.setForeground(table.getSelectionForeground());
		super.setBackground(table.getSelectionBackground());
	} else {
		super.setForeground((unselectedForeground != null) ? unselectedForeground : table.getForeground());
		super.setBackground((unselectedBackground != null) ? unselectedBackground : table.getBackground());
	}

	setFont(table.getFont());

	if (hasFocus) {
		setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));

		if (table.isCellEditable(row, column)) {
			super.setForeground(UIManager.getColor("Table.focusCellForeground"));
			super.setBackground(UIManager.getColor("Table.focusCellBackground"));
		}
	} else {
		setBorder(noFocusBorder);
	}
	setValue(value);
	Color back = getBackground();
	boolean colorMatch = (back != null) && (back.equals(table.getBackground())) && table.isOpaque();
	setOpaque(!colorMatch);
	return this;
}
 
源代码4 项目: RipplePower   文件: OddEvenRowColorModel.java
public Color getForeground(int row, boolean selected, JTable table) {
	if (selected) {
		return table.getSelectionForeground();
	} else {
		return fore;
	}
}
 
源代码5 项目: snap-desktop   文件: MosaicExpressionsPanel.java
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
                                               int row, int column) {
    final boolean enabled = table.isEnabled();
    setText((String) value);

    if (isSelected) {
        super.setForeground(table.getSelectionForeground());
        super.setBackground(table.getSelectionBackground());
    } else if (!enabled) {
        super.setForeground(UIManager.getColor("TextField.inactiveForeground"));
        super.setBackground(table.getBackground());
    } else {
        super.setForeground(table.getForeground());
        super.setBackground(table.getBackground());
    }

    setFont(table.getFont());

    if (hasFocus) {
        setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
        if (table.isCellEditable(row, column)) {
            super.setForeground(UIManager.getColor("Table.focusCellForeground"));
            super.setBackground(UIManager.getColor("Table.focusCellBackground"));
        }
    } else {
        setBorder(noFocusBorder);
    }

    setValue(value);

    return this;
}
 
源代码6 项目: netbeans   文件: TabDataRenderer.java
@Override
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column ) {
    renderer.clear();
    Rectangle rect = table.getCellRect( row, column, true );
    renderer.setSize( rect.width, rect.height );
    if( value instanceof TabData ) {
        TabData tab = ( TabData ) value;
        String text = tab.getText();
        Icon icon = tab.getIcon();
        Color colBackground = isSelected ? table.getSelectionBackground() : table.getBackground();
        Color colForeground = isSelected ? table.getSelectionForeground() : table.getForeground();

        boolean isActive = (activeBackground != null || underlineColor != null)
            ? TabbedImpl.isActive(table) : false;
        if (!isSelected && isActive && activeBackground != null) {
            colBackground = activeBackground;
        }

        for( TabDecorator td : decorators ) {
            Color c = td.getBackground( tab, isSelected );
            if( null != c )
                colBackground = c;
            c = td.getForeground( tab, isSelected );
            if( null != c )
                colForeground = c;

            String s = td.getText( tab );
            if( null != s )
                text = s;

            Icon i = td.getIcon( tab );
            if( null != i ) {
                icon = i;
            }
        }
        boolean isHover = (hoverBackground != null && TabTableUI.isHover(table, row, column));
        if (isHover) {
            colBackground = hoverBackground;
        }
        renderer.label.setText( text );
        renderer.label.setIcon( icon );
        renderer.label.setFont( table.getFont() );
        renderer.setBackground( colBackground );
        renderer.label.setForeground( colForeground );
        renderer.tabData = tab;
        renderer.isSelected = isSelected;
        renderer.isActive = isActive;
        renderer.tabsLocation = (table instanceof TabTable) ? ((TabTable)table).getTabsLocation() : JTabbedPane.TOP;

        if( table instanceof TabTable ) {
            TabTable tabTable = ( TabTable ) table;
            if( isClosable(tab) ) {
                boolean inCloseButton = tabTable.isCloseButtonHighlighted( row, column );
                renderer.closeButton.setVisible( true );
                renderer.closeButton.getModel().setRollover( inCloseButton );
                renderer.closeButton.getModel().setArmed( inCloseButton );
            } else {
                renderer.closeButton.setVisible( false );
            }
        }
    }
    return renderer;
}
 
源代码7 项目: netbeans   文件: CoverageReportTopComponent.java
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);
    }

    if (isSelected) {
        super.setForeground(table.getSelectionForeground());
        super.setBackground(table.getSelectionBackground());
    } else {
        super.setForeground(table.getForeground());
        super.setBackground(table.getBackground());
    }

    setFont(table.getFont());

    if (hasFocus) {
        Border border = null;
        if (isSelected) {
            border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder"); // NOI18N
        }
        if (border == null) {
            border = UIManager.getBorder("Table.focusCellHighlightBorder"); // NOI18N
        }
        setBorder(border);
    } else {
        setBorder(new EmptyBorder(1, 1, 1, 1));
    }


    FileCoverageSummary summary = (FileCoverageSummary) table.getValueAt(row, -1);
    FileObject file = summary.getFile();

    setText(summary.getDisplayName());
    if (file != null && file.isValid()) {
        try {
            DataObject dobj = DataObject.find(file);
            Node node = dobj.getNodeDelegate();
            Image icon = node.getIcon(BeanInfo.ICON_COLOR_32x32);
            setIcon(new ImageIcon(icon));
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        }
    } else {
        setIcon(null);
    }


    return this;
}
 
源代码8 项目: pgptool   文件: EncryptBackActionCellRenderer.java
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {

	if (table == null) {
		return this;
	}

	lbl.setFont(table.getFont().deriveFont(Font.BOLD));

	Color fg = null;
	Color bg = null;

	JTable.DropLocation dropLocation = table.getDropLocation();
	if (dropLocation != null && !dropLocation.isInsertRow() && !dropLocation.isInsertColumn()
			&& dropLocation.getRow() == row && dropLocation.getColumn() == column) {
		fg = UIManager.getColor("Table.dropCellForeground");
		bg = UIManager.getColor("Table.dropCellBackground");
		isSelected = true;
	}

	if (isSelected) {
		super.setForeground(fg == null ? table.getSelectionForeground() : fg);
		super.setBackground(bg == null ? table.getSelectionBackground() : bg);
	} else {
		Color background = unselectedBackground != null ? unselectedBackground : table.getBackground();
		if (background == null || background instanceof javax.swing.plaf.UIResource) {
			Color alternateColor = UIManager.getColor("Table.alternateRowColor");
			if (alternateColor != null && row % 2 != 0) {
				background = alternateColor;
			}
		}
		super.setForeground(unselectedForeground != null ? unselectedForeground : table.getForeground());
		super.setBackground(background);
	}

	setFont(table.getFont());

	if (hasFocus) {
		Border border = null;
		if (isSelected) {
			border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
		}
		if (border == null) {
			border = UIManager.getBorder("Table.focusCellHighlightBorder");
		}
		setBorder(border);

		if (!isSelected && table.isCellEditable(row, column)) {
			Color col;
			col = UIManager.getColor("Table.focusCellForeground");
			if (col != null) {
				super.setForeground(col);
			}
			col = UIManager.getColor("Table.focusCellBackground");
			if (col != null) {
				super.setBackground(col);
			}
		}
	} else {
		setBorder(getNoFocusBorder());
	}

	return this;
}
 
 方法所在类
 同类方法