merge avec le github + j'ai mis les trucs de l'interface dans un package gui
This commit is contained in:
42
src/gui/ElevatorCanvas.java
Normal file
42
src/gui/ElevatorCanvas.java
Normal file
@ -0,0 +1,42 @@
|
||||
package gui;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
class ElevatorCanvas extends JPanel {
|
||||
private final static int WIDTH = 40;
|
||||
private final static int HEIGHT = 50;
|
||||
private final static Color COLOR = Color.PINK;
|
||||
private final static Dimension DIMENSIONS = new Dimension(WIDTH, 200);
|
||||
|
||||
private int y = 0;
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return DIMENSIONS;
|
||||
}
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return DIMENSIONS;
|
||||
}
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return DIMENSIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
g.setColor(COLOR);
|
||||
g.fillRect(0, y, WIDTH, HEIGHT);
|
||||
}
|
||||
|
||||
public void setElevatorY(int y) {
|
||||
this.y = y;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public int getElevatorY() {
|
||||
return y;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user