Java: Open URL in browser popup window in center of screen - java

I can't seem to find answer anywhere but How can I open URL in default-set browser, but not typical full screen browser but a small window in center of monitor?
I have Java application which uses Flickr API, when user logins it needs to open small window to show Authorize App or not, full screen huge window looks stupid.

Solution will be to use JavaFX WebView
https://docs.oracle.com/javafx/2/swing/SimpleSwingBrowser.java.htm
You can set the window size and window location to the main Frame.
Also If you like, it can integrate to your app like a internal panel or like a Dialog.

Related

Java place other windows app below of my swing application

I have a java swing application which is a ticker and it's on top of display. Now I need a way to place other windows applications when they are maximized to be below of my ticker. I mean I don't want my application to overlap other app' s toolbar.
Is there a way to implement such a functionality?
Something like in image, above is my ticker and a chrome can be maximized and the shouldn't overlap toolbar:
Thank you.
When you maximize an app, you are telling the window manager to "Set the size of this app to be the full size of the screen". Apparently you want that to be "Set the size of this app to be the full screen size, minus the size of my special app" - that is, place it just south of my special app. This is probably not possible without writing your own window manager.

Focus issues with JWebBrowser when browser window is refocused

I am using DJBrowser in my swing application to show a static html page with style sheets.
The JWebBrowser instance is added inside the panel and the panel is inside JFrame. The issue is with focus not coming back inside the browser when the browser frame regains the focus.
I am using java 6 (jdk 1.6.0_21 to be specific).
I have tried the SimpleWebBrowserExample inside the DJProject. After opening the JWebBrowser, the focus/cursor will go inside the browser content e.g. google search text field. When the screen is de-focused by ALT+TAB and refocused using the same keys, focus does not come inside the text field again (Not sure where the focus is going).
In my application, after opening the html page in the browser user generally wants to find some words inside the page using CTRL+F option then switch between the application and browser often. But after switching to browser user cannot access CTRL+F option as there is no focus on the native browser. (Unless he/she clicks on the browser by mouse).
After reading other similar posts I have tried setting the focus to the native component like - getNativeComponent().requestFocus(), but this did not work.
Could someone please help?
I got the answer to my question above from Christopher Deckers.
If you control the web page, you could keep track of the focused control, and maybe execute Javascript code to restore focus when you detect it should re-acquire it. Javascript code could be something like:
document.getElementById("mytext").focus();
This helped me. Now the web component is getting focus when the window is focused.
Just sharing with you all.
Thanks,
Tushar

How to Resize a window so that all components are visible

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

Facebook messenger application like docking

The Facebook messenger for windows 7 docks on the side of the screen and does not allow any other application to go on top of it.For example when i maximize another window , it does not cover the Facebook window.
How can i do this in java.
So far i can dock my window to the right, i set it undecorated and also always on top. But i want it to be like Facebook messenger so other windows can go maximize but only where it meets my docked window.
Here is a slimier question
http://www.dreamincode.net/forums/topic/278553-facebook-messenger-application-sidebar-like-docking-with-swing/

Swing components used for "splash" pages?

I see some Swing apps (like Eclipse) that load with a Welcome!/"splash" page. What kind of Swing component is this? Its sort of like a web page (like the old <imagemap>s!) embedded inside a Swing app and is very cool.
You could design the splash screen using an image editor, like Photoshop or GIMP. Save the image in a format that Java supports, like JPG, GIF, or PNG. Design the splash screen at a resolution that will work on low resolution devices like netbooks and projectors.
E.g. the Eclipse splash screen is ~450x300 pixels:
To display the image, you could use a JDialog whose border and close button have been hidden via setUndecorated(true). The JDialog could contain a single JLabel. Size both the JDialog and JLabel to be able to display the entire image. The JLabel's icon property should be set to the splash screen image.
You could display the splash screen for a fixed amount of time by employing Swing's Timer class. Consider allowing the user to optionally disable the splash screen so they don't always have to waste time watching it every time they start your program.
Or, rather than using a timer to display the splash screen for a fixed amount of time, you could consider hiding the splash screen as soon as the application has finished initializing. What "initializing the application" entails is specific to your application. This is the approach that Eclipse uses (its splash screen even has a progress bar).
Your question actually appears to be about the Eclipse "Welcome screen" (see screenshot below), not the Eclipse "splash screen". The Welcome Screen does include clickable areas. Java has some limited abilities to display HTML content. See http://docs.oracle.com/javase/tutorial/uiswing/components/html.html for some details. Java's built in support for HTML is pretty limited, and so it may not meet your needs. Here is a guide that talks about using a read-only JEditorPane to display HTML content, and capturing hyperlink click events to perform custom actions:
http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JEditorPane.html
Checkout this tutorial http://docs.oracle.com/javase/tutorial/uiswing/misc/splashscreen.html
Its really easy to do. Just create a splash screen entry in your manifest file that points to an image resource in your jar file.
e.g.
SplashScreen-Image: resources/splash.png
The image can even have transparency, so you can make it appear to be non-rectangular.

Categories