use of java.awt.peer.FramePeer in project jdk8u_jdk by JetBrains.
the class Util method createEmbeddedFrame.
public static Frame createEmbeddedFrame(final Frame embedder) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InstantiationException, InvocationTargetException {
Toolkit tk = Toolkit.getDefaultToolkit();
FramePeer frame_peer = (FramePeer) embedder.getPeer();
System.out.println("frame's peer = " + frame_peer);
if ("sun.awt.windows.WToolkit".equals(tk.getClass().getName())) {
Class comp_peer_class = Class.forName("sun.awt.windows.WComponentPeer");
System.out.println("comp peer class = " + comp_peer_class);
Field hwnd_field = comp_peer_class.getDeclaredField("hwnd");
hwnd_field.setAccessible(true);
System.out.println("hwnd_field =" + hwnd_field);
long hwnd = hwnd_field.getLong(frame_peer);
System.out.println("hwnd = " + hwnd);
Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
Constructor constructor = clazz.getConstructor(new Class[] { Long.TYPE });
return (Frame) constructor.newInstance(new Object[] { hwnd });
} else if ("sun.awt.X11.XToolkit".equals(tk.getClass().getName())) {
Class x_base_window_class = Class.forName("sun.awt.X11.XBaseWindow");
System.out.println("x_base_window_class = " + x_base_window_class);
Method get_window = x_base_window_class.getMethod("getWindow", new Class[0]);
System.out.println("get_window = " + get_window);
long window = (Long) get_window.invoke(frame_peer, new Object[0]);
System.out.println("window = " + window);
Class clazz = Class.forName("sun.awt.X11.XEmbeddedFrame");
Constructor constructor = clazz.getConstructor(new Class[] { Long.TYPE, Boolean.TYPE });
return (Frame) constructor.newInstance(new Object[] { window, true });
}
throw new RuntimeException("Unexpected toolkit - " + tk);
}
use of java.awt.peer.FramePeer in project intellij-community by JetBrains.
the class WindowManagerImpl method updateFrameBounds.
private int updateFrameBounds(IdeFrameImpl frame) {
int extendedState = frame.getExtendedState();
if (SystemInfo.isMacOSLion) {
@SuppressWarnings("deprecation") ComponentPeer peer = frame.getPeer();
if (peer instanceof FramePeer) {
// frame.state is not updated by jdk so get it directly from peer
extendedState = ((FramePeer) peer).getState();
}
}
boolean isMaximized = extendedState == Frame.MAXIMIZED_BOTH || isFullScreenSupportedInCurrentOS() && frame.isInFullScreen();
boolean usePreviousBounds = isMaximized && myFrameBounds != null && frame.getBounds().contains(new Point((int) myFrameBounds.getCenterX(), (int) myFrameBounds.getCenterY()));
if (!usePreviousBounds) {
myFrameBounds = frame.getBounds();
}
return extendedState;
}
use of java.awt.peer.FramePeer in project jdk8u_jdk by JetBrains.
the class Frame method addNotify.
/**
* Makes this Frame displayable by connecting it to
* a native screen resource. Making a frame displayable will
* cause any of its children to be made displayable.
* This method is called internally by the toolkit and should
* not be called directly by programs.
* @see Component#isDisplayable
* @see #removeNotify
*/
public void addNotify() {
synchronized (getTreeLock()) {
if (peer == null) {
peer = getToolkit().createFrame(this);
}
FramePeer p = (FramePeer) peer;
MenuBar menuBar = this.menuBar;
if (menuBar != null) {
mbManagement = true;
menuBar.addNotify();
p.setMenuBar(menuBar);
}
p.setMaximizedBounds(maximizedBounds);
super.addNotify();
}
}
use of java.awt.peer.FramePeer in project jdk8u_jdk by JetBrains.
the class Frame method setTitle.
/**
* Sets the title for this frame to the specified string.
* @param title the title to be displayed in the frame's border.
* A <code>null</code> value
* is treated as an empty string, "".
* @see #getTitle
*/
public void setTitle(String title) {
String oldTitle = this.title;
if (title == null) {
title = "";
}
synchronized (this) {
this.title = title;
FramePeer peer = (FramePeer) this.peer;
if (peer != null) {
peer.setTitle(title);
}
}
firePropertyChange("title", oldTitle, title);
}
use of java.awt.peer.FramePeer in project jdk8u_jdk by JetBrains.
the class Frame method removeNotify.
/**
* Makes this Frame undisplayable by removing its connection
* to its native screen resource. Making a Frame undisplayable
* will cause any of its children to be made undisplayable.
* This method is called by the toolkit internally and should
* not be called directly by programs.
* @see Component#isDisplayable
* @see #addNotify
*/
public void removeNotify() {
synchronized (getTreeLock()) {
FramePeer peer = (FramePeer) this.peer;
if (peer != null) {
// get the latest Frame state before disposing
getState();
if (menuBar != null) {
mbManagement = true;
peer.setMenuBar(null);
menuBar.removeNotify();
}
}
super.removeNotify();
}
}
Aggregations