Forums Register Login

Option dialogue box not getting focus

+Pie Number of slices to send: Send

Object[] options = {"Delete","Cancel"};
int confirm=JOptionPane.showOptionDialog(null,"Are you sure you want to delete?","Delete Confirm",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[0]);

I used the above snippet to get a optiondialogue box.its working.But for the first time after running the application,its not getting focus.
please provide a solution.
Thanks in advance
+Pie Number of slices to send: Send
Moving to Swing.
+Pie Number of slices to send: Send
Hello, and welcome to JavaRanch!

I doubt anyone will be able to figure out your problem given the information presented. You may want to create a very small compilable program that demonstrates your problem and that we can run on our machines. Do this and I predict your odds of getting a helpful solution to be > 90%.

Much luck!
+Pie Number of slices to send: Send
Actually i wanted to have a customised confirm box.since its not possible to customise the javascript confirm box.i tried the above one.I depolyed the war in my Jboss server with the same code .On Running the application ,and tring to click my form button which redirects to the jsp having this code snippet ,the pop up is coming .But its coming in the background for the first time.I 've to press alt+tab to see the confirm box.But for the subsequent requests its working as expected.The problem is only with the first request.
+Pie Number of slices to send: Send
I'm not sure how you want to customize it, but you can change the image, create your own text, insert HTML code to style it. JOption's offer a wide variety of ways to make it look just how you want.
+Pie Number of slices to send: Send
Wait, what? Are you trying to use a JOptionPane in a web application? I don't think this is ever going to work properly; the JOptionPane will be shown on the web server, not the client PC.

Maybe you should switch to using an applet instead. Don't use null as the parent then; that will not make the dialog modal. When an applet is shown in a web browser, it has a parent frame that represents the browser. You can get a reference to that as follows:
+Pie Number of slices to send: Send
Hi Rob
Can you please explain this.
Thanks in advance
+Pie Number of slices to send: Send
JOptionPane shows its dialogs on the machine where the JVM is running. For web applications, this is the server. Therefore, clients of your web application will not see it. The only reason you are seeing it is probably because the client and server are the same machine.

For showing dialogs on the client you can use JavaScript, an applet or some framework (I'm working with jACOB at the moment at work, but JSF should also be able to help you out).

If you then decide to use an applet, you must pass a proper component to the JOptionPane methods or the dialog will not be modal, and that is something you definitely want. That's what you can use the Frame my code returns for.
+Pie Number of slices to send: Send
Hi Rob,
i am very new to applet.please explain in detail how to get a dialogue box using applet whict pops up on clicking action on jsp page.
Thanks in advance
+Pie Number of slices to send: Send
The applet would more or less have to replace your JSP. It is possible to interact between an applet and its surrounding page using JavaScript but frankly I couldn't tell you how.

To be honest, I doubt that what you actually want (a Swing dialog instead of a JavaScript dialog) is possible.
+Pie Number of slices to send: Send
Hi Rob,
My doubt is if we are using swing,that will also get run only in serverside right?
+Pie Number of slices to send: Send
Not if it's an applet, but otherwise yes.
I love a good mentalist. And so does this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1831 times.
Similar Threads
Dialog box help
Drag-and-drop questions in SCJP
Focus for the Confirmation Box
Generic Ok / Cancel Screen --- Alert doesn't do
Delete button and scriptlet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:29:44.