Não consigo digitar nada nos campos JTextField e JPasswordField [RESOLVIDO]

1 resposta
M

Boa tarde pessoal, tô criando uma tela de login e tô com problema nos campos JTextField e JPasswordField não consigo digitar nada neles não sei o porque.

segue meu código:
public class LoginSplashView extends JWindow {
    //declaração de variáveis
    JLabel         lUsuario = new JLabel();
    JLabel         lSenha   = new JLabel();
    JTextField     Usuario  = new JTextField();
    JPasswordField Senha    = new JPasswordField();
    JButton        Fechar   = new JButton();
    JButton        Entrar   = new JButton();

    public void LoginSplashShow(){
        JPanel content = (JPanel) getContentPane();
        content.setLayout(null);
        content.setBackground(Color.white);

        // Configura a posição e o tamanho da janela
        int width  = 450;
        int height = 300;
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width-width)/2;
        int y = (screen.height-height)/2;
        setBounds(x, y, width, height);

        // Constrói o splash screen
        JLabel LabelIcone = new JLabel();
        ImageIcon imageIcon = new ImageIcon(getClass().getResource("/br/com/mjjoias/icones/SplashScreen.jpg"));
        LabelIcone.setIcon(imageIcon);
        LabelIcone.setBounds(0, 0, imageIcon.getIconWidth(), imageIcon.getIconHeight());

        lUsuario.setText("Usuário");
        lUsuario.setFont(new Font("Arial", Font.LAYOUT_LEFT_TO_RIGHT, 11));
        lUsuario.setForeground(Color.white);
        lUsuario.setBounds(5, 222, 50, 20);

        lSenha.setText("Senha");
        lSenha.setFont(new Font("Arial", Font.LAYOUT_LEFT_TO_RIGHT, 11));
        lSenha.setForeground(Color.white);
        lSenha.setBounds(5, 245, 50, 20);

        Usuario.setBounds(50, 222, 150, 20);
        Usuario.setFocusable(true);

        Senha.setEditable(true);
        Senha.setBounds(50, 245, 150, 20);

        Entrar.setText("Login");
        Entrar.setIcon(new ImageIcon(getClass().getResource("/br/com/mjjoias/icones/login.gif")));
        Entrar.setBounds(50, 270, 80, 20);

        Entrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                LoginControle controle = new LoginControle();
                //controle.Login(this);
            }
        });

        Fechar.setIcon(new ImageIcon(getClass().getResource("/br/com/mjjoias/icones/X.jpg")));
        Fechar.setBounds(430, 5, 15, 15);

        Fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });

        content.add(lUsuario);
        content.add(Usuario);
        content.add(lSenha);
        content.add(Senha);
        content.add(Entrar);
        content.add(Fechar);
        content.add(LabelIcone);

        Color borderColor = new Color(255, 255, 255);
        content.setBorder(BorderFactory.createLineBorder(borderColor, 10));
        content.setEnabled(true);

        //pack();
        
        this.setVisible(true);
    }

    public JTextField getUsuario(){
        return this.Usuario;
    }

    public JTextField getSenha(){
        return this.Senha;
    }
}

1 Resposta

M

Consegui resolver, o problema era que eu estava estendendo JWindow refiz a classe usando JFrame e deu tudo certo :slight_smile:

Criado 22 de abril de 2009
Ultima resposta 22 de abr. de 2009
Respostas 1
Participantes 1