Java Code Examples for javax.swing.JComponent.setOpaque()

The following are Jave code examples for showing how to use setOpaque() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: StartPageContent.java   View Source Code Vote up 6 votes
public StartPageContent() {
    super( new GridBagLayout() );

    JComponent tabs = new TabbedPane( new LearnAndDiscoverTab(),
            new MyNetBeansTab(),
            new WhatsNewTab());
    tabs.setBorder(BorderFactory.createEmptyBorder(10,15,15,15));
    tabs.setOpaque(false);

    add( tabs, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(27,0,0,0), 0, 0) );

    add( new JLabel(), new GridBagConstraints(0, 2, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0) );
}
 
Example 2
Project: Cognizant-Intelligent-Test-Scripter   File: TreeSelectionRenderer.java   View Source Code Vote up 5 votes
@Override
public Component getTreeCellRendererComponent(JTree jtree, Object o, boolean bln, boolean bln1, boolean bln2, int i, boolean bln3) {
    JComponent comp = (JComponent) super.getTreeCellRendererComponent(jtree, o, bln, bln1, bln2, i, bln3);
    comp.setOpaque(true);
    if (selected) {
        if (cellFocused) {
            comp.setBackground(DEF_SELECTION_COLOR);
        } else {
            comp.setBackground(NOFOCUS_SELECTION_COLOR);
        }
    } else {
        comp.setBackground(jtree.getBackground());
    }
    return comp;
}
 
Example 3
Project: incubator-netbeans   File: DnDSupport.java   View Source Code Vote up 5 votes
private BufferedImage createContentImage( JComponent c, Dimension contentSize ) {
    GraphicsConfiguration cfg = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration();

    boolean opaque = c.isOpaque();
    c.setOpaque(true);
    BufferedImage res = cfg.createCompatibleImage(contentSize.width, contentSize.height);
    Graphics2D g = res.createGraphics();
    g.setColor( c.getBackground() );
    g.fillRect(0, 0, contentSize.width, contentSize.height);
    g.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f ));
    c.paint(g);
    c.setOpaque(opaque);
    return res;
}
 
Example 4
Project: FreeCol   File: OptionUI.java   View Source Code Vote up 5 votes
/**
 * Set up component.
 */
protected void initialize() {
    JComponent component = getComponent();
    component.setToolTipText(label.getToolTipText());
    component.setEnabled(editable);
    component.setOpaque(false);
}
 
Example 5
Project: FreeCol   File: FreeColDialog.java   View Source Code Vote up 5 votes
private static void setOpaqueLayerRecursive(Component opaqueComponent) {
    if (opaqueComponent instanceof JTextArea ||
        opaqueComponent instanceof JLabel) {
        if (opaqueComponent.isOpaque()) {
            ((JComponent) opaqueComponent).setOpaque(false);
        }
    } else if (opaqueComponent instanceof JPanel) {
        JComponent panel = (JComponent)opaqueComponent;
        if (panel.isOpaque()) {
            panel.setOpaque(false);
        }
        iterateOverOpaqueLayersComponents(panel);
    }
}
 
Example 6
Project: incubator-netbeans   File: IssuePanel.java   View Source Code Vote up 5 votes
private void updateFieldStatus(JComponent label, IssueField... fields) {
    label.setOpaque(false);
    for (IssueField field : fields) {
        boolean highlight = !issue.isNew() && (issue.getFieldStatus(field) & BugzillaIssue.FIELD_STATUS_MODIFIED) != 0;
        if (highlight) {
            label.setOpaque(true);
            label.setBackground(incomingChangesColor);
            break;
        }
    }
}
 
Example 7
Project: freecol   File: OptionUI.java   View Source Code Vote up 5 votes
/**
 * Set up component.
 */
protected void initialize() {
    JComponent component = getComponent();
    component.setToolTipText(label.getToolTipText());
    component.setEnabled(editable);
    component.setOpaque(false);
}
 
Example 8
Project: freecol   File: FreeColLabelUI.java   View Source Code Vote up 4 votes
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}
 
Example 9
Project: FreeCol   File: FreeColLabelUI.java   View Source Code Vote up 4 votes
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}
 
Example 10
Project: incubator-netbeans   File: IssuePanel.java   View Source Code Vote up 4 votes
private void cancelHighlight(JComponent label) {
    if (!reloading) {
        label.setOpaque(false);
        label.getParent().repaint();
    }
}
 
Example 11
Project: AgentWorkbench   File: GraphGlobals.java   View Source Code Vote up 4 votes
/**
 * Sets the color for a component that is located in a cell of a JTable.
 *
 * @param comp the JComponent
 * @param row the row
 * @param isSelected the is selected
 */
