ActiveWindowsIcon(String desktopPropertyName, String nativeImageName, String fallbackName) { this.nativeImageName = nativeImageName; this.fallbackName = fallbackName; if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) < 0) { // This desktop property is needed to trigger reloading the icon. // It is kept in member variable to avoid GC. this.desktopProperty = new TriggerDesktopProperty(desktopPropertyName) { @Override protected void updateUI() { icon = null; super.updateUI(); } }; } }
/** * Obtains the appropriate <code>Popup</code> based on * <code>popupType</code>. */ private Popup getPopup(Component owner, Component contents, int ownerX, int ownerY, int popupType) { if (GraphicsEnvironment.isHeadless()) { return getHeadlessPopup(owner, contents, ownerX, ownerY); } switch(popupType) { case LIGHT_WEIGHT_POPUP: return getLightWeightPopup(owner, contents, ownerX, ownerY); case MEDIUM_WEIGHT_POPUP: return getMediumWeightPopup(owner, contents, ownerX, ownerY); case HEAVY_WEIGHT_POPUP: Popup popup = getHeavyWeightPopup(owner, contents, ownerX, ownerY); if ((AccessController.doPrivileged(OSInfo.getOSTypeAction()) == OSInfo.OSType.MACOSX) && (owner != null) && (EmbeddedFrame.getAppletIfAncestorOf(owner) != null)) { ((HeavyWeightPopup)popup).setCacheEnabled(false); } return popup; } return null; }
public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { return; } toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Robot robot = new Robot(); robot.setAutoDelay(50); createAndShowGUI(); // Pressed keys: Alt + E + A // Results: ALT + VK_DEAD_ACUTE + a with accute accent robot.keyPress(KeyEvent.VK_ALT); robot.keyPress(KeyEvent.VK_E); robot.keyRelease(KeyEvent.VK_E); robot.keyRelease(KeyEvent.VK_ALT); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); if (state != 3) { throw new RuntimeException("Wrong number of key events."); } }
@Override public void init() { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { Sysout.createDialogWithInstructions(new String[]{ "Press PASS, this test is for MacOS X only."}); return; } System.setProperty("apple.awt.use-file-dialog-packages", "true"); setLayout(new GridLayout(1, 1)); fd = new FileDialog(new Frame(), "Open"); fd.setDirectory(APPLICATIONS_FOLDER); showBtn = new Button("Show File Dialog"); showBtn.addActionListener(this); add(showBtn); String[] instructions = { "1) Click on 'Show File Dialog' button. A file dialog will come up.", "2) Navigate to the Applications folder if not already there", "3) Check that the application bundles can be selected and can not be navigated", "4) If it's true then the test passed, otherwise it failed."}; Sysout.createDialogWithInstructions(instructions); }
@Override public void init() { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { Sysout.createDialogWithInstructions(new String[]{ "Press PASS, this test is for MacOS X only."}); return; } System.setProperty("apple.awt.fileDialogForDirectories", "true"); setLayout(new GridLayout(1, 1)); fd = new FileDialog(new Frame(), "Open"); showBtn = new Button("Show File Dialog"); showBtn.addActionListener(this); add(showBtn); String[] instructions = { "1) Click on 'Show File Dialog' button. A file dialog will come up.", "2) Check that files can't be selected.", "3) Check that directories can be selected.", "4) Repeat steps 1 - 3 a few times for different files and directories.", "5) If it's true then the test passed, otherwise it failed."}; Sysout.createDialogWithInstructions(instructions); }
public static void main(String[] args) { if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { System.out.println("The test was skipped because it is sensible only for Windows."); return; } for (String key : KEYS) { Image image = (Image) ShellFolder.get(key); if (image == null) { throw new RuntimeException("The image '" + key + "' not found."); } if (image != ShellFolder.get(key)) { throw new RuntimeException("The image '" + key + "' is not cached."); } } System.out.println("The test passed."); }
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Robot robot = new Robot(); robot.setAutoDelay(50); UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); SwingUtilities.invokeLater(new Runnable() { public void run() { fileChooser = new JFileChooser(); fileChooser.showOpenDialog(null); } }); toolkit.realSync(); if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) { Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L); } else { Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L); } checkFocus(); }
public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { System.out.println("The test is suitable only for Windows, skipped."); return; } SwingUtilities.invokeAndWait(new Runnable() { public void run() { File[] files = (File[]) ShellFolder.get("fileChooserComboBoxFolders"); for (File file : files) { if (file instanceof ShellFolder && ((ShellFolder) file).isLink()) { throw new RuntimeException("Link shouldn't be in FileChooser combobox, " + file.getPath()); } } } }); }
public static void main(String[] args) throws Exception { OSType type = OSInfo.getOSType(); if (type != OSType.WINDOWS) { System.out.println("This test is for Windows only... skipping!"); return; } SwingUtilities.invokeAndWait(() -> { try { UIManager.setLookAndFeel(new WindowsLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } System.out.println("Creating JFileChooser..."); JFileChooser fileChooser = new JFileChooser(); System.out.println("Test passed: chooser = " + fileChooser); }); // Test fails if creating JFileChooser hangs }
public static void main(final String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { System.out.println("This test is for OSX, considered passed."); return; } // Default window appearance showFrame(); step++; // apple.awt.brushMetalLook appearance showFrame(); step++; // Window.style appearance showFrame(); // images on step 1 and 2 should be same testImages(images[1], images[2], false); // images on step 1 and 2 should be different from default testImages(images[0], images[1], true); testImages(images[0], images[2], true); }
public static void main(String[] args) throws Exception { if(!OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())){ return; } SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JCheckBox checkBox = new JCheckBox(); checkBox.setSelected(true); checkBox.setSize(new Dimension(IMAGE_WIDTH, IMAGE_HEIGHT)); final BufferedImage image1 = getHiDPIImage(checkBox); final BufferedImage image2 = getScaledImage(checkBox); if(equal(image1, image2)){ throw new RuntimeException("2x image equals to non smooth image"); } } }); }
/** * Obtains the appropriate <code>Popup</code> based on * <code>popupType</code>. */ @SuppressWarnings("deprecation") private Popup getPopup(Component owner, Component contents, int ownerX, int ownerY, int popupType) { if (GraphicsEnvironment.isHeadless()) { return getHeadlessPopup(owner, contents, ownerX, ownerY); } switch(popupType) { case LIGHT_WEIGHT_POPUP: return getLightWeightPopup(owner, contents, ownerX, ownerY); case MEDIUM_WEIGHT_POPUP: return getMediumWeightPopup(owner, contents, ownerX, ownerY); case HEAVY_WEIGHT_POPUP: Popup popup = getHeavyWeightPopup(owner, contents, ownerX, ownerY); if ((AccessController.doPrivileged(OSInfo.getOSTypeAction()) == OSInfo.OSType.MACOSX) && (owner != null) && (EmbeddedFrame.getAppletIfAncestorOf(owner) != null)) { ((HeavyWeightPopup)popup).setCacheEnabled(false); } return popup; } return null; }
public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { return; } Robot robot = new Robot(); robot.setAutoDelay(50); createAndShowGUI(); // Pressed keys: Alt + E + A // Results: ALT + VK_DEAD_ACUTE + a with accute accent keyPress(robot, KeyEvent.VK_ALT); keyPress(robot, KeyEvent.VK_E); keyRelease(robot, KeyEvent.VK_E); keyRelease(robot, KeyEvent.VK_ALT); keyPress(robot, KeyEvent.VK_A); keyRelease(robot, KeyEvent.VK_A); if (state != 3) { throw new RuntimeException("Wrong number of key events."); } }
public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { return; } robot = new Robot(); robot.setAutoDelay(50); createAndShowGUI(); for (int i = 0; i < controlCharArray.length; i++) { testCase = i; System.out.println("\ntestCase = " + testCase); System.out.println("\tkeyPress: <VK_CONTROL> + \'" + controlCharArray[i].controlChar + "\'"); keyPress(KeyEvent.VK_CONTROL); keyPress(controlCharArray[i].controlChar); keyRelease(controlCharArray[i].controlChar); keyRelease(KeyEvent.VK_CONTROL); } frame.dispose(); }