Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

[Swing] Controlling depth of multiple JWindows.

Thread view: 
Andrew Jackman - 29 Dec 2003 07:17 GMT
Hi there,

I am developing an application that has three JWindows that must
always be displayed on the screen.  One displays radar data and is
permanently fixed in the background and covers the entire screen,
while the other two are task bar type windows located across the top
and bottom of the screen.  The two task bar windows must always be
displayed on top of the main radar window.  Other JFrames and JDialogs
may also be displayed over the top of the main radar window.

Currently, when I click on the main radar window, the window is raised
on top of all other windows, including the task bar windows.  How can
I prevent this behaviour?  I would like the main radar window to
ALWAYS stay at the back.  I have investigated listening to the focus
of the radar window and sending it to the back when focused, but this
seems cumbersome.  I'm sure there must be a simpler/more elegant
solution.

I do not wish to use the JDesktopPane (MDI) because I need my
application to be full screen without title bars, and need to be able
to move windows between multiple screens.

adv[Thanks]ance

Andrew Jackman
Harald Hein - 29 Dec 2003 07:19 GMT
> Currently, when I click on the main radar window, the window is
> raised on top of all other windows, including the task bar
> windows.  How can I prevent this behaviour?

You can't.
ak - 29 Dec 2003 09:52 GMT
> I am developing an application that has three JWindows that must
> always be displayed on the screen.  One displays radar data and is
> permanently fixed in the background and covers the entire screen,
> while the other two are task bar type windows located across the top
> and bottom of the screen.  The two task bar windows must always be
> displayed on top of the main radar window.
this is simple - main radar should be owner of task bar windows.

> Other JFrames and JDialogs
> may also be displayed over the top of the main radar window.
this is realy diffcult - I don't say it is impossible.
But you should forget JFrames/JDialogs and work only with JWindows.

____________

http://reader.imagero.com the best java image reader.
Andrew Jackman - 29 Dec 2003 23:27 GMT
...
> this is realy diffcult - I don't say it is impossible.
> But you should forget JFrames/JDialogs and work only with JWindows.

Thanks for your response, but can you please elaborate?  Why should I
work only with JWindows?
ak - 30 Dec 2003 02:51 GMT
> Thanks for your response, but can you please elaborate?  Why should I
> work only with JWindows?
because only with JWindow and JDialog you can have such hierarchie, but
JDialog always have title bar.
if you need to have title bar and border, you can implement it.

This is not really perfect solution (but I know only this one) - look at
code below - if you click at level3 then level2 is over level3b (tested only
with ms-windows)

public class JWinTest {

public static void main(String[] args) {
 JWindow owner = new JWindow();
 JWindow level1 = new JWindow(owner);
 JWindow level2 = new JWindow(level1);
 JWindow level3 = new JWindow(level2);
 JWindow level2b = new JWindow(level1);
 JWindow level3b = new JWindow(level2b);

 new DragHandler(owner);
 new DragHandler(level1);
 new DragHandler(level2);
 new DragHandler(level2b);
 new DragHandler(level3);
 new DragHandler(level3b);

 owner.setBounds(200, 200, 400, 400);
 level1.setBounds(300, 300, 300, 300);
 level2.setBounds(200, 200, 200, 200);
 level2b.setBounds(200, 200, 200, 200);
 level3.setBounds(200, 200, 100, 100);
 level3b.setBounds(300, 300, 100, 100);

 level1.getContentPane().setBackground(Color.green);
 level2.getContentPane().setBackground(Color.green.darker());
 level3.getContentPane().setBackground(Color.green.darker().darker());
 level2b.getContentPane().setBackground(Color.blue);
 level3b.getContentPane().setBackground(Color.blue.darker());

 owner.setVisible(true);
 level1.setVisible(true);
 level2.setVisible(true);
 level2b.setVisible(true);
 level3.setVisible(true);
 level3b.setVisible(true);
}

static class DragHandler extends MouseInputAdapter {

 int x0, y0, x, y;
 Window window;
 Rectangle rw = new Rectangle();

 public DragHandler(Window window) {
  this.window = window;
  window.addMouseListener(this);
  window.addMouseMotionListener(this);
 }

 public void mousePressed(MouseEvent e) {
  x = e.getX();
  y = e.getY();
  Point p = new Point(x, y);
  SwingUtilities.convertPointToScreen(p, e.getComponent());
  x = p.x;
  y = p.y;

  x0 = window.getX();
  y0 = window.getY();
 }

 public void mouseReleased(MouseEvent e) {
 }

 public void mouseDragged(MouseEvent e) {
  Point p = e.getPoint();
  SwingUtilities.convertPointToScreen(p, e.getComponent());
  int dx = x - p.x;
  int dy = y - p.y;
  rw = window.getBounds(rw);
  rw.x = x0 - dx;
  rw.y = y0 - dy;

  window.setLocation(rw.x, rw.y);
 }
}
}
____________

http://reader.imagero.com the best java image reader.
Andrew Jackman - 30 Dec 2003 11:22 GMT
Thanks!  That was a very helpful response.  I think I can adapt your example
to suit my needs.

Andrew

> > Thanks for your response, but can you please elaborate?  Why should I
> > work only with JWindows?
[quoted text clipped - 87 lines]
>
> http://reader.imagero.com the best java image reader.
Andrew Thompson - 30 Dec 2003 04:04 GMT
...
> I am developing an application that has three JWindows that must
> always be displayed on the screen.  One displays radar data

..hhmmm.  Made me think of this.

"..Software is not designed or intended for
use in on-line control of aircraft, air traffic,
aircraft navigation or aircraft communications;.."
[ vaious Sun licensing agreements ]

What you are coding _is_ just a
game or simulator, ..isn't it?       ;-)

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Andrew Jackman - 30 Dec 2003 11:27 GMT
Actually it is a prototyping tool to begin with, but it may eventually
evolve into a real-time ATC HMI if we find it meets our requirements.

> ...
> > I am developing an application that has three JWindows that must
[quoted text clipped - 15 lines]
> * http://www.1point1C.org/ 1.1C - Superluminal!
> * http://www.AThompson.info/andrew/ personal site
Andrew Thompson - 30 Dec 2003 18:37 GMT
> Actually it is a prototyping tool to begin with, but it may eventually
> evolve into a real-time ATC HMI if we find it meets our requirements.

So, do I get a free turn at the ATC, if
I can choot down enough of the HMI's
to gain a score 5000 or more?     ;-)

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.