本文整理汇总了Java中sun.awt.SunToolkit.getHeavyweightComponent方法的典型用法代码示例。如果您正苦于以下问题:Java SunToolkit.getHeavyweightComponent方法的具体用法?Java SunToolkit.getHeavyweightComponent怎么用?Java SunToolkit.getHeavyweightComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.SunToolkit
的用法示例。
在下文中一共展示了SunToolkit.getHeavyweightComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCursor
import sun.awt.SunToolkit; //导入方法依赖的package包/类
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
if (comp == null) {
return;
}
Cursor cur = useCache ? cursor : getCapableCursor(comp);
Component nc = null;
if (useCache) {
synchronized (this) {
nc = nativeContainer.get();
}
} else {
nc = SunToolkit.getHeavyweightComponent(comp);
}
if (nc != null) {
ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
if (nc_peer instanceof XComponentPeer) {
synchronized (this) {
nativeContainer = new WeakReference<Component>(nc);
}
//6431076. A subcomponents (a XTextArea in particular)
//may want to override the cursor over some of their parts.
((XComponentPeer)nc_peer).pSetCursor(cur, false);
// in case of grab we do for Swing we need to update keep cursor updated
// (we don't need this in case of AWT menus). Window Manager consider
// the grabber as a current window and use its cursor. So we need to
// change cursor on the grabber too.
updateGrabbedCursor(cur);
}
}
}
示例2: paintPopupMenuBackground
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public void paintPopupMenuBackground(SynthContext context, Graphics g,
int x, int y, int w, int h) {
Region id = context.getRegion();
int gtkState = GTKLookAndFeel.synthStateToGTKState(
id, context.getComponentState());
boolean isHW = SunToolkit.getHeavyweightComponent(
context.getComponent()) instanceof ModalExclude;
synchronized (UNIXToolkit.GTK_LOCK) {
if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, isHW)) {
return;
}
ENGINE.startPainting(g, x, y, w, h, id, gtkState);
ENGINE.paintBox(g, context, id, gtkState,
ShadowType.OUT, "menu", x, y, w, h);
GTKStyle style = (GTKStyle)context.getStyle();
Insets insets = style.getInsets(context, null);
ENGINE.paintBackground(g, context, id, gtkState,
style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
x + insets.left, y + insets.top, w - insets.left - insets.right,
h - insets.top - insets.bottom);
BufferedImage img = ENGINE.finishPainting();
if(!isHW) {
int border = img.getRGB(0, h / 2);
if (img != null && border == img.getRGB(w / 2, h / 2)) {
// fix no menu borders in Adwaita theme
Graphics g2 = img.getGraphics();
Color c = new Color(border);
g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
Math.max((int) (c.getGreen() * 0.8), 0),
Math.max((int) (c.getBlue() * 0.8), 0)));
g2.drawLine(0, 0, w - 1, 0);
g2.drawLine(w - 1, 0, w - 1, h - 1);
g2.drawLine(0, h - 1, 0, 1);
g2.setColor(c.darker());
g2.drawLine(w - 1, h - 1, 0, h - 1);
g2.dispose();
g.drawImage(img, x, y, null);
}
}
}
}