Pessoal, mais duvidas sobre if

Pessoal, eu to com outro problema em IF, eu tenho dois campos e quero fazer com o comando select ele verifica sem o usuário consta no banco de daados, se consta, ai ele abre o menu principal, fiz um código mais ou menos, para dar uma mensagem se der certo, mas tá alegando erro no jPasswordField.getText.equalsIgnoreCase(""), alguem pode me ajudar??

private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setText("OK");
			jButton.setLocation(26, 159);
			jButton.setSize(90, 39);
			jButton.addActionListener(new java.awt.event.ActionListener() {   
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					jTextField.getText();
					jPasswordField.getText();
					//System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
					if (jTextField.getText().equals("") || jPasswordField.getText().equals("")){
						JOptionPane.showMessageDialog(null,"Campos em branco");
					}
					else{
					try
					{
						Conexao.conectar().createStatement().executeQuery("SELECT * FROM USUARIO" );
						if (jTextField.getText().equalsIgnoreCase("") || jPasswordField.getText.equalsIgnoreCase("")){
							JOptionPane.showMessageDialog(null, "Usuário Existente");
						}
						
					}catch (Exception error){
						error.printStackTrace();
					}
						
					}
			
				}
			});
			
		}
		return jButton;
	}

[size=“11”]
[color=“red”]

  • Editado: Aumente as chances de alguém responder o seu tópico. Use BBCode em seus códigos para mantê-los identados e mais legíveis para outros usuários. - Matheus[/color][/size] :joia:

E qual é o erro que está alegando?

O erro que é constatado é a seguinte:

jPasswordField.getText cannot be resolved or is not a field.

tu declarou a variável jPasswordField? Se sim, ela está visível neste escopo?

