Two icons on taskbar when running java application - java

Hey so I have a Java application where I use a JFrame as the main window. My problem is when I pin the executable to the taskbar and then run the executable a second icon is placed on the taskbar instead of a "glow" being placed on top of the icon that is already pinned. In other words, two icons on the taskbar when I pin and run the executable. Is there any coding solution to this problem?
Please even let me know if you think there is no way or if you have come across this before.

There could be multiple reasons for this:
Do you have more than one JFrame getting a task-bar icon? Referencing this question: how to restrict more than one java application icon on taskbar?
It could be that the pinned version is not the same as the one that actually runs, i.e. trying pinning the second icon that appears, then using that icon in the future.
You might need a setting in your configuration if you have any, Eclipse (the IDE) seems to suffer from this problem and requires the JVM tp be specified in it's ini file, referencing: How to make Eclipse behave well in the Windows 7 taskbar?
Last Resort. The IsHostApp setting in the registry can change the way java behaves on the task bar, you would still have two icons, they would just stack:
https://superuser.com/questions/465002/how-do-i-combine-multiple-java-buttons-into-a-pile-on-the-taskbar/465248#465248

Related

How can I force the size of a Java (.jar) application window?

I have an old .jar file that creates a main window with some textboxes for settings.
The problem is that some textboxes doesn't appear in the window (but they exist), if you lower the computer screen resolution they appear, but with higher resolutions, they disappear.
I tried to decompile the .jar file, but no success...
Since I cannot resize the window in any way (size seems to be fixed), is there a way to force it to be resized or set some Java VM parameters for this purpose?
The loader is "JarRsrcLoader". I attach an image showing the problem in Win10:
(They are not only cut, there are more textboxes).
I asked Mr Google for a Windows tool to make unresizable windows resizeable. Got several matches, here is a short list:
http://www.howtogeek.com/howto/11799/turn-non-resizeable-windows-into-rezieable-windows/
https://www.raymond.cc/blog/how-to-resize-an-unresizable-window-or-dialog-box/
http://www.ghacks.net/2012/06/18/resize-windows-with-fixed-sizes/
I actually found a way to scale the Java application to a lower resolution and see it adequately, only for Linux (but it was what I was searching).
From this source (askubuntu.com): script to fix scaling of java applications.
It provides python scripts to adjust the resolution of certain applications (statically and dynamically) when opened (on a high dpi screen). This solution works for my problem.

How can I display multiple dock items for jFrames within one Java application?

I have a modular Java application: a single jar launches a 'control panel', from which the user can open several modules. Each module uses its own jFrame. (A discussion of whether this is a good or bad practice can be found here - in my case the modules all talk to one another but perform different functions).
Running on Windows, each module (jFrame) gets its own icon on the taskbar, and is selectable via ALT-tab. On OS X I only get one dock icon and one icon in the Application Switcher (CMD-tab). This makes it quite awkward to switch between modules, several of which will be open at any one time.
How can I put each module (jFrame) in the OS X dock and Application Switcher separately?
Iterestingly, if I iconise one of the jFrames, it does appear in the dock, in the right-hand area by the Trash.
I am testing this using Java 7 on OS X 10.10 (Yosemite). I have made a cheat's .app which launches the jar via a shell script, in order to provide cmd-line arguments (Xdock:name etc) and icons - so I do have an info.plist file.
You can't. The OS X user interface just doesn't work that way.
Iterestingly, if I iconise one of the jFrames, it does appear in the
dock, in the right-hand area by the Trash.
This is user-configurable. See Preferences > Dock > Minimize windows into application dock.
Rather than fight against the normal OS behavior, come up with your own "module switcher" feature, perhaps making it part of your control panel. You will find that application switching and dock icon behavior differs a lot across operating systems. Trying to make OS X behave like Windows, or vice-versa, outside the bounds of your application will be a big headache.
That said, if you don't want to heed the above advice, the only way I can think of to do what you want is to create dummy applications, that don't display any windows, but that do show up in the dock. The dummy applications can be started by your main application. When a dummy application is clicked, it can then signal your main application (perhaps listening on a local open port) to make one of the modules active. This would give the illusion that each module had its own place in the dock. This would probably work with the Alt-Tab switcher as well.

