Ok this is what I've got:
>From the main JFrame class (MDI application that was created by
NetBeans 5.0) I call a JIF:
Update modal = new Update("Modal window", MainApp.this );
modal.setVisible(true);
try {
modal.setSelected(true);
} catch (java.beans.PropertyVetoException e1) {}
This is some code of the Update class:
public class Update extends javax.swing.JInternalFrame {
JPanel glass = new JPanel();
MouseInputAdapter adapter = new MouseInputAdapter(){};
public Update(String title, javax.swing.JFrame parent ) {
super ( title );
initComponents();
glass.setOpaque(false);
glass.addMouseListener(adapter);
glass.addMouseMotionListener(adapter);
glass.setBounds(20,20, 200, 200);
glass.add(this);
parent.getRootPane().setGlassPane( glass );
glass.setVisible(true);
System.out.println("InitGlass="+ glass.getLocation() + "
InitJIF="+ this.getLocation());
}
This Update class size and all other properties are set through the
InitComponents().
When the window appreas, the printing line got the following results:
InitGlass=java.awt.Point[x=20,y=20] InitJIF=java.awt.Point[x=0,y=0]
I have a button on this internal frame and when I press it without
moving the window, then I got:
BtnGlass=java.awt.Point[x=5,y=5] BtnJIF=java.awt.Point[x=88,y=5]
If I move the window and press the button, the Point values are
different, but the glass location remains x=5, y=5.
What could be wrong? Why I can't set the proper location for the first
time?
Vova Reznik - 27 Apr 2006 15:01 GMT
> Ok this is what I've got:
>
[quoted text clipped - 24 lines]
> glass.addMouseListener(adapter);
> glass.addMouseMotionListener(adapter);
/*
* no needs to set bounds, glass pane
* should cover whole JFrame (without title bar area)
*/
> glass.setBounds(20,20, 200, 200);
/*
* If you need to show internal frame at specific
* location then:
*/
glass.setLayout(null);
this.setLocation(10, 10);
> glass.add(this);
>
> parent.getRootPane().setGlassPane( glass );
parent.setGlassPane(glass);
> glass.setVisible(true);
>
[quoted text clipped - 17 lines]
> What could be wrong? Why I can't set the proper location for the first
> time?
Mikl - 27 Apr 2006 15:43 GMT
Thanks Vova, it works like a charm!