Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane issue  RSS feed

 
vladislav peichev
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet, which displays a drawing and allows user to measure area by drawing lines. When the last drawn line intersects another line I display a JOptionPane with warning message for self-intersection. After the user presses the OK button my applet does not regain the focus, so ESC key cannot be used also the wrong line cannot be removed. Tried requestFocus and requestFocusWindow without success. How to regain focus after JOptionPane is closed? Thanks in advance.
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll probably need to use EventQueue.invokeLater / SwingUtilities.invokeLater, to make sure the focus event is processed correctly:
 
vladislav peichev
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using invokeLater does not help, the same issue still occurs. Any other suggestions?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post a SSCCE that clearly demonstrates your problem.
 
vladislav peichev
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my function which displays JOptionPane with Warning message in case of self-intersection.


The problem is that after JOptionPane is closed my applet does not gain the focus again, so it cannot capture ESC key pressed and also the applet is not redrawn properly.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vladislav, what part of the SSCCE page wasn't clear to you?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!