Re: Moving a glass pane
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 ,y ] 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?