Make the main window a singleton to permit to query it from other views and update...
[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
25 g.setColor(Color.black);
26 Graphics2D g2d = (Graphics2D) g;
27 int imageWidth = 120;
28 int imageHeight = 180;
29 g2d.drawImage(this.personImage.getScaledInstance(imageWidth / 2, imageHeight / 2, Image.SCALE_SMOOTH), imageWidth / 4, imageHeight / 4, this);
30 }
31}