Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Basic Java Login Form Help - JPasswordField Error

Basic Java Login Form Help - JPasswordField Error

Basic Java Login Form Help - JPasswordField Error

Hi All,

I know this is probably a really basic question, however, I am making my first entry into Java programming and I am struggling a little with the coding and errors I'm getting.

My main issue is with this piece of code:



It tells me that getText() is deprecated, but a) I'm not sure exactly what that means and b) what I'm supposed to do about it.

Also, if someone has a second, can you have a look over my code and see if I am doing this to the proper standards or have I missed something simple.


package Forms;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Color;
import javax.swing.SwingConstants;

public class frmLogon {

    private JFrame frmLogon;
    private JTextField txtUserID;
    private JPasswordField txtPassword;
     * Launch the application.
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    frmLogon window = new frmLogon();
                } catch (Exception e) {

     * Create the application.
    public frmLogon() {

     * Initialize the contents of the frame.
    private void initialize() {
        frmLogon = new JFrame();
        frmLogon.setBounds(100, 100, 253, 171);
        txtUserID = new JTextField();
        txtUserID.setBounds(77, 11, 152, 20);
        txtPassword = new JPasswordField();
        txtPassword.setBounds(77, 42, 152, 20);
        JLabel lblUserId = new JLabel("User ID:");
        lblUserId.setBounds(10, 14, 57, 14);
        JLabel lblPassword = new JLabel("Password:");
        lblPassword.setBounds(10, 42, 57, 14);

        final JLabel lblError = new JLabel(" ");
        lblError.setBounds(10, 73, 219, 14);
        JButton btnLogon = new JButton("Logon");
        btnLogon.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent arg0) {
            //public final Boolean isEmpty()
                    System.out.println("No User ID");
                    lblError.setText("Please Enter A User ID");
                            System.out.println("No Password");
                            lblError.setText("Please Enter A Password");
                            System.out.println("This is the value: xx" + txtUserID.getText() + "xx");
                            System.out.println("This is the value: xx" + txtPassword.getText() + "xx");
                            lblError.setText("  ");
        btnLogon.setBounds(20, 98, 89, 23);
        JButton btnQuit = new JButton("Quit");
        btnQuit.setBounds(119, 98, 89, 23);


Many thanks for ANY help or support you can provide. I'm new to Java, have done some eTraining, but it's still a mystery.

Truely, Many Thanks,


Did you know, there are 10 types of people in this world:
* Those who understand binary
* Those who Don't!!

RE: Basic Java Login Form Help - JPasswordField Error

If a method is deprecated then this basically means that it scheduled to be removed in a later Java version. It is still available for backwards compatibility, but it is advised to use another method as replacement.

The JPasswordField.getText() method is deprecated, because it is considered to be less secure than the JPasswordField.getPassword() method (that replaces it).  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close