Results 1 to 8 of 8
Thread: Ask about JPasswordfield
- 09-11-2008, 01:24 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
Ask about JPasswordfield
Hi all,i'm using netbeans with ubuntu.I got a problem,i use a jtextfield and a jpaswordfield,when i run the program,jtextfield is ok,but whne i want to edit the jpasswordfield,it can't be edited,unless i've click a button displaying messages,then the jpasswordfield can be edited..What should i do?Thanks a lot..
- 09-11-2008, 04:41 PM #2
Can you provide the cod please,actually it should be this way:
you can try this demo JNLP application with JPasswordFieldJava Code:JPasswordField passwordField = new JPasswordField(10); passwordField.addActionListener(this);
PasswordDemo
and the code for it is:
PasswordDemo.javaLast edited by serjant; 09-11-2008 at 04:46 PM.
- 09-12-2008, 05:33 AM #3
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
i use netbeans
I use netbeans,i didn't edit the code for the jpasswordfield..When i delete the jtextfield,the jpasswordfield can be edited immediately.
-
My recommendation, and you're not going to like it: avoid using NetBeans to generate your Swing code and code it by hand. It's not hard to do, and in the process, you'll learn much more about Swing.
- 09-13-2008, 06:38 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
This is really nice advice for newbies, on swing specially. When you have better idea on such things better to move with Java IDE.
Back to the original question, can you post a code segment to see what you have exactly done. I hope it's not clear what you have done for most of the members.
- 09-13-2008, 09:34 AM #6
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
Here are the codes..I did'nt edit anything else for the jpasswordfield..
I'm confused..Last night i try,there's no problem..I can directly edit the password,but just now it doesn't works again..
private void btCancelActionPerformed(java.awt.event.ActionEvent evt)
{
System.exit(0);
}
private void btLoginActionPerformed(java.awt.event.ActionEvent evt)
{
try
{char[] pwd = txtPwd.getPassword();
StringBuffer str = new StringBuffer();for (int i=0;i<pwd.length;i++)
{
str.append(pwd[i]);
}
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(str.toString().getBytes(),0,str.length() );
String pass = new BigInteger(1,md.digest()).toString(16);
javax.persistence.Query query=ent.createQuery("select d from DataUser d where d.usrname=:name and d.pwd= :pwd");
query.setParameter("name",txtUser.getText());
query.setParameter("pwd", pass);
DataUser d =(DataUser) query.getSingleResult();
this.setVisible(false);this.dispose();new MainFrm().setVisible(true);
}
catch (Exception exception)
{
JOptionPane.showMessageDialog(null, exception.getMessage());
}
}
- 09-13-2008, 02:20 PM #7
,it can't be edited,unless i've click a buttonYour code in the above method appears to be called when a button is pressed. You don't show the addActionListener() call but the method name and args make it look like an actionListener. So its only called when the button is pressed.private void btLoginActionPerformed(java.awt.event.ActionEvent evt)
{
What do you want to change?
- 09-14-2008, 11:54 AM #8
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
I don't want to change anything
I don't want to change anything Norm..It just that i don't know why that the jpasswordfield that i put in the login form using netbeans are unabled to be edited on the runtime,unless i click the login button first,then back to edit the jpasswordfield....I'm using ubuntu,does it concern with it?Thansk a lot..


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks