I have committed the necessary changes for this.
First, I have to say that I thought it through and the
active window is also always the
focused one, if it is not focused it can not be active. That is because the active state is used for determining whether the window should receive a "focus" border, among other things. It is currently tightly coupled with the focus sitting inside the window and I don't see a way to represent it differently. I thought about setting the focus property of the window itself, but that might have side effects which I can't foresee right now and it would require a lot of testing.
That means that the new activeWindowProperty of FXDesktopPane will "just" fetch you the currently active/focused window.
- Code: Select all
FXInternalWindow activeWindow = desktopPane.getActiveWindow();
if (activeWindow != null)
{
// Do something here.
}
else
{
// No focused window.
}
Since that isn't that useful for your use case, I've also implemented that the window managers are exposing a list of windows in their display order:
- Code: Select all
List<FXInternalWindow> windows = pane.getWindowManager().getWindows();
if (!windows.isEmpty())
{
FXInternalWindow topMostWindow = windows.get(windows.size() - 1);
currentWindowLabel.setText(topMostWindow.getTitle());
}
else
{
currentWindowLabel.setText("<none>");
}
So if you want to know which window is currently the top one, which equals the active one even if does not have the focus, you just have to listen to the list of the window manager for changes and then get the last one from it.
- Code: Select all
pane.getWindowManager().windowsProperty().addListener((ListChangeListener<FXInternalWindow>)pChange ->
{
List<? extends FXInternalWindow> windows = pChange.getList();
if (!windows.isEmpty())
{
FXInternalWindow topMostWindow = windows.get(windows.size() - 1);
currentWindowLabel.setText(topMostWindow.getTitle());
}
else
{
currentWindowLabel.setText("<none>");
}
});
That works with the FXDesktopWindowManager and the FXTabWindowManager. Obviously, if you change the window manager of the FXDesktopPane, you'll have to rewire your listener. You can see some of this in action in the MDITestMain application.
Now forth to the explanation on how to compile the project, that is easy:
- Checkout/Get the project from the SourceForge repository.
- Change into the "java" directory of "trunk".
- Run Ant (default goal is to build everything, so no parameters needed).
That's it, the jar you're looking for will be located in the "build/install" directory.