Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic