This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNI - Obtaining window handles from AWT

 
Frank Hale
Ranch Hand
Posts: 230
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way for a programmer to obtain a window handle from a window created by the AWT. I would like to pass this handle back through a native method and manipulate it with native code.
The platform I am using is Linux/X11.
Frank
 
Pawel Veselov
Ranch Hand
Posts: 165
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, this can be done with SUN JDK on Solaris/Win32. They have special class called EmbeddedFrame, but this one is in sun.awt.* package, so undocumented and unusable if you are going to use it on any other JDK.
So, the first question is - what JDK are you using ?
 
Frank Hale
Ranch Hand
Posts: 230
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have IBM JDK 1.3, Suns JDK 1.2.2 both for Linux. Incase one is wondering why I would want to obtain a handle to the windows created by the AWT. Well I want to program a window manager for X Windows using Java. I also wanna create a library of native functions that are callable from a Java program which interface to X11 functions and structures.
I am still not sure if its possible to do this but I have been thinking of it lately and how I could implement it. But there are alot of things still to work out.
Frank
 
Pawel Veselov
Ranch Hand
Posts: 165
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, JDK (at least one from SUN) will allow you to create an embedded frame, that you can pass your window handle to. So, you should create an actual window, and then JDK will use that window for creating an embedded frame inside it.
This is done with WEmbeddedFrame, that is derivative of an EmbeddedFrame class. I don't know exact details, though, since this classes are sun.awt, and actually sun.awt.<platform>
 
Frank Hale
Ranch Hand
Posts: 230
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pawel,
There might be an easier method. There is a library called GL4Java which to the best of my knowledge is an implementation of OpenGL in Java which uses a native layer to access the underlying platform dependent OpenGL libs. In this code they get the window handle and there code is open sourced. I think they've pretty much covered what I need so I will just look at there code to see how they did it.
Frank

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic