Hi Erik
danish?
below is a solution proposed to me when wanting to do the same
It works with JDK 1.3
I was trying to use it under JDK 1.1.8 and wrote my own AWT Listener
---------------
import java.util.EventListener;
import java.awt.AWTEvent;
public interface AWTEventListener extends EventListener {
public void eventDispatched(AWTEvent event);
}
---------------
But there where other 1.3 issues, and since our application, must run under
jdk 1.1.8 i stopped trying, and instead we have made our own windows
hierachy system, and then a jinternalframe given a modal flag, cannot lose
focus to its owner
If you can use jdk 1.3 this will work though and may be also in jdk 1.2.2
--------------solution proposal----------------
Subclass of JPanel
public class JRGlassPane extends JPanel implements AWTEventListener {
BorderLayout borderLayout1 = new BorderLayout();
InternalFrame parentFrame;
public JRGlassPane(InternalFrame parent) {
super();
parentFrame = parent;
// I don't need the cursor!
// this.setCursor(Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR));
setOpaque(false);
addMouseListener(new MouseAdapter() {
});
addKeyListener(new KeyAdapter() {
});
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
/**
* Override setVisible to install/remove key events hook that will allow
us to
* disable key events when the glass pane is visible.
*/
public void setVisible(boolean visible)
{
// This method is called also when an internal frame is selected
(window bar
// pushed, window resized...) with a visible = true parameter and
that
makes
// the functionality to become incorrect and surprising.
if (visible)
{
if (this.parentFrame == null)
Toolkit.getDefaultToolkit().addAWTEventListener (this,
AWTEvent.KEY_EVENT_MASK);
}
else
{
Toolkit.getDefaultToolkit().removeAWTEventListener (this);
}
super.setVisible(visible);
}
/**
* Called whenever there is an event in AWT queue. Note that the current
implementation
* skips all key events, not just events for this window. Logic can be
enhanced to examine
* the source of the event and it's parent window and skip only those
events
* that originated from disabled window
*/
public void eventDispatched(AWTEvent event)
{
if (event instanceof KeyEvent && event.getSource() instanceof
Component)
{
if (GUIUtilities.getInternalFrame((JComponent) event.getSource())
== this.parentFrame)
// Consume events only for our window
((KeyEvent)event).consume();
}
}
void jbInit() throws Exception {
this.setLayout(borderLayout1);
}
}
-------end solution---------------------------
Venlig hilsen
Peter Tilsted
Projekt Storkundel�nsomhed, 5094
tlf: +45 3333 4982
Email: [EMAIL PROTECTED]
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing