0

I would like to create a frame with only a visible border which is resizable by the user. This application should be able to work as an applet. It should draw a rectangle on the screen which is resizable by the user, upon which it calculates the coordinates of the rectangle on the screen.

https://i.stack.imgur.com/IpAnS.jpg

enter image description here

The frame should be similar to what you see in http://www.screenr.com/record.

The first problem I am facing is in making the frame invisible with only the borders being visible.

The second problem is that I need to be able to access my desktop contents through the frame (as shown in the diagram), but with standard frames you cannot access anything behind the frame.

Mat
  • 202,337
  • 40
  • 393
  • 406
  • This is not possible in swing, because it only allows opaque windows. Maybe you can try a set of JWindows? – marc Jul 17 '11 at 15:02
  • I did use JWindows.. And I've got the entire look and feel done... However, one problem still remains that I cant access my desktop through that frame.. I need a way to make that happen. – Jeremy Craig Jul 22 '11 at 06:23
  • Maybe look at `java.awt.Robot`? It can capture the screen. – marc Jul 22 '11 at 08:39
  • Ok yes I did that... I captured the screen, extracted the required coordinates and displayed it correctly on the JWindow... However, there can still be no mouse or keyboard actions on that, like if it were the desktop itself. – Jeremy Craig Jul 24 '11 at 03:39
  • 1
    That is why I suggested a *set* of JWindows. One for the top border, one for the left, right and bottom. Maybe some controsl within the bottom one, maybe the ability to drag/drop when clicking on them. – marc Jul 24 '11 at 11:59
  • Well yeah that totally makes sense.. Why did I not think of that! Thanks a ton :) – Jeremy Craig Jul 24 '11 at 21:53

1 Answers1

1

You might use a variant of the code shown on How to get the x and y of a program window in Java?. It obatins a single point, so you'd need to alter it to gain two points (to construct a Rectangle).

This application should be able to work as an applet.

The applet will need to be digitally signed (by you) and trusted (by the user, when prompted) in order to gain screenshots.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • That example really doesn't help me much. Or maybe I cant understand how to use it. For the following reasons: 1 - The example creates a GUI with a title bar and borders. I need a GUI which is only a rectangle and has no visible frame. 2 - The program takes a screenshot of the desktop and asks user to interact with that. I want my program to work on the desktop itself. Not with a screenshot. You could see http://www.screenr.com/record. The visible rectangle that pops up is something very similar to what I want. Im sorry if I'm being ambiguous, I cant find the correct words to explain. – Jeremy Craig Jul 18 '11 at 18:22
  • Is there no answer to my question? I used your code, but I cant seem to make the applet title window go away.. Furthermore I cant seem to understand how to access my desktop through it.. – Jeremy Craig Jul 21 '11 at 02:05