I want to have one main window, and inside that window should be child windows, which are draggable, resizable etc. If I use just JFrames or JDialogs, it gives me many problems about the stacking of the windows. When the main window has focus, the child windows shouldn't move to the background.
This can be so-so fixed by listening to window events and bringing the child windows to front again, but now I get even more problems, for example popup boxes and other prompt dialogs are not stacked in the right order.
My solution is to use JInternalFrame for the child windows, but the disadvantage is, that they are clipped by the parent container.
Here's an example (just from internet). You see the clipping of internal frames:
My question is: is it possible to make them visible outside the parent component, so the overflow is visible.
The final goal of the GUI is to get something like photoshop. Windows which are independent on the screen, but which will never go to the background of its main window (parent)
Related
I am developing a Java Swing-based application with different perspectives. For the "main menu" perspective I do not want the window (JFrame) to be decorated, while in other perspective I do want the window to be decorated. In other words, I need want to change the decoration attribute dynamically.
I have tried to use setUndecorated(false) and setUndecorated(true), but I seems I can only set this once, before actually showing the window.
Is there a way to achieve this?
From the javadoc:
Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.
Therefore, once the JFrame is packed and/or displayed, you can no longer change that value. If you want to change the undecorated state of a JFrame you will need to dispose() it first, then change the state and eventually make it visible again.
After all, I had to take a different approach.
The former solution did work, as I stated in my last comment.
However, it was showing the default LAF window decoration, while I was using a different LAF.
So the result was graphically inconsistent with the rest of the LAF. Finally, I came with the right solution, I used setUndecorate(true) for my frame. Then, when I had to change my perspective to one using decorations I simply had to use the following code
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
And when I had to revert to the non decorate perspective, I use
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
This approach didn't need to dispose the window and show it again (which actually produced a brief but still visible hide/show of the window)
So I have a JavaFX 2.0 application, and the main window is shown on startup. What I want to do is have the user press a button, and have another window pop up next to the main window.
So, I want an undecorated stage "pinned" to the left of the main stage.
I know how to make the window, and how to make it undecorated, the new window works fine, I just want to make it so that it stays in the same position relative to the main window (or stage, whichever you prefer to call it), when that window is moved.
Just set a listener to reposition your window when its 'buddy' window is repositioned or resized. There may be a lag, since sometimes those events don't get fired until the final new position/size is set, though.
A Stage has a heightProperty and widthProperty, to which you can bind a listener using:
stage.widthProperty().addListener(listener);
You can do the same with almost any property that's exposed - the position properties, etc.
Your listener needs to implement the ChangeListener<Number> interface.
If I have a Swing Window which is displayed across more than one monitor, how can I get either all the GraphicsDevices or all the GraphicsConfigurations on which it appears?
window.getGraphicsConfiguration() only gets me one screen (either the one holding the largest portion of the window, or the one where the top left corner of the window resides). My ultimate goal is to be able to determine whether the window extends off of any of the screens, or overlaps taskbars/docks/menubars on any of them. This is made trickier by the possibility that a window extends beyond a taskbar to an adjoining screen, in which case overlapping the taskbar wouldn't be a problem.
This is most likely an obvious question, but I was wondering how I can keep a program behind all other windows (except the desktop)?
In a way, I am trying to achieve the opposite of keeping a window in the front.
Here's an example:
Window 1
Window 2
Random Window
My App
Desktop
However, I need it so that it will always stay against the desktop, so you cannot interact with it unless you're looking at the desktop itself.
public void toBack()here
If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window.
Places this Window at the bottom of the stacking order and shows it behind any other Windows in this VM. No action will take place is this Window is not visible. Some platforms do not allow Windows which are owned by other Windows to appear below their owners. Every attempt will be made to move this Window as low as possible in the stacking order; however, developers should not assume that this method will move this Window below all other windows in every situation.
4 Years late, but if you need the window to always stay in the back, even when the user clicks on it, you can use:
JFrame frame = new JFrame("");
frame.setFocusableWindowState(false);
frame.toBack();
setFocusableWindowState(false) prevents the activation of the window when clicked.
I am developing a Java Swing-based application with different perspectives. For the "main menu" perspective I do not want the window (JFrame) to be decorated, while in other perspective I do want the window to be decorated. In other words, I need want to change the decoration attribute dynamically.
I have tried to use setUndecorated(false) and setUndecorated(true), but I seems I can only set this once, before actually showing the window.
Is there a way to achieve this?
From the javadoc:
Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.
Therefore, once the JFrame is packed and/or displayed, you can no longer change that value. If you want to change the undecorated state of a JFrame you will need to dispose() it first, then change the state and eventually make it visible again.
After all, I had to take a different approach.
The former solution did work, as I stated in my last comment.
However, it was showing the default LAF window decoration, while I was using a different LAF.
So the result was graphically inconsistent with the rest of the LAF. Finally, I came with the right solution, I used setUndecorate(true) for my frame. Then, when I had to change my perspective to one using decorations I simply had to use the following code
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
And when I had to revert to the non decorate perspective, I use
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
This approach didn't need to dispose the window and show it again (which actually produced a brief but still visible hide/show of the window)