Vou tentar mandar o código pra ver como que ta, para ver como que tá, pq naum entendi sua explicação, vou tentar usar o bbcode

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JInternalFrame;
import javax.swing.JDesktopPane;
//import javax.swing.JOptionPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.sql.*;
/*
 * Created on 06/07/2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author unknown
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Login extends JInternalFrame implements ActionListener {

	private javax.swing.JPanel jContentPane = null;

	private JDesktopPane jDesktopPane = null;
	private JPanel jPanel = null;
	private JLabel jLabel = null;
	private JTextField jTextField = null;
	private JLabel jLabel1 = null;
	private JPasswordField jPasswordField = null;
	
	private static Connection con;

	private ResultSet resultado;

	private JLabel systemIMG = null;

	private JLabel jLabel2;
	private JButton jButton = null;
	private JButton jButton1 = null;



	protected String usuario;
	/**
	 * 
	 */
	public Login() {
		super();
		// TODO Auto-generated constructor stub
		initialize();
	}

	/**
	 * @param arg0
	 */
	public Login(String arg0) {
		super(arg0);
		// TODO Auto-generated constructor stub
		initialize();
	}

	/**
	 * @param arg0
	 * @param arg1
	 */
	public Login(String arg0, boolean arg1) {
		super(arg0, arg1);
		// TODO Auto-generated constructor stub
		initialize();
	}

	/**
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 */
	public Login(String arg0, boolean arg1, boolean arg2) {
		super(arg0, arg1, arg2);
		// TODO Auto-generated constructor stub
		initialize();
	}

	/**
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @param arg3
	 */
	public Login(String arg0, boolean arg1, boolean arg2, boolean arg3) {
		super(arg0, arg1, arg2, arg3);
		// TODO Auto-generated constructor stub
		initialize();
	}

	/**
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @param arg3
	 * @param arg4
	 */
	public Login(String arg0, boolean arg1, boolean arg2, boolean arg3,
			boolean arg4) {
		super(arg0, arg1, arg2, arg3, arg4);
		// TODO Auto-generated constructor stub
		initialize();
	}

	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub

	}

	/**
	 * This method initializes jDesktopPane	
	 * 	
	 * @return javax.swing.JDesktopPane	
	 */    
	private JDesktopPane getJDesktopPane() {
		if (jDesktopPane == null) {
			jDesktopPane = new JDesktopPane();
			systemIMG = new javax.swing.JLabel();
			jLabel2 = new JLabel();
			jDesktopPane.setBounds(0, 0, 487, 307);
			systemIMG.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sistemaLogin.jpg")));
			jLabel2.setBounds(333, 116, 10, 10);
			jLabel2.setText("");
			systemIMG.setBounds(215, 17, 259, 214);
			systemIMG.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
			jDesktopPane.add(getJPanel(), null);
			jDesktopPane.add(jLabel2, null);
			jDesktopPane.add(systemIMG, null);
			jDesktopPane.setBackground(new java.awt.Color(88, 87, 104));
		}
		return jDesktopPane;
	}
	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */    
	private JPanel getJPanel() {
		if (jPanel == null) {
			jPanel = new JPanel();
			jLabel = new JLabel();
			jLabel1 = new JLabel();
			jPanel.setLayout(null);
			jPanel.setBounds(17, 16, 190, 272);
			jPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
			jLabel.setText("LOGIN");
			jLabel.setFont(new java.awt.Font("Bookman Old Style", java.awt.Font.BOLD, 14));
			jLabel.setLocation(17, 30);
			jLabel.setSize(70, 20);
			jLabel1.setText("SENHA");
			jLabel1.setSize(53, 20);
			jLabel1.setLocation(17, 90);
			jLabel1.setFont(new java.awt.Font("Bookman Old Style", java.awt.Font.BOLD, 14));
			jPanel.add(jLabel, null);
			jPanel.add(getJTextField(), null);
			jPanel.add(jLabel1, null);
			jPanel.add(getJPasswordField(), null);
			jPanel.add(getJButton(), null);
			jPanel.add(getJButton1(), null);
		}
		return jPanel;
	}
	/**
	 * This method initializes jTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */    
	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setSize(150, 20);
			jTextField.setLocation(17, 55);
		}
		return jTextField;
	}
	/**
	 * This method initializes jPasswordField	
	 * 	
	 * @return javax.swing.JPasswordField	
	 */    
	private JPasswordField getJPasswordField() {
		if (jPasswordField == null) {
			jPasswordField = new JPasswordField();
			jPasswordField.setLocation(17, 125);
			jPasswordField.setSize(150, 20);
		}
		return jPasswordField;
	}
	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */    
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setText("OK");
			jButton.setLocation(26, 159);
			jButton.setSize(90, 39);
			jButton.addActionListener(new java.awt.event.ActionListener() {   
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					jTextField.getText();
					jPasswordField.getText();
					//System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
					if (jTextField.getText().equals("") || jPasswordField.getText().equals("")){
						JOptionPane.showMessageDialog(null,"Campos em branco");
					}
					else{
					try
					{
						Conexao.conectar().createStatement().executeQuery("SELECT * FROM USUARIO" );
						if (jTextField.getText().equalsIgnoreCase("") || jPasswordField.getText.equalsIgnoreCase("")){
							JOptionPane.showMessageDialog(null, "Usuário Existente");
							
						}
						
					}catch (Exception error){
						error.printStackTrace();
					}
						
					}
			
				}
			});
			
		}
		return jButton;
	}
	
	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */    
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("SAIR");
			jButton1.setSize(90, 39);
			jButton1.setLocation(26, 209);
			jButton1.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					System.exit(0); // TODO Auto-generated Event stub actionPerformed()
				}
			});
		}
		return jButton1;
	}
      	public static void main(String[] args) {
      		Login log = new Login();
	}
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setTitle("Login SCE");
		this.setSize(497, 341);
		this.setContentPane(getJContentPane());
		this.setVisible(true);
		this.setClosable(true);
		this.setMaximizable(true);
	}
	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private javax.swing.JPanel getJContentPane() {
		if(jContentPane == null) {
			jContentPane = new javax.swing.JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJDesktopPane(), null);
		}
		return jContentPane;
	}
	public static Connection conectar() throws ClassNotFoundException, SQLException {
		if (con == null) {
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			return DriverManager.getConnection("jdbc:odbc:Leonardo", "sa", "");
		}
		return con;
	}
	public static ResultSet setSql() {//função que seta o comando sql que será utilizado
		String strSQL = "SELECT * from alguma coisa";
		try {
			con = conectar();
			java.sql.Statement stmt = con.createStatement();
			stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(strSQL);
			return rs;
		} catch (SQLException e) {
			System.out.println("Erro ao especificar consulta. Método setSql(). SQL = "+ strSQL);
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}//finalizada função do comando sql

}  //  @jve:decl-index=0:visual-constraint="10,10"

cara o erro tá aqui…

[code] {
Conexao.conectar().createStatement().executeQuery(“SELECT * FROM USUARIO” );
if (jTextField.getText().equalsIgnoreCase("") || jPasswordField.getText().equalsIgnoreCase("")){
JOptionPane.showMessageDialog(null, “Usuário Existente”);

              } [/code]

nunca se esqueça que getText() é um método… portanto precisa dos parenteses

/T+