To be able to intercept Keyboardevents it's necessary to request focus on the glasspane
addComponentListener(new ComponentAdapter()
{
@Override
public void componentShown(ComponentEvent pE)
{
requestFocusInWindow();
}
});
and this works fine but if I use te Tab Key I can still get to the component behind the glasspane.
I have then used setFocusTraversalKeysEnabled(false); for the glasspane and this works a little bit better but if I select something in a dialog on top of the glasspane I can still tab to the compoent behind the glasspane.
Any ideas?
Sun Certified Java Programmer<br />Sun Certified Web Component Developer<br />IBM Certified Enterprise Developer
the problem is that unless someone has tried to do exactly what you're trying to do,
has experienced the exact same problems of the scenario you have posted, and come
up with a solution that they could post, then the rest of us would need to build a sample
program to observe the behavior and to experiment with to possibly find a solution.
so, your options are
1) wait for someone who has the solution
2) hope someone has spare time/energy to build a program
3) post a working program for the rest of us to play around with.
But what I want to accomplish is that the user should not be able to click on anything behind the dialog showing.
This is normally done by using a Glasspane, but maybe there are other solutions?
Sun Certified Java Programmer<br />Sun Certified Web Component Developer<br />IBM Certified Enterprise Developer
Well it's not really a dialog and I don't want to have it modal I want a Glasspane.
The glasspane works fine but it is still possible to "tab" behind it.
Sun Certified Java Programmer<br />Sun Certified Web Component Developer<br />IBM Certified Enterprise Developer
If it wont matter that dialog will not be in separate window.
You could try to draw/add your dialog on glasspane?
Create some JOptionPane and then JDialog by calling JOptionPane.createDialog(Component parentComponent, String title) then JDialog.getContentPane() and add that to your glasspane. Something like that would help, I haven't tried it myself yet.
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.