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


Java JComponent.setOpaque方法代碼示例

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


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

示例1: StartPageContent

import javax.swing.JComponent; //導入方法依賴的package包/類
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) );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:StartPageContent.java

示例2: getTreeCellRendererComponent

import javax.swing.JComponent; //導入方法依賴的package包/類
@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;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:16,代碼來源:TreeSelectionRenderer.java

示例3: createContentImage

import javax.swing.JComponent; //導入方法依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:DnDSupport.java

示例4: initialize

import javax.swing.JComponent; //導入方法依賴的package包/類
/**
 * Set up component.
 */
protected void initialize() {
    JComponent component = getComponent();
    component.setToolTipText(label.getToolTipText());
    component.setEnabled(editable);
    component.setOpaque(false);
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:10,代碼來源:OptionUI.java

示例5: setOpaqueLayerRecursive

import javax.swing.JComponent; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:15,代碼來源:FreeColDialog.java

示例6: updateFieldStatus

import javax.swing.JComponent; //導入方法依賴的package包/類
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;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:IssuePanel.java

示例7: installUI

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    c.setOpaque(false);
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:7,代碼來源:FreeColLabelUI.java

示例8: cancelHighlight

import javax.swing.JComponent; //導入方法依賴的package包/類
private void cancelHighlight(JComponent label) {
    if (!reloading) {
        label.setOpaque(false);
        label.getParent().repaint();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:IssuePanel.java

示例9: setTableCellRendererColors

import javax.swing.JComponent; //導入方法依賴的package包/類
/**
 * 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;
	}

}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:49,代碼來源:GraphGlobals.java

示例10: setTableCellRendererColors

import javax.swing.JComponent; //導入方法依賴的package包/類
/**
 * 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;
	}

}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:49,代碼來源:OntologyVisualisationConfiguration.java

示例11: dragGestureRecognized

import javax.swing.JComponent; //導入方法依賴的package包/類
@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);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:45,代碼來源:JTreeUtil.java

示例12: setBackground

import javax.swing.JComponent; //導入方法依賴的package包/類
/** Set the background on a component. */
private JComponent setBackground(JComponent comp, Color c) {
    comp.setOpaque(true);
    comp.setBackground(c);
    return comp;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:TreePosTest.java


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