Erro de complilação

18/09/2019

0

Boa tarde pessoal estou com um problema de programação que tenho certeza que pra vcs é muito simples, quando compilo meu programa vai tude bem até certa parte onde aparece uma mensagem em vermelho.
Note: Some input files use or override or deprecated API
Note: Recomplile With -Xlint:deprecation for details.
quando termina executo o programa coloco o usuário e a senha da a mensagem de ok mais abre o sistema. me ajudem pessoal por favor
Alexsandro Costa

Alexsandro Costa

Responder

Posts

18/09/2019

Joao Nascimento

Manda o código?
Responder

18/09/2019

Alexsandro Costa

Manda o código?

Boa tarde João, cara andei lendo algumas coisas que coloquei em pratica e erro sumiu, ele compila de boa mais quando mando limpar e construiu ele executa sem erro e quando vou no programa e executo coloco o usuario e a senha aparece a opção de ok da msg que coloquei masi não sai do lugar fica parado na tela de login.
Responder

18/09/2019

Alexsandro Costa

Manda o código?

Boa tarde João, cara andei lendo algumas coisas que coloquei em pratica e erro sumiu, ele compila de boa mais quando mando limpar e construiu ele executa sem erro e quando vou no programa e executo coloco o usuario e a senha aparece a opção de ok da msg que coloquei masi não sai do lugar fica parado na tela de login.


Segue o codigo:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package br.com.view;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/**
*
* @author alex.costa
*/
public class Novo extends javax.swing.JFrame {

PreparedStatement pst;
ResultSet rs;
Connection con;

/**
* Creates new form Tela_Login
*/
// @override
public Novo() {
initComponents();
URL caminhoIcone = getClass().getResource("/br/com/view/imagens/login.png");

Image iconeTitulo = Toolkit.getDefaultToolkit().getImage(caminhoIcone);

this.setIconImage(iconeTitulo);

this.setLocationRelativeTo(null);

byte[] person_image = null;

}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
txtlogin = new javax.swing.JTextField();
btnlimpar = new javax.swing.JToggleButton();
btnsair = new javax.swing.JToggleButton();
lblimage = new javax.swing.JLabel();
btnentrar = new javax.swing.JButton();
jpsenha = new javax.swing.JPasswordField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBackground(new java.awt.Color(51, 51, 0));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Acesso ao Sistema", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial Black", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N
jPanel1.setAlignmentX(0.0F);
jPanel1.setAlignmentY(0.0F);

jLabel1.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Nome:");

jLabel2.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("Senha:");

txtlogin.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txtloginKeyPressed(evt);
}
});

btnlimpar.setText("Limpar");
btnlimpar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnlimparActionPerformed(evt);
}
});

btnsair.setText("Sair");
btnsair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnsairActionPerformed(evt);
}
});

lblimage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/view/imagens/login.png"))); // NOI18N
lblimage.setText("jLabel3");

btnentrar.setText("Entrar");
btnentrar.setBorder(null);
btnentrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnentrarActionPerformed(evt);
}
});
btnentrar.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
btnentrarKeyPressed(evt);
}
});

jpsenha.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jpsenhaActionPerformed(evt);
}
});
jpsenha.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jpsenhaKeyPressed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(btnentrar, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnlimpar, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnsair, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE))
.addComponent(txtlogin)
.addComponent(jpsenha))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblimage, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(16, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblimage, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtlogin, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(8, 8, 8)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayo
Responder

19/09/2019

Joao Nascimento

Manda o código desse método
btnentrarActionPerformed(evt)
Responder

19/09/2019

Alexsandro Costa

Manda o código desse método
btnentrarActionPerformed(evt)

Bom dia João, desculpa só vi hoje sua resposta, segue abaixo o codigo, eu chamo este metodo no " btnentrarActionPerformed(evt) "

public void logar() {

try {

Class.forName("com.mysql.jdbc.Driver");

// con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Telefonia", "root", "12345");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/advocacia", "root", "531988");

Statement stm = con.createStatement();

String SQL = "Select * from usuario where usuario = '" + txtlogin.getText() + "';";

ResultSet rs = stm.executeQuery(SQL);

if (rs.next()) {

String perfil = rs.getString(5);

String nome = rs.getString(2);

String login = rs.getString(3);

String senha = rs.getString(4);

// lblimage.setIcon(new ImageIcon("imagem_candidato"));
if (txtlogin.getText().equals(login) && new String (jpsenha.getPassword()).equals(senha)) {

lblimage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/view/imagens/login2.png")));

ImageIcon imagem = new ImageIcon(Novo.class.getResource("/br/com/view/imagens/martelo.png"));

JOptionPane.showMessageDialog(
null, "", "",
JOptionPane.INFORMATION_MESSAGE,
imagem);

//JOptionPane.showMessageDialog(null, "Seja bem vindo:");
Tela_Principal principal = new Tela_Principal();

principal.setVisible(true);

if (perfil.equals(rs.getString(5))) {

Tela_Principal.lblUsuario.setText(rs.getString("nome"));
//
// Tela_Principal.lblPerfil.setText(rs.getString("perfil"));
//
// Tela_Principal.lblData.setText(getDateTime());

txtlogin.setText("");

jpsenha.setText("");

txtlogin.requestFocus();



dispose();

}

} else {

JOptionPane.showMessageDialog(null, "Login ou Senha inválidos.");

txtlogin.setText("");

jpsenha.setText("");

txtlogin.requestFocus();

}

}

} catch (SQLException e) {

e.printStackTrace(); //vejamos que erro foi gerado e quem o gerou

JOptionPane.showMessageDialog(null, "Erro na conexão, com o banco de dados!", "!", JOptionPane.WARNING_MESSAGE);

} catch (ClassNotFoundException e) {

e.printStackTrace();

} finally {

try {

con.close();

} catch (SQLException onConClose) {

//System.out.println("Houve erro no fechamento da conexão");
JOptionPane.showMessageDialog(null, "Erro na conexão, com o banco de dados!", "!", JOptionPane.WARNING_MESSAGE);

onConClose.printStackTrace();

}

}

}
Responder

19/09/2019

Joao Nascimento

Coloca no github, vou tentar rodar na minha máquina
Responder

20/09/2019

Alexsandro Costa

Coloca no github, vou tentar rodar na minha máquina

Cara sou mais novato que q o proprio novato, não sei colocar no github
Responder

20/09/2019

Alexsandro Costa

Coloca no github, vou tentar rodar na minha máquina

Cara sou mais novato que q o proprio novato, não sei colocar no github


ja rodei em outras maquina criei uma maquina virtual no virtualbox com o windows 7 para ver se de-repente não era o Windows 10 que estava barrando a aplicação, mais ficou na mesma se só complilar ele roda normal, agora se limpar e contruir ai ele so abre a tela de login ai eu logo ai aparece a msg de bem vindo mais não sai da tela de login
Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar