File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Message box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Message box" Watch "Message box" New topic
Author

Message box

Jeff Dube
Ranch Hand

Joined: Jun 14, 2001
Posts: 44
Hi,
I made a form and i need to have a message box that inform the user if one or more field are empty.
I tried with the following:
<%<br /> if (".....one field is null.....")<br /> {<br /> this.showMessageDialog(null,"You need to enter a value...");<br /> }<br /> else<br /> { <br /> %>
<%@ include file="Response.jsp" %>
<%<br /> }<br /> %>
But it does'nt work. Do i have to insert the showMessageDialog inside my bean with the parent.showMesageDialog()?
I know that i can do it with javascript but i prefer java.
Is it possible??
Thank you very much
Jeff

manjerekar annajirao
Greenhorn

Joined: Jun 12, 2001
Posts: 4
hi jeff
this is manjerekar.
u haven't specified anything clear. but still i consider ur class extends JFrame. to display a message box , u can go for a JOptionPane class where we have methods to display different dialog boxes.
here's the code for opening a file
==================================
when there is a file opening error this dialog box is displayed.
catch(Exception e)
{
JOptionPane.showMessageDialog(frame,new String[]
{
"Unable to open file",fileName.toString()
},"File Open Error",JOptionPane.INFORMATION_MESSAGE);
}
frame------object of JFrame.
fileName-----selected file.
u can manipulate the same for a displaying a dialog box , when the user as not filled in the boxes.
hope this will help u out.
Amit Agarwal
Ranch Hand

Joined: May 09, 2001
Posts: 92
Hi Jeff,
Your code is not visible, but generally you do not have to insert anything.
The showMessageDialog is a statc method of the JOptionPane class, and can be directly called by using the class name or an instance of the JOptionPane class.
Usage:
JOptionPane.showMessageDialof, parent, "Message", "Title", JOptionPane.ERROR_MESSAGE);
--------
Regards,
Amit
 
wood burning stoves
 
subject: Message box