TP
This commit is contained in:
BIN
DEV2.1/TP09/01_Volume/Cercle.class
Normal file
BIN
DEV2.1/TP09/01_Volume/Cercle.class
Normal file
Binary file not shown.
30
DEV2.1/TP09/01_Volume/Cercle.java
Normal file
30
DEV2.1/TP09/01_Volume/Cercle.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Cercle extends JComponent {
|
||||
|
||||
private Color fond;
|
||||
|
||||
public Cercle(Color fond) {
|
||||
this.fond = fond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
|
||||
if (this.isOpaque()) {
|
||||
pinceau.setColor(this.getBackground());
|
||||
pinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
pinceau.setColor(Color.DARK_GRAY);
|
||||
pinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
pinceau.setColor(this.fond);
|
||||
pinceau.fillOval(this.getWidth()/4, this.getHeight()/4, this.getWidth()/2, this.getHeight()/2);
|
||||
}
|
||||
|
||||
public void setFond(Color n) {
|
||||
this.fond = n;
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP09/01_Volume/Fenetre.class
Normal file
BIN
DEV2.1/TP09/01_Volume/Fenetre.class
Normal file
Binary file not shown.
29
DEV2.1/TP09/01_Volume/Fenetre.java
Normal file
29
DEV2.1/TP09/01_Volume/Fenetre.java
Normal file
@@ -0,0 +1,29 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
public Fenetre() {
|
||||
this.setSize(700, 100);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new GridLayout(1, 10));
|
||||
|
||||
Cercle[] tabCercles = new Cercle[10];
|
||||
|
||||
for (int i = 0; i != 5; i++) {
|
||||
Cercle nouveauCercle = new Cercle(Color.ORANGE);
|
||||
this.add(nouveauCercle);
|
||||
tabCercles[i] = nouveauCercle;
|
||||
}
|
||||
|
||||
for (int i = 5; i != 10; i++) {
|
||||
Cercle nouveauCercle = new Cercle(Color.LIGHT_GRAY);
|
||||
this.add(nouveauCercle);
|
||||
tabCercles[i] = nouveauCercle;
|
||||
}
|
||||
|
||||
MoletteSouris gestionSouris = new MoletteSouris(this, tabCercles);
|
||||
this.addMouseWheelListener(gestionSouris);
|
||||
}
|
||||
|
||||
}
|
BIN
DEV2.1/TP09/01_Volume/Main.class
Normal file
BIN
DEV2.1/TP09/01_Volume/Main.class
Normal file
Binary file not shown.
6
DEV2.1/TP09/01_Volume/Main.java
Normal file
6
DEV2.1/TP09/01_Volume/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP09/01_Volume/MoletteSouris.class
Normal file
BIN
DEV2.1/TP09/01_Volume/MoletteSouris.class
Normal file
Binary file not shown.
38
DEV2.1/TP09/01_Volume/MoletteSouris.java
Normal file
38
DEV2.1/TP09/01_Volume/MoletteSouris.java
Normal file
@@ -0,0 +1,38 @@
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class MoletteSouris implements MouseWheelListener {
|
||||
|
||||
private Fenetre fenetre;
|
||||
private Cercle[] tabCercles;
|
||||
private int depart;
|
||||
|
||||
public MoletteSouris(Fenetre fenetre, Cercle[] tabCercles) {
|
||||
this.fenetre = fenetre;
|
||||
this.tabCercles = tabCercles;
|
||||
this.depart = 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent evenement) {
|
||||
int sensRotation = evenement.getWheelRotation();
|
||||
this.depart -= sensRotation;
|
||||
|
||||
if (this.depart == 11) {
|
||||
this.depart = 10;
|
||||
}
|
||||
else if (this.depart == -1) {
|
||||
this.depart = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.depart ; i++) {
|
||||
this.tabCercles[i].setFond(Color.ORANGE);
|
||||
}
|
||||
for (int i = this.depart; i < 10; i++) {
|
||||
this.tabCercles[i].setFond(Color.LIGHT_GRAY);
|
||||
}
|
||||
this.fenetre.repaint();
|
||||
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP09/02_Playlist/Fenetre.class
Normal file
BIN
DEV2.1/TP09/02_Playlist/Fenetre.class
Normal file
Binary file not shown.
34
DEV2.1/TP09/02_Playlist/Fenetre.java
Normal file
34
DEV2.1/TP09/02_Playlist/Fenetre.java
Normal file
@@ -0,0 +1,34 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
public Fenetre() {
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new GridLayout(14, 1));
|
||||
|
||||
JLabel[] chromakopia = {
|
||||
new JLabel("St. Chroma"),
|
||||
new JLabel("Rah Tah Tah"),
|
||||
new JLabel("Noid"),
|
||||
new JLabel("Darling, I"),
|
||||
new JLabel("Hey Jane"),
|
||||
new JLabel("I Killed You"),
|
||||
new JLabel("Judge Judy"),
|
||||
new JLabel("Sticky"),
|
||||
new JLabel("Take Your Mask Off"),
|
||||
new JLabel("Tomorrow"),
|
||||
new JLabel("Thought I Was Dead"),
|
||||
new JLabel("Like Him"),
|
||||
new JLabel("Balloon"),
|
||||
new JLabel("I Hope You Find Your Way Home")
|
||||
};
|
||||
|
||||
for (JLabel titre : chromakopia) {
|
||||
this.addMouseListener(new GestionSouris(titre));
|
||||
this.add(titre);
|
||||
}
|
||||
|
||||
this.pack();
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP09/02_Playlist/GestionSouris.class
Normal file
BIN
DEV2.1/TP09/02_Playlist/GestionSouris.class
Normal file
Binary file not shown.
33
DEV2.1/TP09/02_Playlist/GestionSouris.java
Normal file
33
DEV2.1/TP09/02_Playlist/GestionSouris.java
Normal file
@@ -0,0 +1,33 @@
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class GestionSouris implements MouseListener {
|
||||
|
||||
private JLabel titre;
|
||||
|
||||
public GestionSouris(JLabel titre) {
|
||||
this.titre = titre;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent evenement) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent evenement){
|
||||
this.titre.setOpaque(true);
|
||||
this.titre.setBackground(Color.CYAN);
|
||||
this.titre.repaint();
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent evenement){
|
||||
this.titre.setOpaque(true);
|
||||
this.titre.setBackground(Color.WHITE);
|
||||
this.titre.repaint();
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent evenement){
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent evenement){
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP09/02_Playlist/Main.class
Normal file
BIN
DEV2.1/TP09/02_Playlist/Main.class
Normal file
Binary file not shown.
6
DEV2.1/TP09/02_Playlist/Main.java
Normal file
6
DEV2.1/TP09/02_Playlist/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user