Swing Application on Win 8 Platform - java

I have Swing Application which runs absolutely perfect on Windows XP but fails to give desired Look And Feel on Windows 8(Dimension of Frame and Dialog Changes).I googled a lot but no solution. Will I have to make some changes to my app before deploying on Win 8?

use layouts for your Jframe.
If you use IDE for design means the look and feel will change in another system.
so use layout for your design.
check this link click here
You can use this layout in Windows XP then try it Windows8.
This looks Will not change.

Related

Java Swing application under Gnome - use Adwaita (dark skin) window title bar

Is there a way for a Java Swing desktop application that runs in Gnome (3.14) on Linux (Debian) to make Gnome use the dark-themed (Adwaita) version of the window decoration?
I am using a custom dark Swing look-and-feel, and the only thing that is really annoying is that the title bar (native Gnome) is very bright. I already have used the Tweak tool to use Adwaita system-wide, but this doesn't kick in for applications that do not explicitly support dark-theme (e.g. Iceweasel, Icedove, Gimp, Libre Office, ...)
Here's a screenshot that illustrates the problem:
Ok, I found a viable solution for my specific system, so I will show what I did here. It is related to this question. In the accepted answer you can see that the issue is with legacy Gtk-2 applications, and that includes Java apparently. In the comments section there is a link to a Adwaita-Dark clone that applies the dark theme also to Gtk-2.
Unfortunately that theme is out-of-sync with Debian Jessie / Gnome 3.14 somehow, and if one installs that theme most widgets are broken in Iceweasel, Icedove etc. However. Since I don't care about the widgets but only the window title bar here, you can selectively use that clone only for the window decoraction.
So I downloaded that clone, and placed a symlink in ~/.local/share/themes/adwaita-again (you can use any name here it seems). Then in the Tweak tool, just flip the window style, like so:
And voilĂ , window title bars are dark for all applications:
This is also great when working with IntelliJ IDEA and "Darcula" theme. Linux FTW.
Edit: It seems the above approach does not fully work, at least after rebooting I am seeing the bright colours again. I found a more simple variant now: Copy the original Adwaita theme and patch the Metacity file. I have created a repository with my patched version.

jSeparator looks - Preview Design vs Run File (netbeans)

