-
Enhancement
-
Resolution: Won't Fix
-
P4
-
11, 17, 19, 20, 21
-
In Review
-
generic
-
os_x
ADDITIONAL SYSTEM INFORMATION :
Tested using:
Mac 13.2.1 (M2 processor)
OpenJDK 19.0.2
A DESCRIPTION OF THE PROBLEM :
If a Swing app calls:
frame.setExtendedState(Frame.ICONIFIED)
... then the frame window slides/animates into the stage manager thumbnails on the left as expected.
Then if you click the thumbnail to reopen the application: the application opens but nothing will repaint ever. The app still identifies as being in an ICONIFIED state.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run attached source code with Stage Manager active.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Frame should not identify as ICONIFIED. Components should repaint.
ACTUAL -
The Frame identifies as ICONIFIED. As a result: nothing repaints.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
/**
* This demonstrates a bug observed on Mac 13.2.1 using openJDK 19.0.2 in Feb of 2023 when Stage Manager is active.
*
* Instructions for reproducing the bug are displayed inside this JFrame window.
*/
public class StageManagerTest2 extends JFrame {
JMenuBar menuBar = new JMenuBar();
JMenu windowMenu = new JMenu("Window");
public static void main(String[] args) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
SwingUtilities.invokeLater(() -> {
StageManagerTest2 test = new StageManagerTest2();
test.pack();
test.setLocationRelativeTo(null);
test.setVisible(true);
});
}
JTextPane instructions = new JTextPane();
JLabel repaintingColorBar = new JLabel(new Icon() {
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
float hue = ((float) (System.currentTimeMillis()%1000)) / 1000f;
Color color = new Color(Color.HSBtoRGB(hue, 1, 1));
g.setColor(color);
g.fillRect(0,0,getIconWidth(),getIconHeight());
c.repaint();
}
@Override
public int getIconWidth() {
return 600;
}
@Override
public int getIconHeight() {
return 20;
}
});
public StageManagerTest2() {
AbstractAction minimizeAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
setExtendedState(JFrame.ICONIFIED);
}
};
String name = "Minimize (Iconify)";
minimizeAction.putValue(Action.NAME, name);
JButton minimizeButton = new JButton(minimizeAction);
minimizeAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_M, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
JMenuItem minimizeMenuItem = new JMenuItem(minimizeAction);
windowMenu.add(minimizeMenuItem);
menuBar.add(windowMenu);
setJMenuBar(menuBar);
instructions.setEditable(false);
instructions.setBorder(new EmptyBorder(10, 10, 10, 10));
instructions.setText("Instructions:\n" +
"1. Open this app.\n" +
"2. Turn on Stage Manager (see Mac system preferences)\n" +
"3. Select \"" + name + "\" button or menu item\n" +
"4. Click thumbnail in stage manager to reopen application\n\n" +
"Expected behavior: animated color bar repaints continuously.\n\n" +
"Observed behavior: nothing repaints.");
getContentPane().setLayout(new BorderLayout());
getContentPane().add(instructions, BorderLayout.NORTH);
getContentPane().add(minimizeButton, BorderLayout.CENTER);
getContentPane().add(repaintingColorBar, BorderLayout.SOUTH);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Tested using:
Mac 13.2.1 (M2 processor)
OpenJDK 19.0.2
A DESCRIPTION OF THE PROBLEM :
If a Swing app calls:
frame.setExtendedState(Frame.ICONIFIED)
... then the frame window slides/animates into the stage manager thumbnails on the left as expected.
Then if you click the thumbnail to reopen the application: the application opens but nothing will repaint ever. The app still identifies as being in an ICONIFIED state.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run attached source code with Stage Manager active.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Frame should not identify as ICONIFIED. Components should repaint.
ACTUAL -
The Frame identifies as ICONIFIED. As a result: nothing repaints.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
/**
* This demonstrates a bug observed on Mac 13.2.1 using openJDK 19.0.2 in Feb of 2023 when Stage Manager is active.
*
* Instructions for reproducing the bug are displayed inside this JFrame window.
*/
public class StageManagerTest2 extends JFrame {
JMenuBar menuBar = new JMenuBar();
JMenu windowMenu = new JMenu("Window");
public static void main(String[] args) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
SwingUtilities.invokeLater(() -> {
StageManagerTest2 test = new StageManagerTest2();
test.pack();
test.setLocationRelativeTo(null);
test.setVisible(true);
});
}
JTextPane instructions = new JTextPane();
JLabel repaintingColorBar = new JLabel(new Icon() {
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
float hue = ((float) (System.currentTimeMillis()%1000)) / 1000f;
Color color = new Color(Color.HSBtoRGB(hue, 1, 1));
g.setColor(color);
g.fillRect(0,0,getIconWidth(),getIconHeight());
c.repaint();
}
@Override
public int getIconWidth() {
return 600;
}
@Override
public int getIconHeight() {
return 20;
}
});
public StageManagerTest2() {
AbstractAction minimizeAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
setExtendedState(JFrame.ICONIFIED);
}
};
String name = "Minimize (Iconify)";
minimizeAction.putValue(Action.NAME, name);
JButton minimizeButton = new JButton(minimizeAction);
minimizeAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_M, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
JMenuItem minimizeMenuItem = new JMenuItem(minimizeAction);
windowMenu.add(minimizeMenuItem);
menuBar.add(windowMenu);
setJMenuBar(menuBar);
instructions.setEditable(false);
instructions.setBorder(new EmptyBorder(10, 10, 10, 10));
instructions.setText("Instructions:\n" +
"1. Open this app.\n" +
"2. Turn on Stage Manager (see Mac system preferences)\n" +
"3. Select \"" + name + "\" button or menu item\n" +
"4. Click thumbnail in stage manager to reopen application\n\n" +
"Expected behavior: animated color bar repaints continuously.\n\n" +
"Observed behavior: nothing repaints.");
getContentPane().setLayout(new BorderLayout());
getContentPane().add(instructions, BorderLayout.NORTH);
getContentPane().add(minimizeButton, BorderLayout.CENTER);
getContentPane().add(repaintingColorBar, BorderLayout.SOUTH);
}
}
---------- END SOURCE ----------
FREQUENCY : always