/* * Delegate initialization (create native window and all the * related resources). */ @Override // PlatformWindow public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) { initializeBase(_target, _peer, _owner, new CPlatformView()); final int styleBits = getInitialStyleBits(); responder = createPlatformResponder(); contentView = createContentView(); contentView.initialize(peer, responder); final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L; Rectangle bounds; if (!IS(DECORATED, styleBits)) { // For undecorated frames the move/resize event does not come if the frame is centered on the // screen // so we need to set a stub location to force an initial move/resize. Real bounds would be set // later. bounds = new Rectangle(0, 0, 1, 1); } else { bounds = _peer.constrainBounds(_target.getBounds()); } final long nativeWindowPtr = nativeCreateNSWindow( contentView.getAWTView(), ownerPtr, styleBits, bounds.x, bounds.y, bounds.width, bounds.height); setPtr(nativeWindowPtr); if (target instanceof javax.swing.RootPaneContainer) { final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer) target).getRootPane(); if (rootpane != null) rootpane.addPropertyChangeListener( "ancestor", new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { CLIENT_PROPERTY_APPLICATOR.attachAndApplyClientProperties(rootpane); rootpane.removePropertyChangeListener("ancestor", this); } }); } validateSurface(); }
protected int getInitialStyleBits() { // defaults style bits int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE; if (isNativelyFocusableWindow()) { styleBits = SET(styleBits, SHOULD_BECOME_KEY, true); styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true); } final boolean isFrame = (target instanceof Frame); final boolean isDialog = (target instanceof Dialog); final boolean isPopup = (target.getType() == Window.Type.POPUP); if (isDialog) { styleBits = SET(styleBits, MINIMIZABLE, false); } // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always // is undecorated. { this.undecorated = isFrame ? ((Frame) target).isUndecorated() : (isDialog ? ((Dialog) target).isUndecorated() : true); if (this.undecorated) styleBits = SET(styleBits, DECORATED, false); } // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never // resizable { final boolean resizable = isFrame ? ((Frame) target).isResizable() : (isDialog ? ((Dialog) target).isResizable() : false); styleBits = SET(styleBits, RESIZABLE, resizable); if (!resizable) { styleBits = SET(styleBits, ZOOMABLE, false); } else { setCanFullscreen(true); } } if (target.isAlwaysOnTop()) { styleBits = SET(styleBits, ALWAYS_ON_TOP, true); } if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) { styleBits = SET(styleBits, MODAL_EXCLUDED, true); } // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look. if (isPopup) { styleBits = SET(styleBits, TEXTURED, false); // Popups in applets don't activate applet's process styleBits = SET(styleBits, NONACTIVATING, true); styleBits = SET(styleBits, IS_POPUP, true); } if (Window.Type.UTILITY.equals(target.getType())) { styleBits = SET(styleBits, UTILITY, true); } if (target instanceof javax.swing.RootPaneContainer) { javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer) target).getRootPane(); Object prop = null; prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK); if (prop != null) { styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString())); } if (isDialog && ((Dialog) target).getModalityType() == ModalityType.DOCUMENT_MODAL) { prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET); if (prop != null) { styleBits = SET(styleBits, SHEET, Boolean.parseBoolean(prop.toString())); } } prop = rootpane.getClientProperty(WINDOW_STYLE); if (prop != null) { if ("small".equals(prop)) { styleBits = SET(styleBits, UTILITY, true); if (target.isAlwaysOnTop() && rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE) == null) { styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, true); } } if ("textured".equals(prop)) styleBits = SET(styleBits, TEXTURED, true); if ("unified".equals(prop)) styleBits = SET(styleBits, UNIFIED, true); if ("hud".equals(prop)) styleBits = SET(styleBits, HUD, true); } prop = rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE); if (prop != null) { styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, Boolean.parseBoolean(prop.toString())); } prop = rootpane.getClientProperty(WINDOW_CLOSEABLE); if (prop != null) { styleBits = SET(styleBits, CLOSEABLE, Boolean.parseBoolean(prop.toString())); } prop = rootpane.getClientProperty(WINDOW_MINIMIZABLE); if (prop != null) { styleBits = SET(styleBits, MINIMIZABLE, Boolean.parseBoolean(prop.toString())); } prop = rootpane.getClientProperty(WINDOW_ZOOMABLE); if (prop != null) { styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString())); } prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE); if (prop != null) { styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString())); } prop = rootpane.getClientProperty(WINDOW_SHADOW); if (prop != null) { styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString())); } prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND); if (prop != null) { styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString())); } } if (isDialog) { styleBits = SET(styleBits, IS_DIALOG, true); if (((Dialog) target).isModal()) { styleBits = SET(styleBits, IS_MODAL, true); } } peer.setTextured(IS(TEXTURED, styleBits)); return styleBits; }