Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8187984

javapackager generated launcher does not honor apple.laf.useScreenMenuBar, no menubar at all

XMLWordPrintable

    • x86_64
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_144"
      Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
      Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      macOS High Sierra Beta 10.13 (17A362a)

      A DESCRIPTION OF THE PROBLEM :
      the launcher generated from "javapackager -deploy ..." (that use libpackager.dylib) behaves differently from the application launched by java command line.
      in particular the use of system property 'apple.laf.useScreenMenuBar' doe not work at all when launched from the javapackegr launcher (opening the .app that contains libpackager.dylib, Info.plist and the binary executable with the app name) insted works well when launched from terminal with java command line (java -jar App.jar)




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JFrame and launch with apple.laf.useScreenMenuBar = true, no menu bar at top of the screen

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      as prior macOs version we expect appearing the java app menu on macOs top screen menu
      ACTUAL -
      no menu bar at all

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no error logged

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      mport javax.swing.UIManager;
      public class TestFrame extends javax.swing.JFrame {
          public TestFrame() {
              initComponents();
          }

          @SuppressWarnings("unchecked")
          // <editor-fold defaultstate="collapsed" desc="Generated Code">
          private void initComponents() {

              jMenuBar1 = new javax.swing.JMenuBar();
              jMenu1 = new javax.swing.JMenu();
              jMenuItem1 = new javax.swing.JMenuItem();
              jMenuItem2 = new javax.swing.JMenuItem();
              jMenuItem3 = new javax.swing.JMenuItem();
              jMenu2 = new javax.swing.JMenu();

              setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

              jMenu1.setText("File");

              jMenuItem1.setText("jMenuItem1");
              jMenu1.add(jMenuItem1);

              jMenuItem2.setText("jMenuItem2");
              jMenu1.add(jMenuItem2);

              jMenuItem3.setText("jMenuItem3");
              jMenu1.add(jMenuItem3);

              jMenuBar1.add(jMenu1);

              jMenu2.setText("Edit");
              jMenuBar1.add(jMenu2);

              setJMenuBar(jMenuBar1);

              javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
              getContentPane().setLayout(layout);
              layout.setHorizontalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGap(0, 400, Short.MAX_VALUE)
              );
              layout.setVerticalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGap(0, 278, Short.MAX_VALUE)
              );

              pack();
          }// </editor-fold>

          public static void main(String args[]) {
              System.setProperty("apple.laf.useScreenMenuBar", "true");
              java.awt.EventQueue.invokeLater(new Runnable() {
                  public void run() {
                      new TestFrame().setVisible(true);
                  }
              });
          }

          // Variables declaration - do not modify
          private javax.swing.JMenu jMenu1;
          private javax.swing.JMenu jMenu2;
          private javax.swing.JMenuBar jMenuBar1;
          private javax.swing.JMenuItem jMenuItem1;
          private javax.swing.JMenuItem jMenuItem2;
          private javax.swing.JMenuItem jMenuItem3;
          // End of variables declaration
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      changed launcher with simple bash script that launch java -jar

        1. screenshot-1.png
          10 kB
          Pardeep Sharma
        2. TestFrame.java
          2 kB
          Pardeep Sharma

            asemenyuk Alexey Semenyuk
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: