2

How can I attach a JFrame in the top right to another applications open window and stay with it while resizing? Is it possible?

Here is a diagram of what i would like to accomplish:

enter image description here

Thanks for the help! If this is not possible, are there alternatives?

Ways to get window size/location and set my own jframe accordingly?

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
ThatGuy343
  • 2,354
  • 3
  • 30
  • 55

1 Answers1

4

You are asking Java to modify an already running non-Java program, and for these types of problems, Java is not the best tool. Please understand that one of Java's main strengths is its ability to run compiled code unchanged on multiple platforms. With this strength comes a weakness: of necessity, Java must be as OS agnostic as possible, and because of this, it is not a good tool when code needs to get cozy with the OS.

Alternatives: just about any other language that can allow easy OS calls.

Don't get me wrong, you can do some similar stuff with Java, but it requires that you jump through hoops that just aren't needed when using other tools.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • My only alternative language is C# and even then just for Unity game development. Java is my main language. I don't mind jumping through hoops! Can you point me in a direction? – ThatGuy343 Jun 30 '14 at 02:11
  • @ThatGuy343: given my druthers, I'd much rather do this sort of thing with C# than with Java. With Java you will need to look up JNI or (my preference) JNA. One other difficulty with using Swing is that it uses light-weight components, and these might not interact well with the heavy weight components of your running non-Java application. – Hovercraft Full Of Eels Jun 30 '14 at 02:12
  • @HovercraftFullOfEels The application so far that i've written deals with processes and sql database pooling. I'm not really comfortable doing that in C#. – ThatGuy343 Jun 30 '14 at 02:17
  • If there are no other solutions then i'm going to mark this as the answer, seems it isn't really feasible to do in Java. – ThatGuy343 Jun 30 '14 at 02:21
  • @ThatGuy343: oh things like it can be done, but again, it would require JNI or (again my preference) JNA, or some other tool that allows Java to get close to the OS. – Hovercraft Full Of Eels Jun 30 '14 at 02:21
  • @ThatGuy343: also note that I can't speak for SWT, just Swing, since I don't use this library, but Elliott knows quite a bit about it. – Hovercraft Full Of Eels Jun 30 '14 at 02:25