Eppleton, the Munich-based NetBeans Platform consultancy, has been learning about this area of the NetBeans Platform recently, for one of its customers. The end result was the integration of the SwingX project's "org.jdesktop.swingx.JXPanel", together with "javax.swing.JLayeredPane", to create the translucent effects of the TopComponents in the screenshot below:
I.e., your TopComponents could be JXPanels, if that's the way you'd prefer them to be. Or something else.
In the image above, there are in fact 3 TopComponents, one of which has this client property in its constructor:
// setting this property informs the Windowmanager that this window is
// our Main Window. Not a standard property.
putClientProperty(TranslucentWindowManager.MAINWINDOW, Boolean.TRUE);
But how to get started with all of this? There's a "DummyWindowManager" in the NetBeans sources that you can start experimenting with. Let's do so now.
A simple way to remove that JAR is to go to "platform.properties" in your application and use this list of disabled modules (definitely won't work in all cases, since your dependencies will be different depending on what else you're using, but if you're starting from scratch, this will be all you'll need):
disabled.modules=\\
org.netbeans.api.visual,\\
org.netbeans.core.execution,\\
org.netbeans.core.multiview,\\
org.netbeans.core.nativeaccess,\\org.netbeans.core.windows,\\
org.netbeans.libs.jsr223,\\
org.netbeans.modules.applemenu,\\
org.netbeans.modules.autoupdate.services,\\
org.netbeans.modules.autoupdate.ui,\\
org.netbeans.modules.core.kit,\\
org.netbeans.modules.favorites,\\
org.netbeans.modules.options.keymap,\\
org.netbeans.modules.templates,\\
org.openide.compat,\\
org.openide.execution,\\
org.openide.options,\\
org.openide.util.enumerations
Note the line in bold below, i.e., that's the line that will result in the "core-windows.jar" to be excluded.
Especially note this class-level annotation, which results in your window manager replacing the one provided by the NetBeans Platform:
@ServiceProvider(service = WindowManager.class, supersedes = "org.netbeans.core.windows.WindowManagerImpl")
In other words, when the module has been built, you'll find a META-INF/services registration consisting of these entries:
org.demo.winsys.MyWindowManager
#-org.netbeans.core.windows.WindowManagerImpl
Note: Make sure to add the required NetBeans API modules to the application (i.e., Nodes API, Window System API, and Utilities API).
@Override
public void restored() {
WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
public void run() {
View1TopComponent.findInstance().open();
View2TopComponent.findInstance().open();
}
});
}
Now look more closely at MyWindowManager.java and change it to fit your business requirements.
If you omit core.windows from your app, then there is no need to supersede core.windows.WindowManagerImpl.
I would have thought the same. Tried that too. But then there's a class cast problem or as Toni puts it in an e-mail to me: "
One small thing: core.windows has to be excluded due to a bug. Something get's the WindowManager from Lookup and tries to cast it to a concrete implementation. This leads to an exception. If that could easily be fixed we could probably also reuse the window system functionality like persistence and launching windows automatically."
This is incredibly cool! I asked about this "feature" on NB forum, without any concrete answer. Now, you gave me the answer with an "example" as a bonus. IMHO, you really deserve a "NB-guru" status! :)
Thanks Eduardo. Would be great to get a screenshot from you when you've made some progress with creating your own window system. :-)
Nice! Worked like a charm! Using Feed Reader sample, I created a "window manager" module with your MyWindowManager and voila! Good bye NB WM and welcome lots of ideas! :)
PS: I will post some screenshots as soon as I have something useful
Nice! Worked like a charm using Feed Reader sample! Good bye NB WM and welcome lots of ideas!
PS: I will post some screenshots as soon as I have something useful
An opened door on the 3rd dimension ? :-)
You need to update your url for MyWindowManager.java to this: https://blogs.oracle.com/geertjan/resource/MyWindowManager.java
Thanks, done!
Thinking one step further:
Is it possible to start MyWindowManager in fullscreen mode?
So I could think of a desktop-manager for Java apps...
import org.openide.awt.Actions;
import org.openide.windows.OnShowing;
@OnShowing
public class FullScreenAtStartUp implements Runnable {
@Override
public void run() {
Actions.forID("Window", "org.netbeans.core.windows.actions.ToggleFullScreenAction").actionPerformed(null);
}
}
MyWindowManager.java can not find the function "invokeWhenUIReady" and "PROP_TC_OPENED" and "PROP_TC_CLOSED".
can not find the function "invokeWhenUIReady" and two fields "PROP_TC_OPENED" and "PROP_TC_CLOSED".
Two seconds of googling the terms "invokeWhenUIReady netbeans" gives me the answer to your question. Try google. It's free. It works.
Is this windows manager still keep the tearing off tab feature of netbeans platform? Are the Main Window and View1 windows independent (if Main window is closed and View1 window is still open)?
Thank you very much!