O meu programa está rodando normalmente dentro do netbeans porém quando tento compilar ele dá esse erro:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: …\JanelaCadastro.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Já dei uma procurada na internet e no caso do deprecated, eu já tirei ele, mas continua dizendo que estou o estou utilizando.
e pelo o que eu vi na internet, parece que esse erro:uses unchecked or unsafe operations, é por causa de ArrayList, mas
nesse caso eu não sei o que fazer, tá dificil
O que eu faço, preciso compilar isso o mais rápido possível!
Aí está o meu código:
[code]public abstract class JanelaCadastro extends javax.swing.JFrame {
public static boolean Fechou = true;
public static boolean abrirConsulta = false;
protected void formatacao() {
this.setLocationRelativeTo(null);
getContentPane().setBackground(Color.white);
ImageIcon icone = new ImageIcon("./src/pctCadastramento/car.png");
setIconImage(icone.getImage());
this.setResizable(false);
}
ArrayList arli = new ArrayList<HashMap<String, Object>>();
boolean editando;
int index = 0;
protected abstract HashMap<String, Object> GetDados();
private ArrayList<String> GetNomesCampos() {
ArrayList retorno = new ArrayList<String>();
HashMap<String, Object> dados = GetDados();
ArrayList<Entry<String, Object>> lista = new ArrayList(dados.entrySet());
for (Entry<String, Object> dado : lista) {
retorno.add(dado.getKey());
}
return retorno;
}
protected ArrayList<Object> GetValoresCampos() {
ArrayList retorno = new ArrayList<Object>();
HashMap<String, Object> dados = GetDados();
ArrayList<Entry<String, Object>> lista = new ArrayList(dados.entrySet());
for (Entry<String, Object> dado : lista) {
retorno.add(dado.getValue());
}
return retorno;
}
protected abstract String GetNomeTabela();
protected void CarregaDados() throws SQLException {
conexao conn = new conexao();
conn.conecta();
conn.executeSQL("SELECT * FROM " + GetNomeTabela());
arli.clear();
while (conn.resultset.next()) {
HashMap<String, Object> mapa = new HashMap<String, Object>();
for (String nomeCampo : GetNomesCampos()) {
mapa.put(nomeCampo, conn.resultset.getObject(nomeCampo));
}
arli.add(mapa);
}
CarregarCombos();
}
protected void CarregaDadosConsulta(String sqlpassado) throws SQLException {
conexao conn = new conexao();
conn.conecta();
conn.executeSQL(sqlpassado);
arli.clear();
while (conn.resultset.next()) {
HashMap<String, Object> mapa = new HashMap<String, Object>();
for (String nomeCampo : GetNomesCampos()) {
mapa.put(nomeCampo, conn.resultset.getObject(nomeCampo));
}
arli.add(mapa);
}
CarregarCombos();
}
protected abstract void CarregarCombos();
protected HashMap<String, Object> Atual() {
if (arli.isEmpty()) {
return null;
} else {
return (HashMap<String, Object>) arli.get(index);
}
}
protected Object Valor(String key) {
try {
return Atual().get(key);
} catch (Exception ex) {
return 0;
}
}
protected void Primeiro() {
index = 0;
}
protected void Ultimo() {
index = arli.size() - 1;
}
protected void Proximo() {
if (index < arli.size() - 1) {
index++;
}
}
protected void Anterior() {
if (index > 0) {
index--;
}
}
protected void Deletar(int codigo, String textoCampoDescricao) {
try {
String sql = "Select * from " + GetNomeTabela() + " where " + GetNomeCampoChave() + " = " + codigo;
conexao conn = new conexao();
conn.conecta();
conn.executeSQL(sql);
conn.resultset.next();
String aviso = "Tem certeza que deseja deletar o registro: " + textoCampoDescricao + "?";
int opcao_escolhida = JOptionPane.showConfirmDialog(null, aviso, "Remover registro", JOptionPane.YES_NO_OPTION);
if (opcao_escolhida == JOptionPane.YES_OPTION) {
sql = "delete from " + GetNomeTabela() + " where " + GetNomeCampoChave() + " = " + codigo;
int conseguiu_excluir = conn.statement.executeUpdate(sql);
if (conseguiu_excluir == 1) {
JOptionPane.showMessageDialog(null, "Excluído com Sucesso!");
CarregaDados();
if (index == arli.size() - 1) {
Atual();
} else {
Anterior();
}
exibir();
}
} else {
return;
}
} catch (SQLException erro) {
JOptionPane.showMessageDialog(null, "Erro ao Excluir!\n" + erro);
}
}
protected void exibir() {
if (Atual() != null) {
mostrarDados();
} else {
limparcampos();
}
}
protected abstract void limparcampos();
protected abstract void mostrarDados();
protected abstract String GetNomeCampoChave();
protected void preencheCombo(JComboBox combo, String tabela, String campoChave, String campoExibicao) {
conexao conn = new conexao();
conn.conecta();
conn.executeSQL("SELECT * FROM " + tabela + " ORDER BY " + campoExibicao);
combo.removeAllItems();
try {
while (conn.resultset.next()) {
combo.addItem(new Pair<Integer, String>(conn.resultset.getInt(campoChave), "<html><font color=black>" + conn.resultset.getString(campoExibicao) + "</font></html>"));
}
} catch (SQLException ex) {
Logger.getLogger(JanelaCadastro.class.getName()).log(Level.SEVERE, null, ex);
}
}
protected void selecionaCombo(JComboBox combo, int codigo) {
for (int i = 0; i < combo.getItemCount(); i++) {
if (((Entry<Integer, String>) combo.getItemAt(i)).getKey() == codigo) {
combo.setSelectedIndex(i);
break;
}
}
}
protected int getValorCombo(JComboBox combo) {
try {
return ((Pair<Integer, String>) combo.getSelectedItem()).getKey();
} catch (Exception ex) {
return 0;
}
}
protected void Salvar() {
conexao conn = new conexao();
conn.conecta();
HashMap<String, Object> mapa = GetDados();
Integer codigo = (Integer) mapa.get(GetNomeCampoChave());
ArrayList<Entry<String, Object>> dados = new ArrayList(mapa.entrySet());
if (!editando) // NOVO
{
String insertSQL = "INSERT INTO " + GetNomeTabela() + "(" + GetNomeCampoChave();
for (Entry<String, Object> dado : dados) {
if (dado.getKey() == GetNomeCampoChave()) {
continue;
}
insertSQL += "," + dado.getKey();
}
insertSQL += ") VALUES(" + codigo;
for (Entry<String, Object> dado : dados) {
if (dado.getKey() == GetNomeCampoChave()) {
continue;
}
insertSQL += "," + FormataValorParaSQL(dado.getValue());
}
insertSQL += ")";
conn.executeUpdate(insertSQL);
index = arli.size();
} else {
String insertSQL = "Update " + GetNomeTabela();
boolean primeiro = true;
for (Entry<String, Object> dado : dados) {
if (dado.getKey().equals(GetNomeCampoChave())) {
continue;
}
if (primeiro) {
primeiro = false;
insertSQL += " Set ";
} else {
insertSQL += ",";
}
insertSQL += dado.getKey() + " = " + FormataValorParaSQL(dado.getValue());
}
insertSQL += " Where " + GetNomeCampoChave() + " = " + codigo;
conn.executeUpdate(insertSQL);
Atual();
}
try {
CarregaDados();
} catch (SQLException ex) {
Logger.getLogger(CadastroMarca.class.getName()).log(Level.SEVERE, null, ex);
}
exibir();
habilitarbotoes();
desabilitarcampos();
}
}[/code]
Desde já agradeço!!!