qhhu
Messages postés66Date d'inscriptionvendredi 16 décembre 2005StatutMembreDernière intervention21 octobre 2009
-
5 févr. 2006 à 22:33
qhhu
Messages postés66Date d'inscriptionvendredi 16 décembre 2005StatutMembreDernière intervention21 octobre 2009
-
6 févr. 2006 à 17:04
Salut
Voila j'ai fait un petit programme qui permet de transcrypter des fichiers au format voulu.
Pour ca j'utilise un CardLayout.
Seulement voila quant je compile le fichier, pas de problème, quand je l'exécute non plus mais quand j'appuie sur le boutton Suivant,
j'obtient un java.lang.IllegalArgumentException : wrong parent for CardLayout.
J'ai essayé plein de choses mais ca marche toujours pas.
Le programme n'est pas treminé vu qu'il se contente de stoker les bytes dans un tableau mais vous pouriez jeter un
petit coup d'oeil sur le code SVP Merci
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class convert extends JFrame implements ActionListener{
ImageIcon suivant_img = new ImageIcon("suivant.jpg");
ImageIcon precedent_img = new ImageIcon("precedent.jpg");
JButton[] suivant = new JButton[4];
JButton[] precedent = new JButton[4];
CardLayout cards = new CardLayout();
int currentCard=0;
JLabel in_lab = new JLabel("1. Choisissez le fichier à convertir :");
JTextField in_field = new JTextField(20);
JButton parcourir = new JButton("Parcourir...");
JLabel format_lab = new JLabel("2. Sélectionnez le format de sortie :");
JComboBox format_box = new JComboBox();
String formats[] = {"mp3","wave","wma","midi"};
String formats2[] = {"mp3","wav","wma","mid"};
JLabel out_lab = new JLabel("3. Choisissez l'endroit ou enregistrer le fichier converti :");
JTextField out_field = new JTextField(20);
JButton parcourir2 = new JButton("Parcourir...");
JButton convertir = new JButton("Convertir");
JTextArea information = new JTextArea(10,30);
JScrollPane bbu=new JScrollPane(information, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
public convert(){
super("Convertisseur");
setDefaultCloseOperation(EXIT_ON_CLOSE);
for (int i=0; i < formats.length; i++){
format_box.addItem(formats[i]);
}
JPanel[] pane= new JPanel[4];
parcourir.addActionListener(this);
convertir.addActionListener(this);
pane[0] = new JPanel();
pane[0].add(in_lab);
pane[0].add(in_field);
pane[0].add(parcourir);
pane[1] = new JPanel();
pane[1].add(format_lab);
pane[1].add(format_box);
pane[2] = new JPanel();
pane[2].add(out_lab);
pane[2].add(out_field);
parcourir2.addActionListener(this);
pane[2].add(parcourir2);
pane[3] = new JPanel();
pane[3].add(convertir);
information.setEditable(false);
Color g = new Color(215,215,215);
information.setBackground(g);
information.setFont(new Font("Lucida Console",Font.PLAIN,11));
pane[3].add(bbu);
Twinuts
Messages postés5375Date d'inscriptiondimanche 4 mai 2003StatutModérateurDernière intervention14 juin 2023111 5 févr. 2006 à 23:22
Sinon le parent ne peut pas etre une JFrame mais getContnentPane, enfin
vu qu getContentPane ne te retourne pas un JPanel je te conseil plus de
faire un JPanel intermediaire qui lui va avoir le layout avec un
CardLayout