Java Code Examples for javax.swing.ImageIcon#setImageObserver()
The following examples show how to use
javax.swing.ImageIcon#setImageObserver() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiResolutionImageHack.java From visualvm with GNU General Public License v2.0 | 6 votes |
private static void hackIcon(ImageIcon icon) { try { // Create a dummy image observer JPanel p = new JPanel(); // Set the image observer to the multi-resolution image icon.setImageObserver(p); // Mac OS X specific if (Platform.isMac()) { Method getInvertedIcon = icon.getClass().getMethod("getInvertedIcon"); // NOI18N getInvertedIcon.setAccessible(true); IconUIResource invertedIcon = (IconUIResource)getInvertedIcon.invoke(icon); Field delegate = invertedIcon.getClass().getDeclaredField("delegate"); // NOI18N delegate.setAccessible(true); ImageIcon imageIcon = (ImageIcon)delegate.get(invertedIcon); // Set the image observer to the inverted multi-resolution image imageIcon.setImageObserver(p); } } catch (Throwable t) { Logger logger = Logger.getLogger(MultiResolutionImageHack.class.getName()); logger.log(Level.FINE, "Failed to apply MultiResolutionToolkitImageCacheHack", t); // NOI18N } }
Example 2
Source File: AbstractSuggestionBoxValueCellEditor.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates a grayed out version of the loading gif that can be used in a combobox through an image observer * * @since 9.2.0 */ private static ImageIcon makeLoadingIcon(JComboBox comboBox) { ImageIcon icon = new ImageIcon(LOADING_ICON); icon.setImageObserver((img, infoflags, x, y, w, h) -> { boolean isFrameOrAll = (infoflags & (ImageObserver.FRAMEBITS | ImageObserver.ALLBITS)) != 0; if (!comboBox.isShowing() || !isFrameOrAll) { return !isFrameOrAll; } if (comboBox.getSelectedIndex() == 0) { comboBox.repaint(); } BasicComboPopup p = (BasicComboPopup) comboBox.getAccessibleContext().getAccessibleChild(0); JList list = p.getList(); if (list.isShowing()) { list.repaint(); } return true; }); return icon; }
Example 3
Source File: DefaultModulesPanel.java From opt4j with MIT License | 5 votes |
@Override public ImageIcon getIcon() { if (isLoading()) { ImageIcon icon = Icons.getIcon(Icons.LOADING); icon.setImageObserver(tree); return icon; } return format.asFolder(null); }
Example 4
Source File: LoaderScreen.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 4 votes |
private void setIcon(String iconLoc) { ImageIcon icon = new ImageIcon( LoaderScreen.class.getResource(iconLoc)); loadLabel.setIcon(icon); icon.setImageObserver(loadLabel); }