How can one change the icon image of a pre-existing shortcut through java? I do not want to change the icon image of a java executable, but have a java program that changes a shortcut's icon image.
I know I can manually change the icon image by right clicking on a shortcut and going to properties->shortcut->change icon, but I would like to do this through java.
Its impractical do this in pure java yourself, although the lnk-file format is documented by microsoft (http://msdn.microsoft.com/en-us/library/dd871305.aspx), but since it originated with Win95 it underwent significant extensions and redefinitions over the years. Implementing this seems like a daunting task.
You can try to find a library that implements it for you, e.g. http://ovanttasks.sourceforge.net/ov-native/ may do what you want.
The alternative would be to use existing Windows API's to do the job (See How do you create (and read) windows shortcut(.lnk file) in Java?).
Related
In my swing application, I have set the UI Look and Feel as:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
And it works well on Windows. Inside, the application, the user has to select files using the JFileChooser. The JFileChooser appearance on windows is again the native one. But not on Mac.
The screenshot of the JFileChooser Panel:
But instead, I prefer something like this: (This one is taken from upload option in gmail)
What should I change the UIManager to or anything else??
Several alternatives include these:
java.awt.FileDialog, illustrated here.
A custom ChooserUI, shown here.
A completely custom implementation; several variations are shown here.
On MacOS, you can use the FileDialog which looks like what you are describing. The drawback is that it is a lot less configurable.
I have experienced a lot of troubles when migrating from Java 6 to Java 8 since with my Java application I have to open some proprietary file bundles.
FileDialog still gives the better LookAndFeel, but treats the bundled files as if it were directories. A first fix to this is to set FileDialog to select directories, which still allows to navigate inside the file-bundle, but as well allows to select the bundle as a whole.
System.setProperty("apple.awt.fileDialogForDirectories", "true");
Not quite happy by the solution I tried other options, including the VAqua LookAndFeel for macOS which looked really great but sometimes didn't display me all the UI Elements (some JTree were hidden at startup, and JFileChooser did look great, but still didn't show me the Network drives in the sidebar).
Finally I found a simple property that - when set - allows to use FileDialog as it was under Java 6. Of course, if we want to select files and not directories, the line above must be deleted.
System.setProperty("apple.awt.use-file-dialog-packages", "true");
Found this one in an old example project about Dialog personalization
The file chooser implementation for Windows, Linux and Mac is not 100% right for any OS
Unfortunately if you really want this you need to look for a replacement for JFileChooser or you need to write your own look and fee.
Java has trouble keeping up with the OS changes.
My goal is to make a simple GUI which almost look like this attached screenshot.
But while using Awt, Swing i have never found yet such combo/buttons nor i have found something like transparent window which showing my desktop background.
I am very desperate to make something similar, but i am not sure which framework i can use?
Can i do this above UI, with GWT? or is there something else?
Java has always supported translucent windows on Mac (from at least OS X 10.4 but probably way before that too).
However on Windows you need at least Java 1.6.0_10 to be able to do translucent windows directly from Java.
If for whatever reason you're stuck with an older Java you can use JNA. They've got examples as to how to create translucent windows on OS X, Windows and Linux and these examples work even on older JVMs.
As I type this JNA is located here:
https://github.com/twall/jna
Here's the code for their alpha/translucent example (where you can drag a picture with an alpha channel, like a PNG with an alpha channel and then choose the opacity):
https://github.com/twall/jna/tree/master/contrib/alphamaskdemo/com/sun/jna/contrib/demo
Now what you want to do can be done but there are gotchas: you need to be careful about several things. For example mouse events: if you want catch them or not when they happen on an area that is "fully transparent" (if you want to catch them, you can cheat and make your translucent window nearly --but not fully-- transparent).
What you want to do is a bit like a HUD: there are definitely HUDs done in Java but as far as I know they weren't build using GUI builder tools. You'll probably have to code it manually (or at least some part of it manually).
See this: How to Create Translucent and Shaped Windows
First of all, I'm a java developer and I am currently working on a small application for Windows only.
In my application, I wish to do as dropbox or tortoise do : add an overlay icon in windows explorer to show the user some state of files managed by my application. (I want the icon of the file change depending on some data stored in the file)
Is it possible to do so in Java ? Do you have examples ?
If it is doable but not efficient, how would you do instead ?
Thanks in advance
Fluminis
It would be possible to do this via JNI - you would need to hook into the Windows registry and from there into the Explorer shell, probably into the various file classes held there.
However, unless you have at least some familiarity with C++ and the windows API, you are unlikely to be able to achieve this.
Java is not the ideal language for what you want to do.
I want to automate an external application, but I have several problems:
How can I recognize a button or other field of an external application in Java?
I use the Robot class in Java for making notepad automation where I open notepad, select file menu, and save or exit, etc.
The problem is, it needs X,Y coordinates for the mouse pointer to go to the proper location.
I want to make it more dynamic, i.e. it should recognize the file menu of a running notepad anywhere on the desktop.
How can this be done in Java? Is there any class in Java I can use to do this?
Thanks everyone to give me response, I want to be more specific i want to know how can i make ui automation by using any tool if it is not possible in java or using any api of java.automation tool must be freeware.....i am searching net for that i found AutoIt is like that.But if any one do this type of things please share his/her experiance means is it possible to do that in AutoIt or not possible if not then which tool do that kind of things.
It is easy to integrate Sikuli into a Java-application since it is written in Java. Sikuli uses image recognition to find elements visible on the screen like buttons and such. It is very easy to use and provides an alternative for tasks that are difficult to handle with static positioning, like finding moving windows and such.
Take a look at this: http://sikuli.org/docx/faq/030-java-dev.html
Hope this helps!
You should have a look at Sikuli. It takes as inputs images of the ui elements to select an area in the targeted app. It's a UI Automation Application
That's a bit difficult to install (at least on Debian/Ubuntu, where I tested it), as you'll need a recent version of OpenCV, a particular version of JXGrabKey but the quality of the program worth the trip. Good Luck
Java doesn't have an API to examine the UI of another application; that would be a very big security risk.
Which is why the Robot class can only record events (key presses, mouse movements and clicks) but not which UI element was involved in most cases.
It would be possible to do more if the external application was written in Java because then, you could analyze the objects in memory but for obvious reasons, this isn't possible for C++ or .NET applications.
If you know babylon translation tool you'd know its word capture feature - when you right click on a word - it tanslates it (from a browser or any documtent).
I want to get the same tool - what program language should i use ?
The os i want to get it work on is win-xp and ubuntu. and I'm writing my program in java.
if it could happen from a java program it would be great.
thanks,
Adi.
You are facing two (IMHO) insurmountable challenges:
Windows and Linux use completely different mechanisms for displaying text on screen. Translating mouse positions into actual text is pretty darned difficult. This is hard even if you're targeting a single operating system.
Java apps generally run in a sandbox, i.e., they can't just go mucking around in the OS asking other windows to tell them what text is under the mouse, nor can they override the default right-click action windows they don't control.
A better UI approach would be something that uses the system clipboard, which I think is available to Java on all systems (I'm not a Java guy, I'm not sure). So, the user would copy a word in any window, perhaps hit some sort of global shortcut key (again, assuming you can assign one in a Java app), and the Java app could access the word in the clipboard and do what it needs to do.