Only draw eyes on selection and the full closest person on validation.
[Persons_Comparator.git] / src / PersonLeftPanel.java
CommitLineData
255d3354
JB
1import javax.imageio.ImageIO;
2import javax.swing.*;
3import java.awt.*;
4import java.io.File;
5import java.io.IOException;
6
7add5cb9 7public class PersonLeftPanel extends JPanel {
255d3354
JB
8 private JLabel leftLabel = new JLabel();
9 private Image personImage;
10
7add5cb9 11 PersonLeftPanel() {
255d3354
JB
12 leftLabel.setText("Current person");
13 add(leftLabel);
14 try {
15 this.personImage = ImageIO.read(new File("data/personImage.png"));
16 } catch (IOException e) {
17 System.out.println(e.getStackTrace());
18 }
19 }
20
255d3354
JB
21 public void paintComponent(Graphics g) {
22 super.paintComponent(g);
23
24 // Draw
255d3354
JB
25 Graphics2D g2d = (Graphics2D) g;
26 int imageWidth = 120;
27 int imageHeight = 180;
28 g2d.drawImage(this.personImage.getScaledInstance(imageWidth / 2, imageHeight / 2, Image.SCALE_SMOOTH), imageWidth / 4, imageHeight / 4, this);
29 }
d418dae1
JB
30
31 public void drawEyes(Color color) {
32 Graphics g = this.getGraphics();
33 g.setColor(color);
34 g.fillOval(50, 50, 6, 3);
35 g.fillOval(62, 50, 6, 3);
36 }
255d3354 37}