请问JOptionPane.showMessageDialog弹出的窗口能设成是模态的吗?怎么设?
如JOptionPane.showMessageDialog(null,"请输入密码!!" );弹出的不是模态的啊
回复 2楼 岁月如刀
改成一个对话框?怎么改啊?什么对话框啊?我是菜鸟啊import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import javax.swing.JOptionPane;
/**
* @author Administrator
*
*/
public class UserBean {
private java.lang.String userName;
private java.lang.String password;
public UserBean() {
}
public java.lang.String getUserName() {
return userName;
}
public void setUserName(java.lang.String userName) {
this.userName = userName;
}
public java.lang.String getPassword() {
return password;
}
public void setPassword(java.lang.String password) {
this.password = password;
}
public String loginUser() {
if("myeclipse".equals(getUserName()) && "myeclipse".equals(getPassword()))
{return "success"; }
else if("".equals(getUserName())||getUserName() == null)
{
JOptionPane.showMessageDialog( null,"用户名不能为空"); 这里怎么定父窗口啊???
return "re";}
else if(!"".equals(getUserName()) && "".equals(getPassword()))
{JOptionPane.showMessageDialog(null,"请输入密码!!");
return"re";}
return "failure";}
public String exitUser(){
int returnValue;
returnValue = JOptionPane.showConfirmDialog(null, "确实要退出吗?", "退出程序", JOptionPane.YES_NO_OPTION);
if (returnValue == JOptionPane.YES_OPTION)
{FacesContext fc = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);
session.invalidate();
return "exit";}
else return "";
}
public String reLogin(){
return "re";
}
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}