X-Git-Url: https://git.piment-noir.org/?p=Persons_Comparator.git;a=blobdiff_plain;f=src%2FLeftPersonPanel.java;fp=src%2FLeftPersonPanel.java;h=95d7d02b9355318acea10847218379e59fa11b5e;hp=0000000000000000000000000000000000000000;hb=255d335423820ebc4316dfd8468dcb97bfd17451;hpb=b05df284031fa4c3077ab73952690172b21a394f diff --git a/src/LeftPersonPanel.java b/src/LeftPersonPanel.java new file mode 100644 index 0000000..95d7d02 --- /dev/null +++ b/src/LeftPersonPanel.java @@ -0,0 +1,35 @@ +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.io.IOException; + +public class LeftPersonPanel extends JPanel { + private JLabel leftLabel = new JLabel(); + private Image personImage; + + LeftPersonPanel() { + leftLabel.setText("Current person"); + add(leftLabel); + try { + this.personImage = ImageIO.read(new File("data/personImage.png")); + } catch (IOException e) { + System.out.println(e.getStackTrace()); + } + } + + public Image getPersonImage() { + return personImage; + } + + public void paintComponent(Graphics g) { + super.paintComponent(g); + + // Draw + g.setColor(Color.black); + Graphics2D g2d = (Graphics2D) g; + int imageWidth = 120; + int imageHeight = 180; + g2d.drawImage(this.personImage.getScaledInstance(imageWidth / 2, imageHeight / 2, Image.SCALE_SMOOTH), imageWidth / 4, imageHeight / 4, this); + } +}