Forums Register Login

Query about event for refresh button??

+Pie Number of slices to send: Send
Hi all friends,
Iam new to swing I prepare one login dialog box using swing and i add one refresh button on that dialog box now i want to give one event on that refresh button so that when user click on refresh button that dialog box should refresh because if user type wrong username or password then they can refresh that dialog box and they can type again just like as html file's refresh button.
below r my codes:-
refresh.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//what should be the code here
}
});
Regards
Bikash
+Pie Number of slices to send: Send
Hi,
Did u mean u want to refresh the TextFields in the dialog box?
If so, assuming the text fields are userTF and passwordTF,
in the actionPerformed() method put the following code:
userTF.setText("");
passwordTF.setText("");

That's it!!
Shashi
+Pie Number of slices to send: Send
Hi,
Thanks for ur reply now it working fine I want to send the userid and password to my servlet on the action event of my submit button for that i try to code like below but it is not sending userid and password to my servlet.Can any one plz guide me how i can do that.

submit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try{
String userid1;
String password1;
String url="http://127.0.0.1:8080/examples/servlet/loginServlet";
userid1 = userid.getText();
password1 = password.getText();
u = new URL(url+"?name=" +userid1 + "&path=" + password1);
uc = (HttpURLConnection)u.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-Type","application/octet-stream");
printout = new DataOutputStream(uc.getOutputStream ());
}catch(Exception ex){System.out.println("Error from actionPerformed :" +
ex.getMessage());}
}
});
Regards
Bikash
+Pie Number of slices to send: Send
uc = (HttpURLConnection)u.openConnection();
I hope uc above is an URLConnection object.
if so change the code to:
uc = u.openConnection(); //no need to type cast
and remove the lines after this line including uc.setRequestProperty()
these lines are needed in case of POST method, in your case, it is GET method.

Shashi
+Pie Number of slices to send: Send
Hi,
I have tried as per ur given guide but couldn't slove my problem.My login dialog is not connecting with my servlet.Can u plz tell me where i have done mistake in my code.In my servlet iam getting parameter by :-
String str = req.getParameter("name");
String str1 = req.getParameter("path");
I also tried like below in my loginDialog(swing)& servlet file but couldn't slove my problem:-
String content =userid1+password1;
printout.writeBytes(content);
printout.flush();
printout.close();
Servlet file:-
============
DataInputStream dos =new DataInputStream(req.getInputStream ());
String str = dos.readLine();
out.println(str);
Iam new to swing plz help me to slove my problem.
Regards
Bikash
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1524 times.
Similar Threads
CheckBox state
Dialog Box Refresh Problem
Dialog Box Refresh Problem
Layered MVC and Chain of Responsibility via Events
Dialog Box Problem
More...

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