-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
9
Please run the following test:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
public class ColorTest extends JFrame {
private JMenu menu;
private void UI() {
setSize(300, 300);
getContentPane().setBackground(Color.BLUE);
int sz = 50;
BufferedImage img = new BufferedImage(sz, sz, BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
g.setColor(Color.BLUE);
g.fillRect(0, 0, sz, sz);
ImageIcon ii = new ImageIcon(img);
JMenuBar menuBar = new JMenuBar();
menu = new JMenu("menu");
menuBar.add(menu);
menu.add(new JMenuItem("test", ii));
setJMenuBar(menuBar);
setVisible(true);
}
public ColorTest() throws Exception { EventQueue.invokeAndWait(this::UI); }
private static void delay(int ms) {
try { Thread.sleep(ms); } catch (Exception e) {}
}
private void run() throws Exception {
Robot r = new Robot();
delay(700);
Point pt = getLocationOnScreen();
System.out.println("color = " + r.getPixelColor(pt.x + 50, pt.y + 50));
pt = menu.getLocationOnScreen();
r.mouseMove(pt.x + 5, pt.y + 5);
r.mousePress(InputEvent.BUTTON1_MASK);
delay(100);
r.mouseRelease(InputEvent.BUTTON1_MASK);
delay(700);
System.out.println("color = " + r.getPixelColor(pt.x + 40, pt.y + 40));
delay(700);
dispose();
}
public static void main(String[] args) throws Exception { (new ColorTest()).run(); }
}
the output is:
OS X 10.10 (JDK9 b104)
color = java.awt.Color[r=0,g=0,b=255]
color = java.awt.Color[r=0,g=0,b=248]
Windows, Linux - the same color (as expected):
color = java.awt.Color[r=0,g=0,b=255]
color = java.awt.Color[r=0,g=0,b=255]
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
public class ColorTest extends JFrame {
private JMenu menu;
private void UI() {
setSize(300, 300);
getContentPane().setBackground(Color.BLUE);
int sz = 50;
BufferedImage img = new BufferedImage(sz, sz, BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
g.setColor(Color.BLUE);
g.fillRect(0, 0, sz, sz);
ImageIcon ii = new ImageIcon(img);
JMenuBar menuBar = new JMenuBar();
menu = new JMenu("menu");
menuBar.add(menu);
menu.add(new JMenuItem("test", ii));
setJMenuBar(menuBar);
setVisible(true);
}
public ColorTest() throws Exception { EventQueue.invokeAndWait(this::UI); }
private static void delay(int ms) {
try { Thread.sleep(ms); } catch (Exception e) {}
}
private void run() throws Exception {
Robot r = new Robot();
delay(700);
Point pt = getLocationOnScreen();
System.out.println("color = " + r.getPixelColor(pt.x + 50, pt.y + 50));
pt = menu.getLocationOnScreen();
r.mouseMove(pt.x + 5, pt.y + 5);
r.mousePress(InputEvent.BUTTON1_MASK);
delay(100);
r.mouseRelease(InputEvent.BUTTON1_MASK);
delay(700);
System.out.println("color = " + r.getPixelColor(pt.x + 40, pt.y + 40));
delay(700);
dispose();
}
public static void main(String[] args) throws Exception { (new ColorTest()).run(); }
}
the output is:
OS X 10.10 (JDK9 b104)
color = java.awt.Color[r=0,g=0,b=255]
color = java.awt.Color[r=0,g=0,b=248]
Windows, Linux - the same color (as expected):
color = java.awt.Color[r=0,g=0,b=255]
color = java.awt.Color[r=0,g=0,b=255]