Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with JOptionPane.ShowMessageDialog  RSS feed

 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am facing a problem with JOptionPane.ShowMessageDialog()

The problem is that the message is not coming to front of the screen when a java applet is opened. The scenario is like this:

User login in to application GUI in IE and home page is displayed. From there user trying to launch another swing GUI by clicking on a link. During that process there is a condition which will check if a boolean variable is set true or false. If the boolean variable is set to false then user will get a popup message "Application GUI failed". This message is coming to the front of the screen if there is no other GUI launched from the home page. If there is any other GUI is launched from this home page and if the boolean variable is set to false, the popup message is struck behind the home page and is not coming to the front.

The code is like this:



I tried this way


But it didn't worked. Is there any way to force it to display in the front of the screen . Please help me in this
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try:

 
Campbell Ritchie
Sheriff
Posts: 53769
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a new JFrame() as the component in the showMessageDialog() method, and that frame isn't visible, where is your dialog going to appear?
 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried this way also




But still no luck. The Message is getting stuck between the Home page and the GUI application. It is not able to come to the front of the home page
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using a new frame ? Shouldn't you pass the reference of the applet (this?) instead ?
 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Christophe, I tried that also. But I am getting this compilation Error:


VMManager.java:1019: windowForComponent(java.awt.Component) in javax.swing.SwingUtilities cannot be applied to (com.nortel.
omea.omeacwdlaunch.VMManager)

JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(this), "Application GUI failed");



please help
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then pass a reference to the applet. Apparently this code is not in the applet but a separate class.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Rob says, you've got to find a way to get a reference to the applet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!