I have this little problem. I'm using Netbeans. When I click on Preview Design I see the jSeparators like this:
But when I run the project this is what it looks like:
How can I fix this problem? I want the project to look like the Preview Design.
Thanks!
When you run your window (JFrame, JDialog) / component (JPanel) in Preview Design it's displayed using system look and feel, but when you run your application UIManager uses a cross-platform L&F by default, also called Metal L&F.
I want the project to look like the Preview Design.
See related:
How to Set the Look and Feel
How to set jframe look and feel
Off-topic
This is one of the arguments against the use of GUI builders. You will lay-out all your components using Preview Design to arrange all your components. Let's say you use Windows and now you set the look and feel to system L&F so in your computer your application runs and displays prefectly:
public static void main(Strin[] args) {
...
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
...
}
Awesome, it works! Now lets say a friend of yours likes your application and you share it with your friend. It turns out your mate uses Linux or Mac... Then the system look and feel won't be Windows anymore and GUI will probably look terrible. For instance consider this post: Different looks beetwen Preview and Runview You can see in the second picture that last row of components is cut in the half.
This happens because the Layout Manager used by NetBeans GUI builder is GroupLayout, which is designed to be used with GUI builders and it can be a really pain in the ass (sorry for the expression, but it's true) to make it work in a different platform than yours.
In my experience I've used builder for a couple of minor projects, intended to run all in the same platform, but when I really had to develop a cross-platform application it turns out a nightmare. So I strongly recommend you to forget about GUI builders and write your GUIs by hand.
See GroupLayout autogenerated code in NetBeans. There is a list of really good layout managers that can make your life easier and your applications UI truly cross-platform, as any Java application is supposed to be.

Taskbar behaviour for Swing Application

I have a Swing Application that currently has the feature setAlwaysOnTop(true); and is docked to the top of the screen.
Now i can't find a way for other windows (Browser, IDE) to maximize in respect of my application.
To make myself clearer here is a picture:
As you see, currently the maximized window is behind my Application.
I don't want other applications to expand behind my application; just like maximizing a browser won't expand it past the Windows taskbar.
How can i realize the desired behaviour with JAVA?
If not possible directly with/in Java, are there other ways to achieve this?
N.B.: The App only has to work on Windows 7.
I guess the reason for my lack of search results was my inability to describe this behaviour. Any hints would be appreciated.
Thank you for your time.
It is called an Application Desktop Toolbar
The system prevents other applications from using the desktop area used by an appbar
Which is very Windows-specific, making it difficult in pure Java.
Perhaps jdeskbar could be an option if you really have to do this in Java and not a more "Windowsy" language
EDIT: According to the jDeskBar project wiki, the current release is broken. Maybe it can be picked apart?

How to make a "background" desktop program in java?

I was wondering how to make like one of those silent programs that run on your desktop but at the same time doesn't show a picture in your taskbar in the bottom?
This is kind of hard to explain since my experience is limited to making GUIs that show up in the taskbar and has the top bar with the minimize, maximize, and close buttons.
I want to make a program running that is something like this:
See those boxes? How would I create something like that with Java?
You can use translucent windows in Java: http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html
It will depend on the capabilities of the platform (that you can query for). You will probably need at least per-pixel transparency, if not translucency. No idea if they are supported on both Windows 7 and Mac, you have to try.

Make the java systray look prettier in Linux

I'm making a Java Application on Linux that uses sytray using Java 6 and Swing. The app looks great (uses the system look and feel) but the systray looks awful. I mean the systray menu looks like old widgedts (Motif?). I wonder if there is a way to set a look and feel or something to make the system tray prettier.
Heres a screenshot of the tray:
Have you tried JXTrayIcon?
I tested this demo from SwingHelper on Ubuntu 10.10 with Compiz and it looks cool.
UPDATE
As 2020, these links are broken and this solution has many drawbacks today. For instance, GNOME3 desktop environments had removed entirely system tray icons and they replaced it with AppIndicator.
Java's (AWT/Swing) System Tray support is broken today. I recommend using this Java library: https://github.com/dorkbox/SystemTray
From the site:
Professional, cross-platform SystemTray support for Swing/AWT, GtkStatusIcon, and AppIndicator on Java 6+. This library provides OS Native menus and Swing/AWT menus, depending on the OS and Desktop Environment and if AutoDetect (the default) is enabled.
For reference, you can found a copy of the original example at here
Swing uses emulated UI widgets. It has a number of styles or themes you can apply. If you would prefer more native results you will need to look for another widget toolkit. You have a few options:
If your needs are very basic, you may be happy with AWT that is the original Java UI toolkit. It uses native widgets, but has very limited library of widgets that it supports.
If you want to go beyond AWT, consider SWT, which is maintained at eclipse.org. It gives you a rich library of widgets, that are implemented natively.
Because Swing use AWT on Systray, if you want great looking on systray. Maybe you can try with SWT :)
I wrote my own library for it. Here is the link:
http://www.2shared.com/file/sQdjb6aG/jtray.html
Usage:
import javax.swing.jtray.*;
JTrayIcon.initSystemTray();
JTrayIcon icon = new JTrayIcon(img, "Tooltip", jpopupmenu);
icon.displayMessage(null, "Title", "Multiline\nsecondline", 3000); // 3 seconds
The library uses a few dirty tricks, so maybe it may not work on any Linux platform as good as in Ubuntu. It should work for Windows and OSX as well.
I haven't tried it myself, but if you're using Java 6 Update 10 or later, can you use the new Nimbus look and feel?:
Using Nimbus LAF
I've heard of tray icons using "JPopupMenu" on Ubuntu, which uses the Nimbus look and feel, so this may be your best bet:
Using JPopupMenu in TrayIcon
From what I've seen, using JPopupMenu alone would be a big improvement - coupled with Nimbus it should be awesome.
A quick & dirty workaround:
Create an undecorated JDialog, add a JPopupMenu for it and make it visible from your mouse listener of your TrayIcon as you want.

Categories