Chiedo a Voi esperti di dare un'occhiata a questo codice:
codice:
package graphic;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import database.ConnessioneDatabase;
import utility.ClasseLog;
import utility.readString;
public class GrafDueInsDB extends JDialog implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
// :::::: LEGGO LE STRINGHE PER QUESTA CLASSE ::::::
private readString readIstanza = new readString();
String[] G = readIstanza.leggiSet("0|1|2|3"); //leggo per i SETTAGGI
String[] L = readIstanza.leggiLog("6"); //leggo per il LOG
//LEGGO DATI DAL DATABSE
ConnessioneDatabase istCallDati = new ConnessioneDatabase();
// scrivo il LOG
String datiStazione = istCallDati.InterrogazioneDatabase("archivioDB","elencoStazioni_prova");
//RISOLVO LA STRINGA DATI
String[] contenitore = datiStazione.split("\\#");
String[] nomiStazioni = new String[contenitore.length-1];
String[] codiciList = new String[contenitore.length-1]; <------- ERRORE!!
for (int i=0; i<contenitore.length; i++) {
String[] xyz = contenitore[i+1].split("\\|");
nomiStazioni[i] = xyz[1];
codiciList[i] = xyz[2];
}
//SETTAGGIO VARIABILI
JComboBox<String> nomiList = new JComboBox<String>(nomiStazioni);
JTextField codiciStazioni = new JTextField();
JTextField numeroPersonale = new JTextField();
JTextField numeroComuni = new JTextField();
JButton btnUno = new JButton(G[0]);
JButton btnDue = new JButton("ANNULLA");
String nomeSt = "";
String codSt = "";
String numPer = "";
String numCom = "";
ActionListener selectionListener = new SelectionListener(); <------- ERRORE!!
public GrafDueInsDB(String titolo, String img) {
//PANNELLO CONTENITORE
setTitle(titolo);
setModal(true);
getContentPane().setLayout(new BorderLayout());
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setLocation(375,150);
//PULSANTI
//...OK
ImageIcon iconaPulsanteUno = new ImageIcon("images\\icone\\"+G[1]); // crea un'icona
btnUno.setIcon(iconaPulsanteUno); // imposta l'icona
btnUno.addActionListener(this);
//...ANNULLA
ImageIcon iconaPulsanteDue = new ImageIcon("images\\icone\\"+G[2]); // crea un'icona
btnDue.setIcon(iconaPulsanteDue); // imposta l'icona
btnDue.addActionListener(this);
//JCOMBOBOX:
nomiList.insertItemAt("elenco...",0);
nomiList.setSelectedIndex(0);
nomiList.addActionListener(selectionListener);
//CAMPI TESTO
codiciStazioni.setEditable(false);
codiciStazioni.setHorizontalAlignment(0);
numeroPersonale.setHorizontalAlignment(0);
numeroComuni.setHorizontalAlignment(0);
//PANNELLO INTERNO SX
JPanel panInterSx = new JPanel();
panInterSx.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel immagineUno = new JLabel(new ImageIcon("images\\"+img+".jpg"));
immagineUno.setBorder(BorderFactory.createLineBorder(Color.green));
panInterSx.add(immagineUno);
//PANNELLO INTERNO DX
JPanel panInterDx = new JPanel();
panInterDx.setLayout(new GridLayout(4,2,2,30));
panInterDx.setBorder(BorderFactory.createTitledBorder("INSERIRE I DATI DELLA STAZIONE....."));
panInterDx.add(new JLabel("COMANDO STAZIONE DI: ",JLabel.RIGHT));
panInterDx.add(nomiList);
panInterDx.add(new JLabel("CODICE: ",JLabel.RIGHT));
panInterDx.add(codiciStazioni);
panInterDx.add(new JLabel("NUMERO COMUNI IN GIURISDIZIONE: ",JLabel.RIGHT));
panInterDx.add(numeroComuni);
panInterDx.add(new JLabel("NUMERO PERSONALE DELLA STAZIONE: ",JLabel.RIGHT));
panInterDx.add(numeroPersonale);
//PANNELLO INTERNO
JPanel pannelloInterno = new JPanel();
pannelloInterno.setBorder(BorderFactory.createEmptyBorder(10,4,10,4));
pannelloInterno.setLayout(new FlowLayout());
pannelloInterno.add(panInterSx);
pannelloInterno.add(panInterDx);
//PANNELLO SUD
JPanel pannelloSud = new JPanel();
pannelloSud.setLayout(new FlowLayout(FlowLayout.LEFT));
pannelloSud.add(btnUno);
pannelloSud.add(btnDue);
// PANNELLO CONTENITORE
getContentPane().add(pannelloInterno,BorderLayout.CENTER);
getContentPane().add(pannelloSud,BorderLayout.SOUTH);
pack();
setVisible(true);
}
class SelectionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
int s = cb.getSelectedIndex();
codiciStazioni.setText(codiciList[s-1]);
}
}
public void actionPerformed(ActionEvent ae) {
if(ae.getSource() == btnUno) {
nomeSt = nomiStazioni[nomiList.getSelectedIndex()];
codSt = codiciStazioni.getText();
numCom = numeroComuni.getText();
numPer = numeroPersonale.getText();
} else {
//AZIONE DEL PULSANTE ANNULLA!!!
System.exit(0);
}
dispose();
}
public String[] getData() {
String [] output = new String[4];
output[0] = nomeSt;
output[1] = codSt;
output[2] = numCom;
output[3] = numPer;
return output;
}
}
L'errore che mi viene riportato è questo:
codice:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token ";", { expected after this token
Syntax error, insert "}" to complete Block
Per precisione su due righe mi viene indicato, ripettivamente:
(che ho indicato con la freccia nel codice <-------)
codice:
String[] codiciList = new String[contenitore.length-1]; <------- ERRORE!!
codice:
ActionListener selectionListener = new SelectionListener(); <------- ERRORE!!
Non capisco dov'è l'errore
... e anche cancellando la riga di codice incriminata, l'errore si sposta alla precedente!!!!
Help ME please!!
Grazie.