CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

Help Java'sCool

Jermi95
Jermi95
Niveau 7
01 juin 2014 à 23:00:01

Salut les gens, j'ai mon oral d'isn mardi, on a quasiment fini notre projet de programmation, un simulateur de batterie, sur Java'scool.

Et il nous reste 2 problèmes : Le premier truc, c'est qu'on essaie d'ouvrir une image dans une nouvelle fenêtre, la fenetre s'ouvre, mais pas l'image ! (ou plutot, elle le fait plus, pendant un moment ça marchait, puis là ben ça marche pu ^^').
Le 2ème truc qu'on voudrait ajouter, c'est un timer, pour faire en sorte que l'image qui apparait en cliquant ne reste qu'une demi seconde.

Voilà le code, si vous avez des questions bien sûr jsuis là.

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import javax.swing.JFrame;
import javax.swing.JPanel;

import java.awt.Graphics;
import java.awt.Image;

import javax.swing.*;
import java.awt.event. *;
import org.javascool.proglets.syntheSons.FileSoundBit;

public class Panneau extends JPanel {
public void paintComponent(Graphics g){
try {
Image img = ImageIO.read(new File("C:/Users/jeremi/Desktop/Accueil.jpg"));
//Pour une image de fond
g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
} catch (IOException e) {
e.printStackTrace();
}
}
}

public class Fenetre extends JFrame {
Panneau arriere_plan_menu;

public Fenetre(){
//JButton bouton_play, bouton_regles;
this.setTitle("Jouons à la batterie !");
this.setSize(1065, 737);
this.setResizable(false);

this.arriere_plan_menu = new Panneau ();
this.add(arriere_plan_menu);

JPanel b3 = new JPanel();

this.getContentPane().add(b3);
this.setVisible(true);

this.arriere_plan_menu = new Panneau ();
this.add(arriere_plan_menu);
}
}

FileSoundBit TomBass = new FileSoundBit();
FileSoundBit LowTom = new FileSoundBit();
FileSoundBit MidTom = new FileSoundBit();
FileSoundBit GCaisse = new FileSoundBit();
FileSoundBit CClaire = new FileSoundBit();
FileSoundBit Ride = new FileSoundBit();
FileSoundBit Crash = new FileSoundBit();
FileSoundBit Charleston = new FileSoundBit();

JLabel img_change_TomBass;
JLabel img_change_LowTom;
JLabel img_change_MidTom;
JLabel img_change_GCaisse;
JLabel img_change_CClaire;
JLabel img_change_Ride;
JLabel img_change_Crash;
JLabel img_change_Charleston;

