aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Is there a way to find out color of whatever's behind my frame? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Is there a way to find out color of whatever Watch "Is there a way to find out color of whatever New topic
Author

Is there a way to find out color of whatever's behind my frame?

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
Is there a way in java to find out what pixel is behind a specific pot on my frame (or JFrame)? Whether that's the desktop, an icon or another frame/window? If not, is there a way to do this on Linux/Windows in c/c++?
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Look at SwingUtilities methods:
public static void convertPointToScreen(Point p,
Component c)
Convert a point from a component's coordinate system to screen coordinates.
Parameters:
p - a Point object (converted to the new coordinate system)
c - a Component object
public static Component getDeepestComponentAt(Component parent,
int x,
int y)
Returns the deepest visible descendent Component of parent that contains the location x, y. If parent does not contain the specified location, then null is returned. If parent is not a container, or none of parent's visible descendents contain the specified location, parent is returned.
Parameters:
parent - the root component to begin the search
x - the x target location
y - the y target location

though this would not locate a OS widget behind a Java frame.
[ January 29, 2004: Message edited by: Jose Botella ]

SCJP2. Please Indent your code using UBB Code
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

If what you are trying to do is make an odd-shaped (i.e. non-rectangular) frame, there is no way to do that using just Java. You *can* use a package called SkinLF that supports non-rectangular frame (and many, many other goodies), but the non-rectangular stuff only works on Windows.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
 
subject: Is there a way to find out color of whatever's behind my frame?
 
Similar Threads
JDialog &Modal.
Dialog
Modeless dialog issue
Parent Frames and Panel
File extensions