windows explorer context menu in java - java

Consider simple application, that display list of file. I would like to display context menu , when user click of file or folder, the same as, when user right mouse click in windows explorer (open, rename, edit etc.). I don't want to create my own context menu, I want to show windows os context menu, using some kind of winapi probably. This should works only on windows machine.
Is it possible to achieve it with Swing or SWT or any other UI controls ?

This MSDN article explains how it is done:
Windows Explorer calls a folder object's IShellFolder::GetUIObjectOf to request an interface for one of the objects.... When a user right-clicks an object, Windows Explorer requests an IContextMenu interface.
There is a full source code example in C here.

Related

How can you start an application when the user presses a keystroke in Java?

I have an Swing application in Java that I want to open when the user types as specific keystroke, such as Alt + F2. It would be better if there isn't an application running in the background tracking all the key events and then showing the window.
There are many ways of doing this but the simplest way is to create a shortcut of that application either on Desktop or in a start menu, right click on the icon and select properties and go to shortcuts and click on the shortcut key textbox. Now select keys from your keyboard and save it.enter image description here
I don't think you would be able to do so without a JAVA application already running.
If you wish to use short cuts you will have to use OS related shortcuts
Check out this Stack Exchange link to create a shortcut on Windows OS

Applet being blocked by Java settings

Here is an "Hello World" applet is given on Oracle's it works online. Oracle has also provided these tutorial as offline version. In download files of same website applets are not working rather these are being blocked by Java setting. There was also message that I can change security settings from Java Control Panel. I changed settings from high to medium but applet is sill being blocked by Java.
Click on the Start button and then click on the Control Panel option.
In the Control Panel Search enter Java Control Panel.
Click on the Java icon to open the Java Control Panel.
In the Java Control Panel, under the General tab, click Settings under the Temporary Internet Files section. The Temporary Files Settings dialog box appears.
Click Delete Files on the Temporary Files Settings dialog. The Delete Files and Applications dialog box appears.
Click OK on the Delete Files and Applications dialog. This deletes all the Downloaded Applications and Applets from the cache.
Click OK on the Temporary Files Settings dialog. If you want to delete a specific application and applet from the cache, click on View Application and View Applet options respectively.
Now try to run your applet again and it should work.

Java OS X Dock Menu

Is it possible to add items to the applications dock menu?
EDIT: I think i miss phrased the question, i am not looking for a way to add an icon to the dock. what i am looking for is, when you right click on the itunes icon you get itunes control on the menu (play pause etc) i was wondering how can i add custom items to that menu.
Look into the com.apple.eawt package. Specifically, when you initialize your app, do something like the following:
if (System.getProperty("os.name").startsWith("Mac OS X")) {
// only do this setup if we know this is a Mac
com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication();
java.awt.PopupMenu menu = new java.awt.PopupMenu();
// create your java.awt.MenuItem objects here
// add to menu via java.awt.Menu#add(java.awt.MenuItem)
macApp.setDockMenu(menu);
}
If you are distributing this as a cross-platform application, Apple provides an Apple Java Extensions jar with stubs for the com.apple.eawt package, so the code will compile with non-Apple JDKs.
Yes (providing I understand the question).
If your just trying to customize the Java Icon in the Dock see ...
http://developer.apple.com/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html#//apple_ref/doc/uid/TP40001885-208447-TPXREF120
Point two under OSX Application Bundles section
"If you add an appropriate icon, it shows the application icon in the Dock, clearly identifying your application. (Otherwise, a default Java coffee cup icon appears in the Dock.)"
There is an example app (Java) for handling drag and drop events for your dock icon as well located here :
http://www.devdaily.com/blog/post/jfc-swing/java-handle-drag-drop-events-mac-osx-dock-application-icon
If you want you application to automatically add it's icon during installation to the dock (possibly what you mean) you should know that there is no "official apple" way to do this as it's BAD design on OS X to force your icons into a users dock, and typically frowned upon. All MAC users i know will instantly remove your application as a result of such behavior.
That said however, you can review the system administration guides on Apple's site to see how it can be done programatically.

How to drag from browser area and deposit to the explorer area?

Sometime ago I was facing the problem the other way around: how to drag an item (folder/file) from an explorer window (be it windows explorer, linux nautilus etc.) to the browser window - that is, the drag starts in one application and ends in the browser. Since I had control over the browser, I was able to intercept the dragend event: the one which interested me.
Now, I want to do this from the browser to the file explorer application: much like when you drag an image from firefox and drop it in a folder.
My main problem is that while I can check when the drag event exited the browser window, I have no ideea how to get the location where the drag event finished.
My ideea is to create a signed java applet and somehow track the mouse movement on the desktop - but this seems a little more than overkill.
Any pointers on this?
According to your justification is is not simple, but it can be managed. There is class called DataFlavor. You had to use D&D mechanism introduce in java using Transferable objects and provide correct mime-types and corresponding conversion. The problem is which mime-type will be accepted by explorer. I hope this help.
You won't be able to do this with JavaScript. JS is sandboxed in the browser and can't interact with anything outside.

Universal keybindings in Eclipse

I want to be able to use CTRL-SHIFT-T to open a Java Type (source code file) from any perspective in Eclipse. Unfortunately, the keybinding only works in the Java perspective.
I tried defining the keybindings using context "In Windows" and "In Dialogs and Windows." That did not do the trick.
Any ideas how to do this?
(For documentation, note e.g. this page.)
Image Hosted by ImageShack.us http://img18.imageshack.us/img18/7205/keybindingsna4.pngShot at 2009-02-18
In Eclipse go to:
Window -> Customize Perspective...
Click on "Commands" tab
Select the check box for "Java Navigation"
Click "ok"
Now you can use Ctrl + Shift + T in this perspective.
Unfortunately you have to do this in all perspectives you normally use to get this functionality across all of them.
You need to activate the command 'Java Navigate' in the perspective from which you want to access the "Open Type" dialog.
You will access this dialog through a right click "Customize Perspective" near the toolbbar buttons.
As mentioned in lud0h's answer, "you have to do this in all perspectives you normally use to get this functionality across all of them"
Until... eclipse3.5M4 late this January 200099
Java Action sets in all perspectives:
If you are editing a Java file, you can access your favourite actions (Open Type etc) in a non-java perspective as well (CVS, Resource)

Categories