• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JNI - Obtaining window handles from AWT

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
reply
    Bookmark Topic Watch Topic
  • New Topic