0

I need to create two JFrame, f1 and f2, so that:

  • f2 would be always exactly under f1, even if f2 gains the focus.
  • f1 is not necessarily and always on top (e.g. a popup can appear on top).
  • no other window (from the same java application or from any other application of the OS) could be inserted between f1 and f2.

Note: I can't use CardLayout or InternalFrames or other light-weight components.I really need two JFrames (or Window). The reason is that I have to reparent a X-Window on a Java application and for several reasons I need that this X-Wwindow would be reparent on the f2 frame and that part of the f1 window be transparent so that the user can see the X-Window behind.

paranoia25
  • 626
  • 1
  • 5
  • 23
  • Use two [`JInternalFrame`](http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JInternalFrame.html)s inside an unresizable `JDesktopPane` maybe? – moonwave99 Nov 29 '12 at 17:02
  • See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson Nov 29 '12 at 22:20
  • I can't. I have edited my post to explain why. – paranoia25 Nov 30 '12 at 09:49
  • @paranoia25 I found your mention of X-Window pretty confusing, after google led me to your *other* question about reparenting I *finally* got an idea what you want. But I think your question *here* about two *JFrames* will not get you any closer to solving the problem. Especially when you ask the question(s) without giving proper context. – Durandal Nov 30 '12 at 16:49
  • Yes but as you said, when I mention the X-Window it becomes pretty confused. And I can't explain all my problem!! I will try to edit my post to have clearer question. – paranoia25 Dec 04 '12 at 13:08

3 Answers3

3

Instead of using multiple frames, I would suggest having multiple panels and managing them using Card Layout

Sujay
  • 6,753
  • 2
  • 30
  • 49
  • I can't. In fact I have to reparent a Xwindow on a Java application. For several reasons I need that this Xwindow would be reparent on a the f2 frame and that part of the f1 windouw be transparent to see the XWindow behind. – paranoia25 Nov 30 '12 at 09:40
2

Forget using two Frames for this. Use a single Frame and put a JSplitPane (or a simple JPanel) inside to divide it into two sections.

Using UI components to do things they are not meant to do gives a crappy user experience and is impractical to implement reliably.

Durandal
  • 19,919
  • 4
  • 36
  • 70
  • I can't. In fact I have to reparent a Xwindow on a Java application. For several reasons I need that this Xwindow would be reparent on a the f2 frame and that part of the f1 windouw be transparent to see the XWindow behind. – paranoia25 Nov 30 '12 at 09:40
0

Can you give us more detail on what you are trying to do? I dont understand why F2 is being constructed if F1 will always have priotity on screen. The JVM will have no control of ensure that no other frames get between these frames, without writing alot of code.

user1863504
  • 63
  • 2
  • 8
  • I have edited my post to explain with more details why I want to have these two frames with one always above of another. – paranoia25 Nov 30 '12 at 11:36