a
This commit is contained in:
BIN
APL2.1/TP9_Evenements(suite)/Cercle.class
Normal file
BIN
APL2.1/TP9_Evenements(suite)/Cercle.class
Normal file
Binary file not shown.
38
APL2.1/TP9_Evenements(suite)/Cercle.java
Normal file
38
APL2.1/TP9_Evenements(suite)/Cercle.java
Normal file
@@ -0,0 +1,38 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Cercle extends JComponent{
|
||||
|
||||
private int volume;
|
||||
|
||||
public Cercle(){
|
||||
super();
|
||||
this.volume=0;
|
||||
}
|
||||
|
||||
public void setVolume(int volume){
|
||||
this.volume=volume;
|
||||
}
|
||||
|
||||
protected void paintComponent(Graphics pinceau){
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
if (this.isOpaque()){
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
secondPinceau.setColor(Color.BLACK);
|
||||
secondPinceau.fillRect(0,0,this.getWidth(), this.getHeight());
|
||||
|
||||
secondPinceau.setColor(Color.YELLOW);
|
||||
for(int i=0;i<this.volume;i++){
|
||||
secondPinceau.fillOval(100*i,50,50,50);
|
||||
}
|
||||
|
||||
secondPinceau.setColor(Color.GRAY);
|
||||
for(int i=0;i<10-this.volume;i++){
|
||||
secondPinceau.fillOval(100*i+this.volume*100,50,50,50);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
APL2.1/TP9_Evenements(suite)/Ex1.java
Normal file
22
APL2.1/TP9_Evenements(suite)/Ex1.java
Normal file
@@ -0,0 +1,22 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Ex1
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
JFrame fenetre = new JFrame();
|
||||
|
||||
fenetre.setSize(520, 90);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
Volume vol = new Volume();
|
||||
VolumeListener volListener = new VolumeListener(vol);
|
||||
|
||||
fenetre.add(vol, BorderLayout.CENTER);
|
||||
fenetre.addMouseWheelListener(volListener);
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
7
APL2.1/TP9_Evenements(suite)/Ex2.java
Normal file
7
APL2.1/TP9_Evenements(suite)/Ex2.java
Normal file
@@ -0,0 +1,7 @@
|
||||
public class Ex2
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Playlist pl = new Playlist();
|
||||
}
|
||||
}
|
||||
BIN
APL2.1/TP9_Evenements(suite)/Playlist.class
Normal file
BIN
APL2.1/TP9_Evenements(suite)/Playlist.class
Normal file
Binary file not shown.
44
APL2.1/TP9_Evenements(suite)/Playlist.java
Normal file
44
APL2.1/TP9_Evenements(suite)/Playlist.java
Normal file
@@ -0,0 +1,44 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Playlist{
|
||||
|
||||
public static void main(String[] args) {
|
||||
Image logoAD=Toolkit.getDefaultToolkit().getImage("logoAD.png");
|
||||
|
||||
JFrame fenetre = new JFrame("Playlist");
|
||||
fenetre.setIconImage(logoAD);
|
||||
fenetre.setSize(300,500);
|
||||
fenetre.setResizable(false);
|
||||
fenetre.setLocation(50,50);
|
||||
fenetre.setVisible(true);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
//label
|
||||
PlaylistListener labelListener = new PlaylistListener();
|
||||
JLabel piste1 = new JLabel("piste1");
|
||||
piste1.addMouseListener(labelListener);
|
||||
JLabel piste2 = new JLabel("piste2");
|
||||
piste2.addMouseListener(labelListener);
|
||||
JLabel piste3 = new JLabel("piste3");
|
||||
piste3.addMouseListener(labelListener);
|
||||
JLabel piste4 = new JLabel("piste4");
|
||||
piste4.addMouseListener(labelListener);
|
||||
JLabel piste5 = new JLabel("piste5");
|
||||
piste5.addMouseListener(labelListener);
|
||||
JLabel piste6 = new JLabel("piste6");
|
||||
piste6.addMouseListener(labelListener);
|
||||
JLabel piste7 = new JLabel("piste7");
|
||||
piste7.addMouseListener(labelListener);
|
||||
JLabel piste8 = new JLabel("piste8");
|
||||
piste8.addMouseListener(labelListener);
|
||||
JLabel piste9 = new JLabel("piste9");
|
||||
piste9.addMouseListener(labelListener);
|
||||
JLabel piste10 = new JLabel("piste10");
|
||||
piste10.addMouseListener(labelListener);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
31
APL2.1/TP9_Evenements(suite)/PlaylistListener.java
Normal file
31
APL2.1/TP9_Evenements(suite)/PlaylistListener.java
Normal file
@@ -0,0 +1,31 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class PlaylistListener implements MouseListener {
|
||||
private JLabel label;
|
||||
|
||||
|
||||
public void mouseClicked(MouseEvent evenement){ // un bouton cliqué
|
||||
//SURLIGNE EN BLEU LE LABEL
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent evenement){ // debut du survol
|
||||
Object objetTemp=evenement.getSource();
|
||||
this.label=objetTemp.clone();
|
||||
this.label.setBackground(Color.CYAN);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent evenement){ // fin du survol
|
||||
this.label.setBackground(Color.WHITE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//INUTILE DANS NOTRE CAS
|
||||
|
||||
public void mousePressed(MouseEvent evenement){} // un bouton appuyé
|
||||
public void mouseReleased(MouseEvent evenement){} // un bouton relâché
|
||||
|
||||
}
|
||||
BIN
APL2.1/TP9_Evenements(suite)/Volume.class
Normal file
BIN
APL2.1/TP9_Evenements(suite)/Volume.class
Normal file
Binary file not shown.
28
APL2.1/TP9_Evenements(suite)/Volume.java
Normal file
28
APL2.1/TP9_Evenements(suite)/Volume.java
Normal file
@@ -0,0 +1,28 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Volume{
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Image logoAD=Toolkit.getDefaultToolkit().getImage("logoAD.png");
|
||||
|
||||
JFrame fenetre = new JFrame("Volume");
|
||||
fenetre.setSize(1000,200);
|
||||
fenetre.setLocation(100,500);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.setIconImage(logoAD);
|
||||
|
||||
Cercle dessinCercle = new Cercle();
|
||||
|
||||
|
||||
volumeListener moletteList = new volumeListener(dessinCercle);
|
||||
fenetre.addMouseWheelListener(moletteList);
|
||||
fenetre.add(dessinCercle);
|
||||
|
||||
fenetre.setVisible(true);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
BIN
APL2.1/TP9_Evenements(suite)/logoAD.png
Normal file
BIN
APL2.1/TP9_Evenements(suite)/logoAD.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
171
APL2.1/TP9_Evenements(suite)/logoAD.svg
Normal file
171
APL2.1/TP9_Evenements(suite)/logoAD.svg
Normal file
@@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
viewBox="0 0 210 297"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"
|
||||
sodipodi:docname="logoAD.svg">
|
||||
<defs
|
||||
id="defs2">
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient1445">
|
||||
<stop
|
||||
style="stop-color:#ffff24;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop1441" />
|
||||
<stop
|
||||
style="stop-color:#02f0ff;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop1443" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient1049">
|
||||
<stop
|
||||
style="stop-color:#d40000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop1045" />
|
||||
<stop
|
||||
style="stop-color:#d400ff;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop1047" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1049"
|
||||
id="linearGradient1043"
|
||||
x1="95.263455"
|
||||
y1="303.18657"
|
||||
x2="228.77314"
|
||||
y2="303.18657"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-67.067928,27.47922)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1049"
|
||||
id="linearGradient1051"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="69.364655"
|
||||
y1="303.20288"
|
||||
x2="202.87433"
|
||||
y2="303.20288"
|
||||
gradientTransform="matrix(0.99999229,-0.00392469,-0.00392469,-0.99999229,-41.63971,613.07815)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1049"
|
||||
id="linearGradient1132"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="rotate(12.1196,163.7347,643.95208)"
|
||||
x1="95.263455"
|
||||
y1="303.18657"
|
||||
x2="228.77314"
|
||||
y2="303.18657" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1049"
|
||||
id="linearGradient1309"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="158.15364"
|
||||
y1="296.6882"
|
||||
x2="313.79663"
|
||||
y2="297.67621"
|
||||
gradientTransform="translate(102.69254,-20.376455)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1445"
|
||||
id="linearGradient1433"
|
||||
x1="68.195747"
|
||||
y1="834.53461"
|
||||
x2="512.12231"
|
||||
y2="1099.662"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.26458333,0,0,0.26458333,-316.70966,-853.25307)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1445"
|
||||
id="linearGradient1500"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.33461348,0,0,0.33461348,15.624795,-176.36929)"
|
||||
x1="53.258995"
|
||||
y1="787.23486"
|
||||
x2="488.47244"
|
||||
y2="1165.6327" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1445"
|
||||
id="linearGradient1538"
|
||||
x1="-352.31082"
|
||||
y1="-685.49017"
|
||||
x2="-140.38243"
|
||||
y2="-501.92972"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.2306488,0,0,1.2306488,405.99544,878.33087)" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.11313708"
|
||||
inkscape:cx="2357.3599"
|
||||
inkscape:cy="2522.1206"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1017"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<rect
|
||||
style="fill:url(#linearGradient1538);fill-opacity:1;stroke:none;stroke-width:2.97381"
|
||||
id="rect991-9"
|
||||
width="207.71587"
|
||||
height="180.56192"
|
||||
x="1.3609107"
|
||||
y="59.244583"
|
||||
ry="0" />
|
||||
<rect
|
||||
style="fill:#000000;stroke:none;stroke-width:2.84828"
|
||||
id="rect991"
|
||||
width="198.94812"
|
||||
height="172.94037"
|
||||
x="5.7448006"
|
||||
y="63.055378"
|
||||
ry="0" />
|
||||
<path
|
||||
id="path1197"
|
||||
style="fill:url(#linearGradient1500);fill-opacity:1;stroke:none;stroke-width:2.40416;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 92.03889,85.698409 -24.501941,52.406231 10.448174,-0.0412 -8.351611,17.68354 -10.36387,0.0405 -25.93385,55.47132 c -0.320357,0.68522 -0.557864,1.38694 -0.722816,2.09397 h 33.12542 L 82.490638,177.88499 H 72.210426 l 8.251625,-17.65022 h 10.365173 l 10.471696,-22.17141 h -9.26003 z m 11.91014,0.624791 v 17.11169 a 53.966369,46.38209 0 0 1 53.96688,46.38253 53.966369,46.38209 0 0 1 -53.96688,46.38251 v 17.11169 a 73.876293,63.493926 0 0 0 73.87573,-63.4942 73.876293,63.493926 0 0 0 -73.87573,-63.49422 z" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.6 KiB |
BIN
APL2.1/TP9_Evenements(suite)/volumeListener.class
Normal file
BIN
APL2.1/TP9_Evenements(suite)/volumeListener.class
Normal file
Binary file not shown.
39
APL2.1/TP9_Evenements(suite)/volumeListener.java
Normal file
39
APL2.1/TP9_Evenements(suite)/volumeListener.java
Normal file
@@ -0,0 +1,39 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class volumeListener implements MouseWheelListener{
|
||||
|
||||
private int volumeValue;
|
||||
private Cercle dessinCercle;
|
||||
|
||||
public volumeListener(Cercle dessinCercle){
|
||||
this.volumeValue=0;
|
||||
this.dessinCercle=dessinCercle;
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent evenement){
|
||||
|
||||
int add = this.volumeValue+evenement.getWheelRotation();
|
||||
|
||||
|
||||
if(add>=0 && add<=10){
|
||||
this.volumeValue=add;
|
||||
}
|
||||
|
||||
if(add>10){
|
||||
this.volumeValue=10;
|
||||
}
|
||||
|
||||
if(add<0){
|
||||
this.volumeValue=0;
|
||||
}
|
||||
System.out.println("Volume ="+this.volumeValue);
|
||||
|
||||
this.dessinCercle.setVolume(this.volumeValue);
|
||||
|
||||
this.dessinCercle.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user