void main(){
Fenetre a = new Fenetre();
JLayeredPane frame = getPane();

int n = JOptionPane.showConfirmDialog(frame, "Vous voulez jouez un morceau ?", "Confirmation", JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION) {
JOptionPane.showMessageDialog(frame, "Let's rock !!");

TomBass.reset("C:/Users/jeremi/Desktop/ProjetFina
l/Sons/TomBass.wav");

LowTom.reset("C:/Users/jeremi/Desktop/ProjetFinal
/Sons/LowTom.wav");

MidTom.reset("C:/Users/jeremi/Desktop/ProjetFinal
/Sons/MidTom.wav");

GCaisse.reset("C:/Users/jeremi/Desktop/ProjetFina
l/Sons/GCaisse.wav");

CClaire.reset("C:/Users/jeremi/Desktop/ProjetFina
l/Sons/CClaire.wav");

Ride.reset("C:/Users/jeremi/Desktop/ProjetFinal/S
ons/Ride.wav");

Crash.reset("C:/Users/jeremi/Desktop/ProjetFinal/
Sons/Crash.wav");

Charleston.reset("C:/Users/jeremi/Desktop/ProjetF
inal/Sons/Charleston.wav");

getPane().removeAll();
getPane().setBackground(java.awt.Color.BLACK);
showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Ima
ges/Batterie.png",
0, 0, 1);
getPane().addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {

if((e.getX() > 650) && (e.getX() < 930) && (e.getY() > 405) && (e.getY() < 505)) {
img_change_TomBass = showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Imag
es/TomBass.jpg",0,
0, 1);
try { Thread.sleep(500); } catch (InterruptedException f) { }
TomBass.play();
//getPane().removeAll();
}

if((e.getX() > 292) && (e.getX() < 497) && (e.getY() > 155) && (e.getY() < 269)) {
img_change_LowTom = showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Imag
es/LowTom.jpg",0,
0, 1);
LowTom.play();
}
if((e.getX() > 545) && (e.getX() < 740) && (e.getY() > 170) && (e.getY() < 270)) {
img_change_MidTom = showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Imag
es/MidTom.jpg",0,
0, 1);
MidTom.play();
}
if((e.getX() > 350) && (e.getX() < 660) && (e.getY() > 440) && (e.getY() < 750)) {
img_change_GCaisse = showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Imag
es/GCaisse.jpg",0,
0, 1);
GCaisse.play();
}
if((e.getX() > 245) && (e.getX() < 475) && (e.getY() > 340) && (e.getY() < 400)) {
img_change_CClaire = showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Imag
es/CClaire.jpg",0,
0, 1);
CClaire.play();
}
if((e.getX() > 746) && (e.getX() < 1000) && (e.getY() > 10) && (e.getY() < 180)) {
img_change_Ride = showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Imag
es/Ride.jpg",0,
0, 1);
Ride.play();
}
if((e.getX() > 60) && (e.getX() < 330) && (e.getY() > 10) && (e.getY() < 180)) {
img_change_Crash = showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Imag
es/Crash.jpg",0,
0, 1);
Crash.play();
}
if((e.getX() > 19) && (e.getX() < 248) && (e.getY() > 252) && (e.getY() < 328)) {
img_change_Charleston = showIcon("C:/Users/jeremi/Desktop/ProjetFinal/Imag
es/Charleston.jpg",0,
0, 1);
Charleston.play();
}

}
}
);

//traitement à appliquer si l'on répond "Oui".
} else if (n == JOptionPane.NO_OPTION) {
JOptionPane.showMessageDialog(frame, "Une autre fois peut-être !");
getPane().removeAll();
getPane().setBackground(java.awt.Color.BLACK);
showIcon("C:/Users/jeremi/images/1.jpg", 0, 0, 1);

}
//showIcon("E:/Documents Benoît/Travail ISN/Formation personnelle/RondRose.jpeg", 0, 0, 2);
}

Jermi95
Jermi95
Niveau 7
01 juin 2014 à 23:29:29

:up:

Pseudo supprimé
Pseudo supprimé 02 juin 2014 à 03:47:07

pastebin.com

Jermi95
Jermi95
Niveau 7
02 juin 2014 à 19:36:03

<script src="http://pastebin.com/embed_js.php?i=gd1URtUc">
</script>

Jermi95
Jermi95
Niveau 7
02 juin 2014 à 19:36:35

Il connaissent pas Java'scool :'{

SuisHateFull
SuisHateFull
Niveau 7
03 juin 2014 à 13:12:18

Franchement l'auteur....

SuisHateFull
SuisHateFull
Niveau 7
03 juin 2014 à 13:13:16

Non mais sérieusement....

SuisHateFull
SuisHateFull
Niveau 7
03 juin 2014 à 13:14:01

Voilà quoi....

SuisHateFull
SuisHateFull
Niveau 7
03 juin 2014 à 13:16:32

http://pastebin.com/embed_js.php?i=gd1URtUc voila le vrai lien...

Franchement quoi.....

Sous forums
  • Aide à l'achat Mac
  • Création de sites web
  • Création de Jeux
  • Linux
  • Programmation
  • Internet
  • Steam Deck
  • Macintosh
  • Hardware
La vidéo du moment