public static void setTableCellRendererColors(JComponent comp, int row, boolean isSelected) {

	// --- do the settings --------------
	comp.setOpaque(true);
	if (isSelected == true) {
		comp.setForeground(GraphGlobals.Colors.TB_TEXTFOREGROUND_SELECTED);
		comp.setBackground(GraphGlobals.Colors.TB_HIGHLIGHT);

	} else {
		comp.setForeground(GraphGlobals.Colors.TB_TEXTFOREGROUND);
		if (row%2==0) {
			comp.setBackground(GraphGlobals.Colors.TB_BACKGROUND);
		} else {
			comp.setBackground(GraphGlobals.Colors.TB_ALTERNATEROWCOLOR);			
		}
	}

	// --- In case of debugging ---------
	if (debug==false) {
		return;

	}
	if (colorPropertiesAlreadyPrinted==false) {
		List<String> colors = new ArrayList<String>();
		for (Map.Entry<Object, Object> entry : UIManager.getDefaults().entrySet()) {
			if (entry.getValue() instanceof Color) {
				colors.add((String) entry.getKey()); // all the keys are strings
			}
		}
		Collections.sort(colors);
		for (String name : colors) {
			System.out.println(name);
		}
		
		// --- Print the current color setting ----
		printColorSetting();

		colorPropertiesAlreadyPrinted = true;
	}

}
 
Example 12
Project: AgentWorkbench   File: OntologyVisualisationConfiguration.java   View Source Code Vote up 4 votes
/**
 * Sets the color for a component that is located in a cell of a JTable.
 *
 * @param comp the JComponent
 * @param row the row
 * @param isSelected the is selected
 */
public static void setTableCellRendererColors(JComponent comp, int row, boolean isSelected) {

	// --- do the settings --------------
	comp.setOpaque(true);
	if (isSelected == true) {
		comp.setForeground(Colors.TB_TEXTFOREGROUND_SELECTED);
		comp.setBackground(Colors.TB_HIGHLIGHT);

	} else {
		comp.setForeground(Colors.TB_TEXTFOREGROUND);
		if (row%2==0) {
			comp.setBackground(Colors.TB_BACKGROUND);
		} else {
			comp.setBackground(Colors.TB_ALTERNATEROWCOLOR);			
		}
	}

	// --- In case of debugging ---------
	if (debug==false) {
		return;

	}
	if (colorPropertiesAlreadyPrinted==false) {
		List<String> colors = new ArrayList<String>();
		for (Map.Entry<Object, Object> entry : UIManager.getDefaults().entrySet()) {
			if (entry.getValue() instanceof Color) {
				colors.add((String) entry.getKey()); // all the keys are strings
			}
		}
		Collections.sort(colors);
		for (String name : colors) {
			System.out.println(name);
		}
		
		// --- Print the current color setting ----
		printColorSetting();

		colorPropertiesAlreadyPrinted = true;
	}

}
 
Example 13
Project: FreeCol   File: FreeColCheckBoxUI.java   View Source Code Vote up 4 votes
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}
 
Example 14
Project: freecol   File: FreeColCheckBoxUI.java   View Source Code Vote up 4 votes
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}
 
Example 15
Project: Logisim   File: JTreeUtil.java   View Source Code Vote up 4 votes
@Override
public final void dragGestureRecognized(DragGestureEvent dge) {
	TreePath path = tree.getSelectionPath();
	if (path != null) {
		draggedNode = path.getLastPathComponent();
		if (drawImage) {
			Rectangle pathBounds = tree.getPathBounds(path); // getpathbounds
																// of
																// selectionpath
			JComponent lbl = (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree, draggedNode,
					false, tree.isExpanded(path), tree.getModel().isLeaf(path.getLastPathComponent()), 0,
					false);// returning the label
			lbl.setBounds(pathBounds);// setting bounds to lbl
			image = new BufferedImage(lbl.getWidth(), lbl.getHeight(),
					java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);// buffered
																	// image
																	// reference
																	// passing
																	// the
																	// label's
																	// ht
																	// and
																	// width
			Graphics2D graphics = image.createGraphics();// creating
															// the
															// graphics
															// for
															// buffered
															// image
			graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); // Sets
																								// the
																								// Composite
																								// for
																								// the
																								// Graphics2D
																								// context
			lbl.setOpaque(false);
			lbl.paint(graphics); // painting the graphics to label
			graphics.dispose();
		}
		dragSource.startDrag(dge, DragSource.DefaultMoveNoDrop, image, new Point(0, 0),
				new TransferableNode(draggedNode), this);
	}
}
 
Example 16
Project: FreeCol   File: FreeColTableUI.java   View Source Code Vote up 4 votes
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}
 
Example 17
Project: openjdk-jdk10   File: TreePosTest.java   View Source Code Vote up 4 votes
/** Set the background on a component. */
private JComponent setBackground(JComponent comp, Color c) {
    comp.setOpaque(true);
    comp.setBackground(c);
    return comp;
}
 
Example 18
Project: freecol   File: FreeColTableUI.java   View Source Code Vote up 4 votes
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}
 
Example 19
Project: freecol   File: FreeColMenuItemUI.java   View Source Code Vote up 4 votes
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}
 
Example 20
Project: freecol   File: FreeColButtonUI.java   View Source Code Vote up 4 votes
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}