From 1cc7def2c50d5f6d05762f9881f62ff06cb7075c Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:50:25 +0200 Subject: [PATCH 1/2] Simulator: heavyweight menu popups so the canvas blit cannot smear them (#5850) Co-Authored-By: Claude Opus 5.5 --- .../com/codename1/impl/javase/JavaSEPort.java | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java b/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java index daab9161991..bdb6d3bf16c 100644 --- a/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java +++ b/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java @@ -4457,26 +4457,6 @@ public void run() { updateEdtBufferSize(); } - if (window != null) { - - if (zoomLevel != 1) { - Graphics2D g2d = (Graphics2D) g; - g2d.setTransform(AffineTransform.getScaleInstance(1, 1)); - } - - if (window.getJMenuBar() != null) { - for (int i = 0; i < window.getJMenuBar().getComponentCount(); i++) { - JMenu m = (JMenu) window.getJMenuBar().getComponent(i); - if (m.isPopupMenuVisible()) { - JPopupMenu pop = m.getPopupMenu(); - pop.getInvoker().getX(); - g.translate(pop.getInvoker().getX(), 0); - pop.update(g); - g.translate(-pop.getInvoker().getX(), 0); - } - } - } - } g.dispose(); } } @@ -7464,6 +7444,11 @@ private java.awt.Dimension computeSkinDisplaySize() { private void installMenu(final JFrame frm, boolean desktopSkin) throws IOException{ final Preferences pref = Preferences.userNodeForPackage(JavaSEPort.class); + // The canvas blits straight to the screen through getGraphics(), outside + // Swing's paint cycle, so a lightweight popup (painted into the same + // surface) is overwritten wherever it overlaps the canvas and smears + // (#5850). A heavyweight popup lives in its own native window above it. + JPopupMenu.setDefaultLightWeightPopupEnabled(false); JMenuBar bar = new JMenuBar(); frm.setJMenuBar(bar); From b0fa179825aac9c4991828c002c0559175ce4052 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Sun, 25 Oct 2026 15:14:20 +0200 Subject: [PATCH 2/2] Simulator: set heavyweight popups in a static initializer so native-chrome menus get them too Co-Authored-By: Claude Opus 5.5 --- .../com/codename1/impl/javase/JavaSEPort.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java b/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java index bdb6d3bf16c..ae14988382d 100644 --- a/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java +++ b/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java @@ -278,6 +278,17 @@ public class JavaSEPort extends CodenameOneImplementation { // frame off every reachable display. static final int MAX_PERSISTED_WINDOW_DIMENSION = 32767; + static { + // The canvas blits straight to the screen through getGraphics(), outside + // Swing's paint cycle, so a lightweight popup (painted into the same + // surface) is overwritten wherever it overlaps the canvas and smears + // (#5850). A heavyweight popup lives in its own native window above it. + // Set here, before any frame or menu exists: a JPopupMenu reads the default + // when it is constructed, and the native-chrome menu bars + // (buildNativeMenuBar) are built without installMenu ever running. + JPopupMenu.setDefaultLightWeightPopupEnabled(false); + } + static { IOS_NATIVE_FONT_CANDIDATES.put("native:MainThin", new String[] { "SF Pro Display", "SF Pro Text", @@ -7444,11 +7455,6 @@ private java.awt.Dimension computeSkinDisplaySize() { private void installMenu(final JFrame frm, boolean desktopSkin) throws IOException{ final Preferences pref = Preferences.userNodeForPackage(JavaSEPort.class); - // The canvas blits straight to the screen through getGraphics(), outside - // Swing's paint cycle, so a lightweight popup (painted into the same - // surface) is overwritten wherever it overlaps the canvas and smears - // (#5850). A heavyweight popup lives in its own native window above it. - JPopupMenu.setDefaultLightWeightPopupEnabled(false); JMenuBar bar = new JMenuBar(); frm.setJMenuBar(bar);