Re: [Swing] Controlling depth of multiple JWindows.

From: Andrew Jackman (software.engineer_at_andrewjackman.com)
Date: 12/30/03


Date: Tue, 30 Dec 2003 22:22:12 +1100

Thanks! That was a very helpful response. I think I can adapt your example
to suit my needs.

Andrew

"ak" <spam@imagero.com> wrote in message news:bsqpbc$doh$1@online.de...
> > 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.
>
>



Relevant Pages

  • JFrame Resize Issues (Redux)
    ... However, when the LookAndFeel is set, Java's Window Manager ... public int OffSetX = 0; ... private Rectangle positRectangle; ... public void componentHidden{ ...
    (comp.lang.java.programmer)
  • Re: New Swing Window Not Drawn
    ... The other actions that need to happen while this window appears ... public void activate{ ... thread and Swing should be able to have time to render it? ... All interaction with Swing components should be done on the Event ...
    (comp.lang.java.programmer)
  • Re: problem in coding window
    ... i am new with java and am learning it from Schildt's complete reference, i try to convert an applet example there to a window program, it got compiled but result is not as expected it is only showing the last checkbox, plz help me with corrections or correct code import java.awt.*; ... public class CBGroup extends Frame ... Checkbox win98,winNT,solaris,mac; ... public void itemStateChanged ...
    (comp.lang.java.help)
  • Re: Swing - paintComponent not called
    ... public void actionPerformed{ ... you are launching a new window in a non-EDT thread, ... To create the window in the EDT--just move the ProgressFrame creation ...
    (comp.lang.java.programmer)
  • Re: Preferences Dialog in C#
    ... > public void DisplayPreferencesDialog() ... > Your preferences window gets one new property and a new method. ... > URL on the browser window ... > programmer helping programmers. ...
    (microsoft.public.dotnet.languages.csharp)