Example usage for javax.swing JTable isOpaque

List of usage examples for javax.swing JTable isOpaque

Introduction

In this page you can find the example usage for javax.swing JTable isOpaque.

Prototype

public boolean isOpaque() 

Source Link

Document

Returns true if this component is completely opaque.

Usage

From source file:ExtendedTableCellRenderer.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 {/*from w  ww  . ja v  a2 s . com*/
        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(NO_FOCUS_BORDER);
    }

    setValue(value);

    Color background = getBackground();
    boolean colorMatch = (background != null) && (background.equals(table.getBackground())) && table.isOpaque();
    setOpaque(!colorMatch);

    return this;
}