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

Problem with undecorated Frame on macOS

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Mojave with java 12

      A DESCRIPTION OF THE PROBLEM :
      If u try to minimize an undecorated frame it doesn't work

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      public class SwingFrameState extends JFrame {
          public SwingFrameState() throws HeadlessException {
              initUI();
          }

          private void initUI() {
              setUndecorated(true);
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              setLayout(new FlowLayout());

              final JButton minimize = new JButton("Minimize");
              final JButton maximize = new JButton("Maximize");
              final JButton normal = new JButton("Normal");

              add(normal);
              add(minimize);
              add(maximize);

              pack();
              setSize(500, 200);

              ActionListener listener = new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                      if (e.getSource() == normal) {
                          setExtendedState(Frame.NORMAL);
                      } else if (e.getSource() == minimize) {
                          setExtendedState(Frame.ICONIFIED);
                      } else if (e.getSource() == maximize) {
                          setExtendedState(Frame.MAXIMIZED_BOTH);
                      }
                  }
              };

              minimize.addActionListener(listener);
              maximize.addActionListener(listener);
              normal.addActionListener(listener);
          }

          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      new SwingFrameState().setVisible(true);
                  }
              });
          }
      }


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      a minimizable popup
      ACTUAL -
      it doesn't work as expected

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      public class SwingFrameState extends JFrame {
          public SwingFrameState() throws HeadlessException {
              initUI();
          }

          private void initUI() {
              setUndecorated(true);
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              setLayout(new FlowLayout());

              final JButton minimize = new JButton("Minimize");
              final JButton maximize = new JButton("Maximize");
              final JButton normal = new JButton("Normal");

              add(normal);
              add(minimize);
              add(maximize);

              pack();
              setSize(500, 200);

              ActionListener listener = new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                      if (e.getSource() == normal) {
                          setExtendedState(Frame.NORMAL);
                      } else if (e.getSource() == minimize) {
                          setExtendedState(Frame.ICONIFIED);
                      } else if (e.getSource() == maximize) {
                          setExtendedState(Frame.MAXIMIZED_BOTH);
                      }
                  }
              };

              minimize.addActionListener(listener);
              maximize.addActionListener(listener);
              normal.addActionListener(listener);
          }

          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      new SwingFrameState().setVisible(true);
                  }
              });
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      no one

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pardesha Pardeep Sharma
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: