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.
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 need to add an additional button to the right of the system buttons, as shown in the photo. clicking on it will perform a specific action related to my app. Can this be done?
In general: No. There's not an API for this, only the OS can control the navigation area. Consider also the problems you'd run into with the variety of system navigation styles available, many of which, like gesture navigation, don't even have buttons.
Some apps fake things with screen overlays that reimplement some or all of the navigation and/or hide the system navigation, but you're going to run into all of the above issues doing so, plus the issues inherent in screen overlays, plus you'll have no guarantee that however you do it will continue to work into the future. I wouldn't recommend trying this approach.
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.
I've set my program to appear in the system tray by doing what Oracle told to do. My first question is about the icon. I have a lot of programs in the system tray and mine is hidden. Can I make it to show in the bar without needing to click the arrow in the tray?
I also figured out that I can display a message by calling trayIcon.displayMessage(title, content, icon). I wonder if I can change the outlook of the balloon in the way Skype has done it.
Or do I need to use someting else do display a message? It should appear always in the front of all the applications and it shouldn't hinder other applications. For example if the user is playing a game, the information dialog shouldn't steal the focus from mouse and keyboard.
No you cant change the style of the baloon using the java systray mechanism. Skype doesnt use the java mechanism to show the systray. It is the systems task to style and display the baloon.
To show your icon, it is a windows configuration - when you click the arrow, there is a "customize" link, where you can configure which icons are displayed.
If you want to influence the style of the window, you need to implement your custom Frame that feels like and is positioned like a systray info window. And you would not use the Tray classes.
Concerning your question regarding skinning. The SystemTray displayMessage balloon can not be customized in any way.
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.