How to Attach Modal Dialogue to Main Window in JavaFX? - java

Examples of Attached Modal Dialogues:
Is there any way to bring this to JavaFX?

Couldn't find support for attached dialogs out of the JavaFX box... So, how I would do it...
The dialog part: there's this, no way I'm beating it example gist
And a tweak to the CSS file - the .modal-dialog styleClass:
-fx-position: fixed
-fx-top: 0

Related

Move position of javafx application stage title text

My JavaFX applications look even more different between Windows and OSX than I'd like, as the title text on the mac is centered, but on Windows its left aligned. Ideally I want to make both centered.
Compare OSX
http://i.imgur.com/48YGy5D.png
with Windows:
http://i.imgur.com/alvWo2n.png
Of course, I'd like to know if anyone has found a way to get around this default?
Many thanks,
The best way I have found is to make an undecorated window and add my own title bar to the top of the frame, this way I have full control over everything and the OS/platform will never interfere with the layout.
See here for more info on one way you could do this:
How to create customize title bar with close button on jFrame?

show hide panel in javafx using fxml

I have made the GUI of my javafx application in scenebuilder. I have correctly made the settings of placing the fxml and my application works perfect. Now I want to add action events to buttons and when a button is clicked, a panel should be shown and when other button is clicked, the other panel should be shown. Please help me. And remember that I am building my interface using scenebuilder i.e using fxml for my interface.
Thank you.
you can use the following code and hide the panes you want to hide
(paneid).setVisible(false);
and appear the new code
(paneid).setVisible(True);
here the id is the what you put for "fx:id" in scenebuilder.
What you can do is to write this code to hide the pane
(paneId).setVisible(false);
(paneId).setManaged(false);
and show it again by setting the parameters to true
(paneId).setVisible(true);
(paneId).setManaged(true);

Java Swing Exit Icon?

I was wondering how to change the minimize, maximize, and exit button icons in the top left of the default JFrame swing window? I've looked everywhere and can't find a tutorial or method that does it.
Minimize, maximize/restore and close buttons are bound to the frame decoration used.
If you are using a frame decorated by system (for example some Aero frame in Windows 7) - you cannot modify those buttons since the whole frame decoration is provided by system and there is no good way to invtervene and change its behavior.
On the other hand - if you are using a custom Look and Feel (shorty - L&F) written on Java and it provides its own frame decoration - it is possible to modify it if you have access to that L&F sources or if that L&F provides some options to add/remove those buttons.
You can read more about L&F here:
http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel
You can also find a lot of links to custom L&Fs here:
Java Look and Feel (L&F)
Start with JFrame.setDefaultLookAndFeelDecorated(true).
Then set the Pluggable Look and Feel.
For best results, this is most reliably done before the first GUI element is visible on screen.
See How to Make Frames - Specifying Window Decorations for more info.
As far as I know, you cannot, but if this is something you need to have done, you can use Netbeans to use JavaFX, which allows you to fully customize the window, including the buttons like that. The window doesnt even need to have these buttons.

JFace Dialog maximize programmatically

I am currently trying to maximize a JFace Dialog programmatically.
Usually calling setMaximized(true) on the parentShell of the Dialog would be sufficient to achieve this.
However, it does not work for my Dialog. Maximizing it manually using the window buttons works.
Does anybody have an idea how to do it?
Try to do following:
Rectangle bounds = parentShell.getDisplay().getClientArea();
myDialog.setBounds(bounds);
parentShell.setMaximized(true);
UPD: But this approach is not fairly true as this code breaks previous size of you dialog.
Following approach seems to work better:
parentShell.pack();
parentShell.setMaximized(true);

How do I get "Goodbye Window" to show up in Java?

I have a Java network application and this is what I want to do:
After user logs out, his interface window closes.
Now, I want for another window to show up that will say something like: "Thank you for using our application".
This final window should be borderless and without any available option, more like a plain picture (jpeg? why not?). By clicking on it, user will be sure to close this final window.
I googled and couldn't fin anything on this matter, it's hard to phrase the question.
I hope someone helps me...
https://docs.oracle.com/javase/1.5.0/docs/api/javax/swing/JWindow.html
A JWindow is a borderless, undecorated JFrame (no titlebar or buttons).
This should be what you need.
This should help:
http://java.sun.com/docs/books/tutorial/uiswing/events/windowlistener.html
You're interested in the windowClosing and windowClosed events
You have various possibilities, depending on when you want this dialog to display :
if you want it to display juste before the app closes, use addShutdownHook
if you want it to display when the last window closes, use addWindowListener
You can then use a JWindow with your image inside, and use addMouseListener to wait for the user to click on it.

Categories

Resources