Commit | Line | Data |
---|---|---|
255d3354 JB |
1 | import javax.imageio.ImageIO; |
2 | import javax.swing.*; | |
3 | import java.awt.*; | |
4 | import java.io.File; | |
5 | import java.io.IOException; | |
6 | ||
7add5cb9 | 7 | public 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 | } |