Bom dia, pessoal
Gostaria de pedir a ajuda de vocês, estou fazendo um trabalho e de um mapa do brasil e que o usuário escolhe o caminho por onde vai passar, mas gostaria que esse caminho ficasse piscando cada estado na sequência.
Tipo: São Paulo a Paraná -> piscaria são paulo, depois santa catarina, depois paraná, e voltava piscando são paulo e assim por diante.
if (btnCalcular.isEnabled() && clique == 2) {
//iniciar = false;
ScrollRota.setVisible(true);
lblInformeQtProd.setVisible(true);
txtQtProd.setVisible(true);
//btnMostrarRota.setEnabled(true);
String resultStr = CalcularRota.getRota(origem, destino);
resultStr = resultStr.replace("[", "").replace("]", "");
String[] lista = resultStr.split(", ");
lblRota.setText("<html><br>Rota Utilizada:<br><br>");
for (String str : lista) { //percorre todos os dados da 'lista' e atribui a 'str'
lblRota.setText(lblRota.getText() + "" + str + "<br>");
if (str.equals("Amazonas")) {
imgAM.setVisible(true);
AM = 2;
}
if (str.equals("Alagoas")) {
imgAL.setVisible(true);
AL = 2;
}
if (str.equals("Amapá")) {
imgAP.setVisible(true);
AP = 2;
}
if (str.equals("Bahia")) {
imgBA.setVisible(true);
BA = 2;
}
if (str.equals("Ceará")) {
imgCE.setVisible(true);
CE = 2;
}
if (str.equals("Distrito Federal")) {
imgDF.setVisible(true);
DF = 2;
}
if (str.equals("Espírito Santo")) {
imgES.setVisible(true);
ES = 2;
}
if (str.equals("Goias")) {
imgGO.setVisible(true);
GO = 2;
}
if (str.equals("Amapá")) {
imgAP.setVisible(true);
AP = 2;
}
if (str.equals("Maranhão")) {
imgMA.setVisible(true);
MA = 2;
}
if (str.equals("Mato Grosso")) {
imgMT.setVisible(true);
MT = 2;
}
if (str.equals("Mato Grosso do Sul")) {
imgMS.setVisible(true);
MS = 2;
}
if (str.equals("Minas Gerais")) {
imgMG.setVisible(true);
MG = 2;
}
if (str.equals("Pará")) {
imgPA.setVisible(true);
PA = 2;
}
if (str.equals("Paraíba")) {
imgPB.setVisible(true);
PB = 2;
}
if (str.equals("Paraná")) {
imgPR.setVisible(true);
PR = 2;
}
if (str.equals("Pernambuco")) {
imgPE.setVisible(true);
PE = 2;
}
if (str.equals("Piauí")) {
imgPI.setVisible(true);
PI = 2;
}
if (str.equals("Rio de Janeiro")) {
imgRJ.setVisible(true);
RJ = 2;
}
if (str.equals("Rio Grande do Norte")) {
imgRN.setVisible(true);
RN = 2;
}
if (str.equals("Rio Grande do Sul")) {
imgRS.setVisible(true);
RS = 2;
}
if (str.equals("Rondônia")) {
imgRO.setVisible(true);
RO = 2;
}
if (str.equals("Roraima")) {
imgRR.setVisible(true);
RR = 2;
}
if (str.equals("Santa Catarina")) {
imgSC.setVisible(true);
SC = 2;
}
if (str.equals("São Paulo")) {
imgSP.setVisible(true);
SP = 2;
}
if (str.equals("Sergipe")) {
imgSE.setVisible(true);
SE = 2;
}
if (str.equals("Tocantins")) {
imgTO.setVisible(true);
TO = 2;
}
}
lblRota.setText(lblRota.getText() + "</html>");
Double resultDouble = CalcularRota.getCusto(origem, destino);
// CRIAR MAIS UM LABEL PARA MOSTRAR OS CUSTOS;
// FAZER BOTAO PISCAR;
// PESQUISAR WIKIPEDIA 27 ESTADOS;
custoTotal = resultDouble;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
resultStr = CalcularRota.getRota(origem, destino);
resultStr = resultStr.replace("[", "").replace("]", "");
lista = resultStr.split(", ");
for (String str : lista) { //percorre todos os dados da 'lista' e atribui a 'str'
System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+str);
if (str.equals("Amazonas") && AM ==2) {
apagarEstados();
imgAM.setVisible(true);
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Alagoas") && AL ==2) {
apagarEstados();
imgAL.setVisible(true);
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Acre") && AC ==2) {
apagarEstados();
imgAC.setVisible(true);
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Amapá")&& AP ==2) {
apagarEstados();
imgAP.setVisible(true);
AP = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Bahia")&& BA ==2) {
apagarEstados();
imgBA.setVisible(true);
BA = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Ceará")&& CE ==2) {
apagarEstados();
imgCE.setVisible(true);
CE = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Distrito Federal")&& DF ==2) {
apagarEstados();
imgDF.setVisible(true);
DF = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Espírito Santo")&& ES ==2) {
apagarEstados();
imgES.setVisible(true);
ES = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Goias")&& GO ==2) {
apagarEstados();
imgGO.setVisible(true);
GO = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Maranhão")&& MA ==2) {
apagarEstados();
imgMA.setVisible(true);
MA = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Mato Grosso")&& MT ==2) {
apagarEstados();
imgMT.setVisible(true);
MT = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Mato Grosso do Sul")&& MS ==2) {
apagarEstados();
imgMS.setVisible(true);
MS = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Minas Gerais")&& MG ==2) {
apagarEstados();
imgMG.setVisible(true);
MG = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Pará")&& PA ==2) {
apagarEstados();
imgPA.setVisible(true);
PA = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Paraíba")&& PB ==2) {
apagarEstados();
imgPB.setVisible(true);
PB = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Paraná")&& PR ==2) {
apagarEstados();
imgPR.setVisible(true);
PR = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Pernambuco")&& PE ==2) {
apagarEstados();
imgPE.setVisible(true);
PE = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Piauí")&& PI ==2) {
apagarEstados();
imgPI.setVisible(true);
PI = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Rio de Janeiro")&& RJ ==2) {
apagarEstados();
imgRJ.setVisible(true);
RJ = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Rio Grande do Norte")&& RN ==2) {
apagarEstados();
imgRN.setVisible(true);
RN = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Rio Grande do Sul")&& RS ==2) {
apagarEstados();
imgRS.setVisible(true);
RS = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Rondônia")&& RO ==2) {
apagarEstados();
imgRO.setVisible(true);
RO = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Roraima")&& RR ==2) {
apagarEstados();
imgRR.setVisible(true);
RR = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Santa Catarina")&& SC ==2) {
apagarEstados();
imgSC.setVisible(true);
SC = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("São Paulo")&& SP ==2) {
apagarEstados();
imgSP.setVisible(true);
SP = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Sergipe")&& SE ==2) {
apagarEstados();
imgSE.setVisible(true);
SE = 2;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (str.equals("Tocantins") && TO==2) {
apagarEstados();
imgTO.setVisible(true);
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Visao.class.getName()).log(Level.SEVERE, null, ex);
}
}
} else {
JOptionPane.showMessageDialog(rootPane, "Para esta ação o programa precisa ser iniciado e ter origem e destino escolhidos.", "Erro", JOptionPane.ERROR_MESSAGE, iconeErro);