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.
Related
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.
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
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 have specified splash picture in jnlp application
<icon href="starter.png" kind="splash"/>
When I use IE to run the jnlp, the splash window showed up, but my application can't access the splash. I have used the static variable to obtain the instance:
private static SplashScreen splash = SplashScreen.getSplashScreen();
in main(), I first check whether splash is null, and unfortunately, it is null. Then why can I see it for a few seconds? Did Java Web Start window closed it?
If I run application (not jnlp) in Eclipse with vm arguments then I can access the splash screen and update my slow loading process.
How do I access the splash screen using jnlp?
The splash screen as used by web start predates the AWT SplashScreen API & is not compatible with it.
How do I access the splash screen using jnlp?
It cannot be accessed.
..it looks like I have to pop up a window to show the picture.
I'd say that is the only option.
..But that way there is no way to show transparency with the splash screen at least before Java 7, right?
Correct. Given that..
..I mean, I don't want to use the reflection either.
..well, reaching into Sun(/Oracle) private classes is not necessarily 'reflection', I guess that is your worry, and that worry is well founded. Either give up on a partially transparent splash, or wait for Java 7.
But then, gotta' comment, I've never before seen a semi-transparent splash. If a splash is worth showing, why not show it at full opacity?
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.