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
|
public class TLeiterJP extends JPanel{
private int p1x,p1y,p2x, p2y;
private char stl;
private PetitPoint p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14;
public TLeiterJP(int p1x, int p1y, int p2x, int p2y, char stl)
{
setLayout(null);
this.setBackground(new Color(214, 217, 141));
this.setOpaque(true);
this.setBounds(p1x, p1y, p2x, p2y);
this.p1x = p1x;
this.p1y = p1y;
this.p2x = p2x;
this.p2y = p2y;
this.stl = stl;
}
public void paintComponent(Graphics g)
{
int incrX = 16;
super.paintComponents(g);
g.setColor(new Color(214, 217, 141));
g.drawRect(0, 0, p2x - 2,p2y - 2);
g.fillRect(0, 0, p2x - 2,p2y - 2);
g.setColor(Color.BLACK);
while (incrX < 112){
g.drawLine(incrX, 20, incrX, 160);
incrX = incrX + 16;
}
p1 = new PetitPoint(8, 10);
g.setColor(p1.ppColor);// ppColor, corde au repos a la creation
g.drawOval(p1.cX, p1.cY, 16, 16);
g.fillOval(p1.cX , p1.cY , 16, 16);
if (stl == 'B')
tl1Blues(g);
}
private void tl1Blues(Graphics g)
{
}
class PetitPoint{
private int cX, cY;
private int ppRayon = 8;
private Color ppColor;
private Color pressed = new Color(191, 128, 11);
private Color unPressed = new Color(145, 144, 131);
private PetitPoint(int x, int y){
this.ppColor = unPressed;
this.cX = x;
this.cY = y;
}
}
}
// Le but est d'aller changer la couleur de p1 avec un p1.setColor(); |
Partager