当前位置: 首页>>代码示例>>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;未经允许,请勿转载。