sido722
Messages postés6Date d'inscriptionvendredi 9 juillet 2004StatutMembreDernière intervention16 juillet 2004
-
9 juil. 2004 à 15:32
sido722
Messages postés6Date d'inscriptionvendredi 9 juillet 2004StatutMembreDernière intervention16 juillet 2004
-
9 juil. 2004 à 16:51
Mon erreur
Mafenetre4.java:181: tests(java.io.File) in Mafenetre4 cannot be applied to (java.lang.String)
tests(file.getAbsolutePath());
^
L'erreur est entouré de ***********************************************************************************
Mon programme
class Mafenetre4 extends JFrame implements ActionListener{
//GrapheEvent trace = new GrapheEvent(this);
JFileChooser fc = new JFileChooser();
JPanel row0 = new JPanel();
JLabel debut = new JLabel("Bienvenue au LCP-GRAPHEUR :");
// définition de la première ligne
JPanel row1 = new JPanel();
JLabel fichierLabel = new JLabel("Nom du Fichier :",JLabel.LEFT);
JTextField fichier = new JTextField(JLabel.LEFT);
// définition de la première ligne bis
JPanel row1b = new JPanel();
JButton okButton = new JButton("OK");
JTextArea fichierarea = new JTextArea(10, 20);
// définition de la deuxième ligne
JPanel row2 = new JPanel();
ButtonGroup option = new ButtonGroup();
JCheckBox courbe = new JCheckBox("Courbe", true);
JCheckBox surf = new JCheckBox("Surface", false);
// définition de la troisième ligne
JPanel row3 = new JPanel();
JLabel nbcLabel = new JLabel(" Nombre de courbes", JLabel.RIGHT);
JTextField nbcourbes = new JTextField();
//System.out.println(texte);
while (texte != null)
{
texte = li.readLine();
if (texte == null) {
System.out.println(finentete); break;}
//System.out.println(texte);
StringTokenizer st = new StringTokenizer(texte, " ");
while (st.hasMoreTokens()) {
it = st.nextToken();
va[a] = Double.parseDouble(it);
a++;
//System.out.println(va);
}
}
li.close();
a = a - 1;
System.out.println(va[a]);
} // fin if
public static void Traitement(String li) {
//System.out.println("ds traitement");
int pos = 0;
pos = li.indexOf("=");
String spefi = "";
String valeur = "";
int ind_x[] = {'0', '0', '0', '0'};
int dim_x[] = {'0', '0', '0', '0'};
int ndim;
int nbcol;
char c; // indices temporaire des ind_x et dim_x
String label;//titre
String tlabel[] = new String[4];//initialisation
int k;
if (pos != -1) {
if (pos < li.length()) {
int tailleli = li.length();// longueur de la ligne
//System.out.println(tailleli);spefi li.substring(0, pos-1);// sous chaine avant ss espace
//System.out.println(spefi);valeur li.substring(pos+2, tailleli);// sous chaine ap ss espac
//System.out.println(valeur);
if (spefi.equals("ndim")) { // on a trouve ndim
ndim = Integer.parseInt(valeur);// converti ssch droite int
//System.out.println("ds if ndim "+ ndim);
}
else if (spefi.equals("nbcol")) {
nbcol = Integer.parseInt(valeur);
//System.out.println("ds if nbcol "+ nbcol);
}
else if (spefi.startsWith("ind_x")) { // ssch commence par "
c = spefi.charAt(6);// recupere 7eme caractere 6+1
int intc = (int)c;// converti en int
intc = intc - 48; //char 'A';
//System.out.println("c= "+c +"= "+ intc);
ind_x[intc] = Integer.parseInt(valeur);
System.out.println("ind_x(c) "+ ind_x[intc]);
}
else if (spefi.startsWith("dim_x")) {
c = spefi.charAt(6);
int intc = (int)c;
intc = intc - 48;
dim_x[intc] = Integer.parseInt(valeur);
System.out.println("dim_x "+ dim_x[intc]);
}
else if (spefi.startsWith("label(")) {
c = spefi.charAt(6);
int intc = (int)c;
//System.out.println("c intc"+c+" "+intc);
intc = intc - 48;
//System.out.println("c= "+c+" "+intc);
tlabel[intc] = valeur;
System.out.println("tlabel( "+ valeur);
}
} // FIN IF LI.LENGTH
} // FIN IF POS
// cohérence de l'entête
for (k = 0; k < 4; k++){
if (((ind_x[k]== 0) && (dim_x[k]!= 0))||((ind_x[k]!= 0)
&& (dim_x[k]== 0)))
System.out.println("L'entete de votre fichier est mal défini");
}
} // fin Traitement de l'entete
public void actionPerformed(ActionEvent event){
if (event.getSource() == okButton){
System.out.println("fichier channely");
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
System.out.println("fichier channely");
fichierarea.append("Opening: " + file.getName() + ".");
***********tests(file.getAbsolutePath());*********************************************************************
} // fin showopen
} // fin getsource
//String commande = event.getActionCommand();
// if (commande == "channely2"){
//champ.getText("chan"));
} // fin actionPerformed
FlowLayout layout0 = new FlowLayout(FlowLayout.CENTER);// titre
row0.setLayout(layout0);
row0.add(debut);
pane.add(row0);
// caractérisation de la première ligne
GridLayout layout1 = new GridLayout(1, 1, 0, 2);
row1.setLayout(layout1);
row1.add(fichierLabel);
row1.add(fichier);
pane.add(row1);
// caractérisation de la première ligne bis
GridLayout layout1b = new GridLayout(1, 2, 0, 2);
row1b.setLayout(layout1b);
row1b.add(okButton);
fichierarea.setEditable(false);
row1b.add(fichierarea);
pane.add(row1b);
// caractérisation de la deuxière ligne
FlowLayout layout2 = new FlowLayout(FlowLayout.LEFT,0, 2);
option.add(courbe);
option.add(surf);
row2.setLayout(layout2);
row2.add(courbe);
row2.add(surf);
pane.add(row2);
// caractérisation de la troisière ligne