Ok so I am writing this GUI menu and one of the choices on the menu requires the user to log in. So I open a new window that prompts the user for a username password. However after the user inputs the information how do I just close the window? I don't mean exit the program but just close the GUI window. Or when user hits the cancel button I just want to close the window

Edited 5 Years Ago by akaicewolf: n/a

As you open a new window for the user to enter the username and password you can close that window using self.close() function in javascript by assigning it to the cancel button.So when the user clicks on the cancel button the window gets closed

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript">
function closewin()
{
javascript:self.close();
}
</script>
</head>

<body>
<input type="button" value="cancel" onclick="closewin(this)"/>
</body>
</html>
Comments
there 's a huge difference between java and javascript, make sure you know what you are offering as answer

I am not to sure which library its from. Javascript doesn't help me out tho. Here is my code for the one of the windows

But my code uses things like JFrame,JPanel,JButton, ActionListener etc... not sure which library that is

I don't get any indication from the OP that this is an applet.
Look up JOptionPane to display a dialog window.

This article has been dead for over six months. Start a new discussion instead.