Blank but still somewhat working user interface

I've written a Java database program using Swing, and it looks and works fine on my Windows machine. I was expecting to be able to transfer it to my Linux (CentOS 6) machine with no problems, and while it compiles and runs just fine, the GUI is blank.
Specifically, a JDialog that I show appears as a solid grey rectangle, but I can still see my cursor change to an I bar when I hover over the text boxes, and I can type into them and press the invisible Ok button, and it works. (This is a database login dialog.)
Then, a JFrame that I've setup as an MDI parent is displayed, but it has zero size. If I drag it open it does have a border, but it does not visibly have the menu that I placed on it. I don't seem to be able to access the menu invisibly as I was able to on the JDialog.
I suspect that this must have something to do with some Java or library version, but I'm not sure. I tried installing Java 7 but it didn't change anything. I'm not sure if I should uninstall Java completely and try reinstalling it, or if maybe it has something to do with the project instead (I am using Eclipse Kepler if that helps.)
I see a few other "Java program is blank" questions, but they either do not have answers or are not the same issue I am having. (My program is only blank under CentOS so far; it works and looks just fine under Windows.)
I narrowed it down to a single line. In the JDialog I had the following:
setType(Type.POPUP);
as soon as I removed this line, the dialog became visible.
Additionally, I find that if I use the Test/Preview... feature (this is using the WindowBuilder) when that line is present, it shows the dialog blank, but it is non-interactive and effectively hangs Eclipse. This led me to "end-task" java.exe, which did unfreeze Eclipse, but it ended up causing even more problems, including the ones I was having with my MDI JFrame.
After rebooting, and removing the above POPUP line, everything is working great.

Set an icon similar to mac when minimized it to dock

Set an icon for a JFrame when it is minimized to the dock like other mac application.
Please help..
An e.g. of what Mikle was referring to:
Now moved to: Sizes of frame icons used in Swing.
Use the jar bundler that is available with Mac os to create an App. Set the icon of the app using jar bundler and dont set any icons for your jframe.
Window class has method setIconImages which requires java.util.List<? extends Image> as an argument. You will have to pass a list of images with different sizes so that OS can choose one from that list for each specific situation - would it be minimized icon, icon for dock/toolbar, icon for window or icon for any other system-specific UI element.
I usually pass a lot of images for my own application in different sizes:
16x16, 24x24, 32x32, 48x48, 64x64, 128x128, 256x256, 512x512
The large ones are usually used by large toolbars or by folder view to display icons for files associated with your application. Also usually 16x16 icon is used as window (frame/dialog) icon. Other icons can be used in a lot of different situations which depends on what OS you have (Windows, Mac OS e.t.c).
You're really talking about two things.
The icon of the application in the dock, in Finder, etc.
appbundler or even simply hand-creating the bundle is the solution to that, as already
mentioned.
The icon of the application when minimised to the dock
When you minimise the application it becomes a separate dock entry which does not
necessarily look like the application one.
The Window has setIconImages - if you set this method, the application will become
that icon when minimised which will not look native. So you should check if you're
running on OSX before calling that method and avoid calling it.
By leaving out the call, you get the default behaviour where the minimised icon will
be a miniature copy of what the window itself looks like, which is what we see
other applications doing. It would be nice if the JRE would take care of that for us
and just ignore the icons when running on Mac OS X.

How to have non-grouping JFrames within the same application?

I'm creating a new JFrame from within an already running JFrame. Both frames are separate applications, but in this case, the second application gets a "plugin handle" of the first application instead of using its default stuff. For some operations in the second app, a callback is made to the first app to know what to do/display.
This way, the second application can be reused by many other applications. It is and will NOT be possible to manually start some java.exe command to achieve a real separate process.
Now, to emphasize that the second JFrame is another application, I want the taskbar entry to not be grouped together with the entry that was already there for the first JFrame. So basically this is a Windows 7 issue in combination with Java.
The icons on the taskbar are grouped together by default, there is enough space for them to be displayed separately but they simply don't.
How can I display the JFrame's icons separately on the taskbar? I can't find anything on JFrame that does what I want.

Categories