I am making a javafx application and I made the border around it invisible but now I would like to know how to "fake" someone from clicking on the fullscreen button (in Windows the middle button in the right top corner). I know how to make it 100% fullscreen but I just want to know how to "fake" the clicking of the windows fullscreen button.
Thanks.
Solution
I think you refer to a maximize button, and perhaps the stage.setMaximized() method.
Maximized != Full Screen
Setting the stage fullscreen viastage.setFullScreen() is generally a different thing than maximizing a stage. A full screen stage operates in full screen exclusive mode (i.e. no windowing at all, the stage takes over the entire display).
Related
What you seem to be doing is creating an undecorated window (i.e. a window with no default OS window frame and no in-built controls for resizing, title and minimize/maximize/close), but you still want some of the functionality that you would get if the window were decorated (by adding your own custom decoration controls to provide it). For more information on how to tackle that problem, see the related question:
JavaFX entirely customized windows?
In particular, checkout the Undecorator project, which is the defacto standard way of supplying such functionality for JavaFX.
Related
As we all know, when a user double-clicks on a window title bar, that window gets resized to the full available screen size. At least I have seen this happening in Mac OS. Any idea how to capture this event? What should I listen to in my code so that I know that the user has single or double-clicked the Window title?
Don’t try to intercept interactions with Window decorations directly
Don’t try to work with clicks. Handling state changes due to keyboard or window decoration interactions differs between OSes and isn’t a JavaFX function anyway.
Use Stage properties and API instead
Stage has a maximized property (and iconifed), listen for changes on relevant properties. Similarly, there is a full screen mode which is a bit different (see Stage Java doc).
Creating your own window decorations
If you really want complete control, you can use an undecorated stage style and add your own decorations in JavaFX for handling basic window system functions. That way, a lot of the decoration functionality can be handled internally by your app, but I really don’t recommend that. There was an old project named Undecorator which assisted doing this if you wanted to go that route (I don’t advise coding it yourself).
Capturing clicks is a bad idea as #jewelsea mentioned in his comment. The effort in the question was to know why the behavior. Upon research, I found that it is a bug already listed by Oracle - please find below: Each window when double-clicked on the title bar is expected to assume full-screen height and width (Maximised) and on double-clicking title bar again should get back to its previous size. This is not working beyond JDK8 is what I understood from this link. However, on macOS Monterey 12.1 (OpenJDK 17) the window is assuming maximized size on double-clicking the title bar, but, is unable to go back to the previous size when double-clicking again.
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8232812
I cannot figure this one out.
What I want to do is somehow disable the full-screen button on the right side of the title bar of the main application window, that seems to be a feature of Mountain Lion (10.8)+. It has two arrows pointing outwards diagonally.
There are related answers to this problem if the window is a dialog box, and an eclipse SWT-related solution here, but I need a solution to this problem if I have a single application primary-stage window, using javafx as the platform and netbeans 8 as the IDE.
I guess what I want is some way to access the cocoa API through javafx. Is this possible?
One way is to disable resizing completely:
stage.setResizable(false);
First off I am using Intellij IDEA's GUI tool.
I have a window that has a browse button, if the user clicks the browse button they can explore their computer for an image file. If they choose an Image file then the window will add that image to the screen next to the previous image, If the window just barely shows all the images and the user adds another one, I want the window to expand to be able to show the new image.
Does Java Swing have this capability? If so, how should I go about implementing it?
If you are using appropriate layout managers, you can simple call Window#pack.
You should also consider checking out How to use scroll panes, cause I have some very large images...
The other thing you can look at is the Scrollable interface
Are there any current implementations or frameworks for Java Swing that include functionality for a context-switcher menu?
More detail:
In our application, we have several sub-parts of the application, and only one of them is displayed at once. Presently there are several ways to switch between them, including tool bar buttons and via the View menu. We would like to add another means, that is accessible via a keyboard shortcut. This would bring up a context-switch menu, similar in concept to those available in modern OS'es.
If you press Alt+Tab and release the Tab while still holding down Alt, you will get a little window in the middle of the screen, displaying the various applications that are running at the moment. In Ubuntu, you get a screenshot of each application, plus its window manager icon. In Windows you get the window manager icons, and so on.
I think this is possible. You could apply a transformation to a Graphics option that you pass to each JFrame and have it paint a small version of itself on it. Then take those images and place them on a GlassPane on top of your application. The highlighting of the selected window might be tricky, but I think it would work nicely.
I'm using Qt Jambi 4.4 for a project I'm working on (and designing the windows in the Qt Designer eclipse plugin). One of the windows I'd like to use is a preview window which is basically just a window with a QWebView on it. How can I make it so that the QWebView resizes as the window does? I've set the sizePolicy to expanding for both Horizontal and Vertical position. What else do I need to do?
(also bear in mind that I'm a newbie to both Java and eclipse and need to be talked to in stupid people terms on both of those subjects)
UPDATE
Just to illustrate the point, here are a couple of screenshots (I've made the window background bright just to illustrate my point):
alt text http://img13.imageshack.us/img13/2103/screenshot2oi7.jpg
alt text http://img152.imageshack.us/img152/6250/screenshot1mz9.jpg
I don't know Jambi, but with Qt Designer just give the background the focus and then apply a layout from the toolbar. Then the main widget will get resized by that layout manager -- if you don't add that layout manager you'll get the widget resizing but the contents staying at their old positions.
I haven't used qt-jambi, but if it is anything like Qt in C++ or PyQt, the QWebView would resize automatically as the window size changes. As far as I know, setting size policies/ expansion factors, adding QSpacerItem objects etc. is only necessary if the sizing behavior is not working right. Just laying it out using an appropriate layout within the preview window should be sufficient. Do let me know if I have misunderstood the question.
You need to place the QWebView in a layout, that it will follow the change in its "container". For using layout with Qt Designer, refer to http://doc.trolltech.com/4.5/designer-layouts.html
From Qt Designer docs:
The form's top level layout can be set by clearing the selection
(click the left mouse button on the form itself) and applying a
layout. A top level layout is necessary to ensure that your widgets
will re-size correctly when its window is re-sized.