1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
| public void actionPerformed(ActionEvent aActionEvent) {
String action = aActionEvent.getActionCommand();
//String chemin = racine();
//String racine = Document.getRootElement();
if(action.equals("Configurer")) // BOUTON CONFIGURER ( menu ) OUVRE LE JFC
{
if(this.chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
{
this.textChemin.setText(this.chooser.getSelectedFile().getAbsolutePath());
JOptionPane pane = new JOptionPane();
int option = JOptionPane.showConfirmDialog(null, "Sauvegarder la configuration actuelle ? ", "INFORMATION", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
pane.show();
if (option == JOptionPane.OK_OPTION)
{
System.out.println("sauvegarder"); // DEMANDE DE SAUVEGARDE DE L'EMPLACEMENT
j = 1;
System.out.println(j);
//JOptionPane pane2 = new JOptionPane();
JOptionPane.showMessageDialog(null, "Sauvegarde avec succès !", "Information", JOptionPane.INFORMATION_MESSAGE); // Fichier bien enregistrer
JOptionPane.showMessageDialog(null, "Le chemin d'accès à été enregistrer avec succès à l'emplacement : "+textChemin.getText() , "INFORMATION", JOptionPane.INFORMATION_MESSAGE); // Information emplacement
{
// CREATION DU FICHIER XML ICI
System.out.println("Création du fichier XML et sauvegarde de l'emplacement de l'executable à l'interieur");
XMLEncoder encoder = null;
try {
encoder = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("config.xml")));;
encoder.writeObject(textChemin); // STOCKAGE DE L'EMPLACEMENT DANS LE FICHIER XML
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
finally {
encoder.close();
}
}
}
else {
System.out.println("ne pas sauvegarder");
j = 0;
System.out.println(j);
}
}
}
if(action.equals("boutonTest")) // IDEM QU'AU DESSU
{
try
{
// ICI UTILISATION DE LA VARIABLE (chemin) issue de la classe MyTools
Runtime.getRuntime().exec(new String[] {(chemin), "C:\\Users\\pendoRa\\Music\\son\\LIFE.mp3" }) ;
// test avec fichier audio "C:\\Users\\pendoRa\\Music\\son\\LIFE.mp3"
// "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u"
// http://pendora.fr.nf:8000/listen.pls
}
catch (IOException aIOException)
{
JOptionPane.showMessageDialog(this, aIOException.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);
}
}
if(action.equals("Connexion")) // BOUTON CONNEXION LANCEMENT DE L'APPLI CHOISI PAR L'UTILISATEUR + Injection de L'URL
{
try
{
Runtime.getRuntime().exec(new String[] {this.textChemin.getText(), "C:\\Users\\pendoRa\\Music\\son\\LIFE.mp3" }) ;
// test avec fichier audio "C:\\Users\\pendoRa\\Music\\son\\LIFE.mp3"
// http://pendora.fr.nf:8000/listen.pls
}
catch (IOException aIOException)
{
JOptionPane.showMessageDialog(this, aIOException.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);
}
}
if(action.equals("boutonOK")) // IDEM QU'AU DESSU
{
try
{
Runtime.getRuntime().exec(new String[] {this.textChemin.getText(), "C:\\Users\\pendoRa\\Music\\son\\LIFE.mp3" }) ;
// test avec fichier audio "C:\\Users\\pendoRa\\Music\\son\\LIFE.mp3"
// "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u"
// http://pendora.fr.nf:8000/listen.pls
}
catch (IOException aIOException)
{
JOptionPane.showMessageDialog(this, aIOException.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);
}
}
if(action.equals("sauvegarder")) // BOUTON SAUVEGARDER CONFIGURATION ACTUELLE
{
if(j==0)
{
System.out.println("Aucun Lecteur Multimedia enregistré...");
}
if(j==1)
System.out.println(chemin);
}
{
// CREATION DU FICHIER XML ICI
System.out.println("Création du fichier XML et sauvegarde de l'emplacement de l'executable à l'interieur");
XMLEncoder encoder = null;
try {
encoder = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("config.xml")));;
encoder.writeObject(textChemin);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
finally {
encoder.close();
}
} |