Results 1 to 17 of 17
- 06-25-2010, 03:27 PM #1
Member
- Join Date
- May 2008
- Posts
- 8
- Rep Power
- 0
How to find the active Window in Swing?
Hi all!
I have an RCP plugin (which will be plugged into any RCP app)
and the aim is to get the screenshot of the RCP app. So actually now what i make is, the plugin adds a new menu item to application and whenever the menu item is clicked the pluginForm opens (a form to take and manipulate the screenshots)
But what i want is just to take the capture of the RCP app. So the plugin needs to see the current active Swing windows and get the screen size of that to take just that part of screen.
How can i handle this?
(btw i tried Frame.getOwnerlessWindows(), Frame.getWindows(), Frame.getFrames() methods. they dont give me the 'just rcp app window'. maybe the current running thread is just the plugin form. and it goes invisible during capture, but still there is the rcp app window running in JVM which i want to reach)
Regards,
- 06-25-2010, 03:39 PM #2
Extend the class for the window(s) and have it/them keep track of its state. Have a list of these windows that you can scan.
- 06-25-2010, 03:45 PM #3
Member
- Join Date
- May 2008
- Posts
- 8
- Rep Power
- 0
Window is java.awt.Window class. how can i extend this and what for?
if i could reach the states of the windows (especially the window of the rcp form) i could also reach the bounds and i wouldnt have problem.
- 06-25-2010, 04:18 PM #4
I'm sorry, I thought this was a java programming problem.
By "active window" are you asking at the Java program level or at the OS level.
If the OS level, you need native code.
What is the relationship between the windows you're talking about?
- 06-25-2010, 04:23 PM #5
Member
- Join Date
- May 2008
- Posts
- 8
- Rep Power
- 0
i thought the problem was pretty clear :) RCP app window.
is of course java prog.
- 06-25-2010, 04:25 PM #6
Member
- Join Date
- May 2008
- Posts
- 8
- Rep Power
- 0
The thing is this.
I normally had 2 forms which one of those is the parent of other.
In this RCP plugin stuation, since the plugin must work on all RCP apps, you dont have a parent form. The plugin loads itself. So how to get the parent form (RCP app form which is currently running together with the plugin in JVM)
- 06-25-2010, 04:34 PM #7
What does this have to do with Swing apps?
Sounds more like an IDE thing. How is a plugin loaded? What Java SE class does it?
- 06-25-2010, 04:36 PM #8
Member
- Join Date
- May 2008
- Posts
- 8
- Rep Power
- 0
dude ok. if you dont know let somebody answer. of course this is the awt swing forum and i want to get the awt window of the current processes from jvm.
- 06-25-2010, 06:26 PM #9
Member
- Join Date
- Jun 2010
- Posts
- 5
- Rep Power
- 0
Hi.
Please could you try the following code:
Java Code:KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Window window =keyboardFocusManager.getActiveWindow();
- 06-25-2010, 09:08 PM #10
Cross posted
Java Programming - find the active Window in Swing?
db
- 06-26-2010, 12:09 AM #11
Member
- Join Date
- May 2008
- Posts
- 8
- Rep Power
- 0
Hi jackGav, thanx but it did not work. :confused:
- 06-26-2010, 12:16 AM #12
Member
- Join Date
- Jun 2010
- Posts
- 5
- Rep Power
- 0
Which value has the window ? null?? and
in what part of your code are you putting the above extract?
- 06-26-2010, 12:19 AM #13
Member
- Join Date
- May 2008
- Posts
- 8
- Rep Power
- 0
i got a window type of jdialog.
as i told i have an rcp app.. and plugin also has a form..
so when i want to take the capture, i make the plugin form invisible.. then just the main app is visible, and i put this code.. but it didnot work
- 06-26-2010, 03:21 PM #14
Member
- Join Date
- Jun 2010
- Posts
- 26
- Rep Power
- 0
this requires OS code.
orJava Code:JNIEXPORT jlong yourclass_blabla_getActiveWindow() { return (jlong) GetForegroundWindow(); }
Java Code:JNIEXPORT jlong yourclass_blabla_getActiveWindow() { return static_cast<jlong>(GetForegroundWindow()); }Last edited by JvlShz; 06-26-2010 at 03:28 PM.
- 06-26-2010, 04:05 PM #15
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
- 06-26-2010, 05:09 PM #16
Member
- Join Date
- Jun 2010
- Posts
- 26
- Rep Power
- 0
- 06-26-2010, 05:33 PM #17
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
It is totally incorrect in that nature because there is no way in Java to convert the long to a reference to a Window class at all. Maybe your code snippet was technically correct but it didn't make it for an answer. You are not helping the forum, nor the OP this way.
kind regards,
Jos
Similar Threads
-
How do i open JFrame in the same active window
By Jkiller295 in forum AWT / SwingReplies: 35Last Post: 06-02-2010, 04:50 PM -
how to make window active and textfield focused
By whwillisiv in forum New To JavaReplies: 0Last Post: 04-28-2009, 04:06 AM -
To get the current active window`s path using Windows API
By jihadrh in forum Advanced JavaReplies: 8Last Post: 12-01-2008, 02:07 PM -
Close Active Window (?)
By dcnorman07 in forum New To JavaReplies: 2Last Post: 10-03-2008, 05:55 PM -
Changing Active Window
By jmHoekst in forum New To JavaReplies: 1Last Post: 06-14-2008, 12:21 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks