Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Making JDialog visible  RSS feed

 
craig chapman
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application written in JSP. When a user clicks on certain buttons I want to display a modal YES_NO JDialog asking the user to confirm their selection (the easy part). However, despite using toFront(), setVisible() and show() methods, the window when first created remains behind the browser. Subsequent calls to display the message work fine. Is there a way of ensuring the window is to the front every time (without using javascript)?
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since a JApplet isn't a Dialog/Frame/Window, there's no way for the JDialog to know what it is supposed to be displayed in front of. I think the standard work-around is to use a JInternalFrame instead of a dialog and display it on the glass pane (rather than the content pane) of the JApplet. You would also have to make the glass pane a mouse listener to block the user from clicking on the applet's controls.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I don't think that's going to prevent the user from clicking on other things on the webpage... it's just going to prevent them from clicking other places on the JApplet.

I think that you're going to *have* to use a JavaScript dialog to do what you're trying to do.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!