![]() |
|
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| Graphic, Photography & Coding Talk about Graphic Design, Photography and website coding |
This is a discussion on more Java help within the Graphic, Photography & Coding forums, part of the The Lounge category; OK i need more help now. its the last thing i need to do i think on this. I cant ...
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Member
Join Date: Mar 2008
Posts: 231
|
OK i need more help now. its the last thing i need to do i think on this. I cant find in my notes anywhere how to replace a text box with astericks.
![]() like when a person inputs somehting it needs show up as astericks instead of their letters. oh and i need to check to make sure they match each other when it checks.... Code:
// create the password label
labelPass = new JLabel ( ); //instantiate new jlabel
labelPass.setText ("Password "); //set label text to Phone #
labelPass.setLocation(24,290); //set location of jlabel
labelPass.setSize(200,25); //set size of jlabel
labelPass.setForeground(Color.BLACK);//set initial background color
contentPane.add(labelPass); //add jlabel to content pane
// create the password text box
textPass = new JTextField ( ); //instantiate new JTextField
textPass.setText(""); //clear jtextfield
textPass.setToolTipText("Please type in password");
textPass.setLocation(90,290); //set location of jtextfield
textPass.setSize(200,25); //set size of jtextfield
contentPane.add(textPass); //add jextfield to content pane
// create the repassword label
labelRepass = new JLabel ( ); //instantiate new jlabel
labelRepass.setText ("Repassword "); //set label text to Phone #
labelRepass.setLocation(24,320); //set location of jlabel
labelRepass.setSize(200,25); //set size of jlabel
labelRepass.setForeground(Color.BLACK);//set initial background color
contentPane.add(labelRepass); //add jlabel to content pane
// create the repassword text box
textRepass = new JTextField ( ); //instantiate new JTextField
textRepass.setText(""); //clear jtextfield
textRepass.setToolTipText("Please type in password again");
textRepass.setLocation(100,320); //set location of jtextfield
textRepass.setSize(200,25); //set size of jtextfield
contentPane.add(textRepass); //add jextfield to content pane
then skipping ahead where the checks are made: Code:
private boolean checkPass ()
{
if (textPass.getText().length() == 0)
{
labelPass.setForeground(Color.RED); //password is not correct
return false;
}
else
{
labelPass.setForeground(Color.BLACK); //password is correct
return true;
}
} //end of method
private boolean checkRepass ()
{
if (textRepass.getText().length() == 0 )
{
labelRepass.setForeground(Color.RED); //city is not correct
return false;
}
else
{
labelRepass.setForeground(Color.BLACK); //city is correct
return true;
}
} //end of method
here are my specs in particular this part Code:
Add labels and textfields for phone, email, password, and retype password. Make these textfields show **** as a user types in their password. Adjust the GUI any way that you like as long as it looks good. Code:
The checkPassword method needs to be added to program. This method should check the text in the password textfield vs. the text in the retype password textfield. If both of these passwords are equal, then both labels foregrounds (password and retype password ) should be set to original color of black. If these passwords are not equal, then both labels foregrounds should be set to red This the last thing i need help with on this nights HW i am dying herei know replacing needs to be like labelPass.replace('insert here', 'here') // problem is that can only do single character replacements with that, unless i misunderstood also "&" isnt working when setting that boolean condition to make sure they are both equal to each other Last edited by Megalomaniac; 04-29-2008 at 08:58 AM. |
|
|
|
|
|
#3 (permalink) |
|
Junior Member
Join Date: Mar 2008
Posts: 42
|
IE.
if(password_box1 == variable) && (password_box2 == variable) do whatever(); else passwords do not match(); I can't remember if you compare those variables with dual or single == I think it depends on the type of variables. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|