Java Code Examples for java.awt.Component#isOpaque()

The following examples show how to use java.awt.Component#isOpaque() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LuckTableCellHeaderRenderer.java    From littleluck with Apache License 2.0 6 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque()
{
    Color back = getBackground();

    Component p = getParent();

    if (p != null)
    {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null)
            && back.equals(p.getBackground()) && p.isOpaque();

    return !colorMatch && super.isOpaque();
}
 
Example 2
Source File: DefaultListCellRenderer.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 *
 * @since 1.5
 * @return <code>true</code> if the background is completely opaque
 *         and differs from the JList's background;
 *         <code>false</code> otherwise
 */
@Override
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }
    // p should now be the JList.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 3
Source File: DefaultListCellRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 *
 * @since 1.5
 * @return <code>true</code> if the background is completely opaque
 *         and differs from the JList's background;
 *         <code>false</code> otherwise
 */
@Override
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }
    // p should now be the JList.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 4
Source File: DefaultListCellRenderer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 *
 * @since 1.5
 * @return <code>true</code> if the background is completely opaque
 *         and differs from the JList's background;
 *         <code>false</code> otherwise
 */
@Override
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }
    // p should now be the JList.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 5
Source File: CompanionInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean isOpaque()
{
	Color back = getBackground();
	Component p = getParent();
	if (p != null)
	{
		p = p.getParent();
	}

	// p should now be the JTable. 
	boolean colorMatch = (back != null) && (p != null) && back.equals(p.getBackground()) && p.isOpaque();
	return !colorMatch && super.isOpaque();
}
 
Example 6
Source File: DefaultTableCellRenderer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 7
Source File: ResourceRenderer.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 */
@Override
public boolean isOpaque() {
  Color back = getBackground();
  Component p = getParent();
  if(p != null) {
    p = p.getParent();
  }

  // p should now be the JTable.
  boolean colorMatch = (back != null) && (p != null)
          && back.equals(p.getBackground()) && p.isOpaque();
  return !colorMatch && super.isOpaque();
}
 
Example 8
Source File: DefaultListCellRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 *
 * @since 1.5
 * @return <code>true</code> if the background is completely opaque
 *         and differs from the JList's background;
 *         <code>false</code> otherwise
 */
@Override
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }
    // p should now be the JList.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 9
Source File: DefaultTableCellRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 10
Source File: DefaultTableCellRenderer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 11
Source File: DecoratedTreeUI.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * This is copied from BasicTreeUI.java. The only modifications are:
 * <ul>
 * <li>The background color is painted across the entire width of the tree.</li>
 * <li>Because of the above requirement: the expand control is redundantly
 * painted on top of that rectangle for visibility.</li>
 * <li>We never inform the CellRenderer whether focus is present. (That
 * argument is left false, because we don't have access to private fields
 * the original logic wanted.)</li>
 * </ul>
 */
@Override
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets,
		Rectangle bounds, TreePath path, int row, boolean isExpanded,
		boolean hasBeenExpanded, boolean isLeaf) {
	// Don't paint the renderer if editing this row.
	if (editingComponent != null && editingRow == row)
		return;

	// this is in BasicTreeUI, but getLeadSelectionRow() is private.
	/*
	 * int leadIndex;
	 * 
	 * if(tree.hasFocus()) { leadIndex = getLeadSelectionRow(); } else
	 * leadIndex = -1;
	 */

	Component component;

	component = currentCellRenderer.getTreeCellRendererComponent(tree,
			path.getLastPathComponent(), tree.isRowSelected(row),
			isExpanded, isLeaf, row, false);

	if (component.isOpaque()) {
		Color bkgnd = component.getBackground();
		g.setColor(bkgnd);
		g.fillRect(0, bounds.y, tree.getWidth(), bounds.height);

		if (shouldPaintExpandControl(path, row, isExpanded,
				hasBeenExpanded, isLeaf)) {
			paintExpandControl(g, bounds, insets, bounds, path, row,
					isExpanded, hasBeenExpanded, isLeaf);
		}
	}

	rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
			bounds.width, bounds.height, true);
}
 
Example 12
Source File: DefaultTableCellRenderer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 13
Source File: DefaultTableCellRenderer.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 14
Source File: DefaultListCellRenderer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 *
 * @since 1.5
 * @return <code>true</code> if the background is completely opaque
 *         and differs from the JList's background;
 *         <code>false</code> otherwise
 */
@Override
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }
    // p should now be the JList.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 15
Source File: DefaultTableCellRenderer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 16
Source File: DefaultListCellRenderer.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 *
 * @since 1.5
 * @return <code>true</code> if the background is completely opaque
 *         and differs from the JList's background;
 *         <code>false</code> otherwise
 */
@Override
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }
    // p should now be the JList.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 17
Source File: DefaultTableCellRenderer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 18
Source File: DefaultListCellRenderer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 *
 * @since 1.5
 * @return <code>true</code> if the background is completely opaque
 *         and differs from the JList's background;
 *         <code>false</code> otherwise
 */
@Override
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }
    // p should now be the JList.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 19
Source File: DefaultTableCellRenderer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}
 
Example 20
Source File: DefaultTableCellRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
public boolean isOpaque() {
    Color back = getBackground();
    Component p = getParent();
    if (p != null) {
        p = p.getParent();
    }

    // p should now be the JTable.
    boolean colorMatch = (back != null) && (p != null) &&
        back.equals(p.getBackground()) &&
                    p.isOpaque();
    return !colorMatch && super.isOpaque();
}