From 8ea894cd3efc255c74cf34475742f8bc359e16fe Mon Sep 17 00:00:00 2001 From: jbb01 <32650546+jbb01@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:48:11 +0200 Subject: [PATCH] fix live canvas clipping --- .../eu/jonahbauer/raytracing/render/canvas/LiveCanvas.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/jonahbauer/raytracing/render/canvas/LiveCanvas.java b/src/main/java/eu/jonahbauer/raytracing/render/canvas/LiveCanvas.java index 402aebd..bfc5fc0 100644 --- a/src/main/java/eu/jonahbauer/raytracing/render/canvas/LiveCanvas.java +++ b/src/main/java/eu/jonahbauer/raytracing/render/canvas/LiveCanvas.java @@ -42,15 +42,19 @@ public final class LiveCanvas implements Canvas { public @NotNull Thread preview() { var frame = new JFrame(); - frame.setSize(getWidth(), getHeight()); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setContentPane(new JPanel() { + { + setPreferredSize(new Dimension(image.getWidth(), image.getHeight())); + } + @Override protected void paintComponent(Graphics g) { g.drawImage(image, 0, 0, null); } }); frame.setResizable(false); + frame.pack(); frame.setVisible(true); var update = Thread.ofVirtual().start(() -> {