javax.swing.Icon Java Examples

The following examples show how to use javax.swing.Icon. 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: OnClickListener.java    From CEC-Automatic-Annotation with Apache License 2.0 6 votes vote down vote up
public void handleAbout() {
	String messageStr = "-----------------------------------------\nAuthor:wangxu\nDate From:2014/5/7\nEmail:[email protected]\nCopyright:Semantic intelligence laboratory,Shanghai University\n-----------------------------------------";
	String imagePath = "image/water.png";
	URL url = getClass().getClassLoader().getResource(imagePath);
	System.out.println(url);
	Image imageIcon = Toolkit.getDefaultToolkit().getImage(url);// 将默认图标更改为指定图标
	Icon icon = new ImageIcon(imageIcon);
	// parentComponent - 确定在其中显示对话框的 Frame;如果为 null 或者 parentComponent 不具有
	// Frame,则使用默认的 Frame
	// message - 要显示的 Object
	// title - 对话框的标题字符串
	// messageType -
	// 要显示的消息类型:ERROR_MESSAGE、INFORMATION_MESSAGE、WARNING_MESSAGE、QUESTION_MESSAGE
	// 或 PLAIN_MESSAGE
	// icon - 要在对话框中显示的图标,该图标可以帮助用户识别要显示的消息种类
	JOptionPane.showMessageDialog(null, messageStr, "语料标注器", JOptionPane.INFORMATION_MESSAGE, icon);
}
 
Example #2
Source File: SQFBreadCrumbsProvider.java    From arma-intellij-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public Icon getElementIcon(@NotNull PsiElement element) {
	if (element instanceof SQFFileScope) {
		return ArmaPluginIcons.ICON_SQF;
	}
	if (element instanceof SQFCommandExpression || element instanceof SQFCaseStatement) {
		return ArmaPluginIcons.ICON_SQF_COMMAND;
	}
	if (element instanceof SQFExpressionStatement) {
		SQFExpressionStatement exprStatement = (SQFExpressionStatement) element;
		SQFExpression exprStatementExpr = exprStatement.getExpr();
		if (exprStatementExpr instanceof SQFCommandExpression) {
			return ArmaPluginIcons.ICON_SQF_COMMAND;
		}
	}
	return null;
}
 
Example #3
Source File: AnalyzerUtil.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public static Icon getIcon(AnalyzerType type) {
	switch (type) {
		case BYTE_ANALYZER:
			return BYTES_ICON;
		case DATA_ANALYZER:
			return DATA_ICON;
		case FUNCTION_ANALYZER:
			return FUNCTION_ICON;
		case FUNCTION_MODIFIERS_ANALYZER:
			return FUNCTION_MODIFIER_ICON;
		case FUNCTION_SIGNATURES_ANALYZER:
			return FUNCTION_SIGNATURE_ICON;
		case INSTRUCTION_ANALYZER:
			return INSTRUCTION_ICON;
		case ONE_SHOT_ANALYZER:
			return MANUAL_ICON;
		default:
			throw new AssertException("Missing case statement for icons");

	}
}
 
Example #4
Source File: PreferencesDialog.java    From org.alloytools.alloy with Apache License 2.0 6 votes vote down vote up
public static Action decorateWithLogging(final SwingLogPanel log, final Pref< ? > pref, final Action action) {
    if (log == null)
        return action;
    return new AbstractAction((String) action.getValue(Action.NAME), (Icon) action.getValue(Action.SMALL_ICON)) {

        private static final long serialVersionUID = -2790668001235140089L;

        @Override
        public void actionPerformed(ActionEvent e) {
            Object oldVal = pref.get();
            action.actionPerformed(e);
            Object newVal = pref.get();
            if (!newVal.equals(oldVal))
                logPrefChanged(log, pref);
        }
    };
}
 
Example #5
Source File: JExtendedRadioButton.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createExtraIcon() {
    JRadioButton reference = new JRadioButton();
    int iconTextGap = reference.getIconTextGap();

    Icon disabledIcon = getDisabledIconSafe(reference);
    Icon disabledSelectedIcon = getDisabledSelectedIconSafe(reference);
    Icon icon = getIconSafe(reference);
    Icon pressedIcon = getPressedIconSafe(reference);
    Icon rolloverIcon = getRolloverIconSafe(reference);
    Icon rolloverSelectedIcon = getRolloverSelectedIconSafe(reference);
    Icon selectedIcon = getSelectedIconSafe(reference);

    setDisabledIcon((disabledIcon == null) ? extraIcon : new DoubleIcon(disabledIcon, extraIcon, iconTextGap));
    setDisabledSelectedIcon((disabledSelectedIcon == null) ? extraIcon
                                                           : new DoubleIcon(disabledSelectedIcon, extraIcon, iconTextGap));
    setIcon((icon == null) ? extraIcon : new DoubleIcon(icon, extraIcon, iconTextGap));
    setPressedIcon((pressedIcon == null) ? extraIcon : new DoubleIcon(pressedIcon, extraIcon, iconTextGap));
    setRolloverIcon((rolloverIcon == null) ? extraIcon : new DoubleIcon(rolloverIcon, extraIcon, iconTextGap));
    setRolloverSelectedIcon((rolloverSelectedIcon == null) ? extraIcon
                                                           : new DoubleIcon(rolloverSelectedIcon, extraIcon, iconTextGap));
    setSelectedIcon((selectedIcon == null) ? extraIcon : new DoubleIcon(selectedIcon, extraIcon, iconTextGap));
}
 
Example #6
Source File: ProfilerTabbedPane.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void addTab(String title, Icon icon, final Component component, String tip, boolean closable) {
    int tabCount = getTabCount();

    if (component.getMouseWheelListeners().length == 0 && UIUtils.isAquaLookAndFeel()) {
        component.addMouseWheelListener(new MouseWheelListener() {
            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                // GH-122
            }
        });
    }
    super.addTab(title, icon, component, tip);
    
    Runnable closer = closable ? new Runnable() {
        public void run() {
            closeTab(component);
        }
    } : null;
    
    setTabComponentAt(tabCount, new TabCaption(title, icon, closer));
}
 
Example #7
Source File: SynthTableUI.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void uninstallDefaults() {
    table.setDefaultRenderer(Date.class, dateRenderer);
    table.setDefaultRenderer(Number.class, numberRenderer);
    table.setDefaultRenderer(Double.class, doubleRender);
    table.setDefaultRenderer(Float.class, floatRenderer);
    table.setDefaultRenderer(Icon.class, iconRenderer);
    table.setDefaultRenderer(ImageIcon.class, imageIconRenderer);
    table.setDefaultRenderer(Boolean.class, booleanRenderer);
    table.setDefaultRenderer(Object.class, objectRenderer);

    if (table.getTransferHandler() instanceof UIResource) {
        table.setTransferHandler(null);
    }
    SynthContext context = getContext(table, ENABLED);
    style.uninstallDefaults(context);
    context.dispose();
    style = null;
}
 
Example #8
Source File: GuiShowDrinkingContestResult.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void drinkingContestFinished(WorldObject performer, WorldObject target, int goldWon) {
	Icon performerIcon = IconUtils.getWorldObjectIcon(performer, imageInfoReader);
	Icon targetIcon = IconUtils.getWorldObjectIcon(target, imageInfoReader);
	String[] responses = getResponses(goldWon);
	
	if (!performer.isControlledByAI()) {
		//TODO: handle response
		String response = new ListInputDialog("Choose drinking contest ending line:", targetIcon, new ListData(responses), imageInfoReader, soundIdReader, parentFrame).showMe();
	}
	
	if (!target.isControlledByAI()) {
		container.setStatusMessage(IconUtils.getWorldObjectImage(performer, imageInfoReader), responses[0]);
	}
	
}
 
Example #9
Source File: Notifier.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
void showException(KonException ex) {
    if (ex.getError() == KonException.Error.LOAD_KEY_DECRYPT) {
        mView.showPasswordDialog(true);
        return;
    }
    Icon icon = NotificationIcon.error.getIcon();
    NotificationManager.showNotification(mWindow, textArea(Utils.getErrorText(ex)), icon);
}
 
Example #10
Source File: AquaFileView.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Icon getIcon(final File f) {
    final FileInfo info = getFileInfoFor(f);
    if (info.icon != null) return info.icon;

    if (f == null) {
        info.icon = AquaIcon.SystemIcon.getDocumentIconUIResource();
    } else {
        // Look for the document's icon
        final AquaIcon.FileIcon fileIcon = new AquaIcon.FileIcon(f);
        info.icon = fileIcon;
        if (!fileIcon.hasIconRef()) {
            // Fall back on the default icons
            if (f.isDirectory()) {
                if (fFileChooserUI.getFileChooser().getFileSystemView().isRoot(f)) {
                    info.icon = AquaIcon.SystemIcon.getComputerIconUIResource();
                } else if (f.getParent() == null || f.getParent().equals("/")) {
                    info.icon = AquaIcon.SystemIcon.getHardDriveIconUIResource();
                } else {
                    info.icon = AquaIcon.SystemIcon.getFolderIconUIResource();
                }
            } else {
                info.icon = AquaIcon.SystemIcon.getDocumentIconUIResource();
            }
        }
    }

    return info.icon;
}
 
Example #11
Source File: Utility.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a button suitable for linking to another panel
 * (e.g. ColopediaPanel).
 *
 * @param text a {@code String} value
 * @param icon an {@code Icon} value
 * @param action a {@code String} value
 * @return a {@code JButton} value
 */
public static JButton getLinkButton(String text, Icon icon, String action) {
    JButton button = new JButton(text, icon);
    button.setMargin(EMPTY_MARGIN);
    button.setOpaque(false);
    button.setForeground(LINK_COLOR);
    button.setAlignmentY(0.8f);
    button.setBorder(blankBorder(0, 0, 0, 0));
    button.setActionCommand(action);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    return button;
}
 
Example #12
Source File: Actions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure an icon is not null, so that e.g. menu items for javax.swing.Action's
 * with no specified icon are correctly aligned. SystemAction already does this so
 * that is not affected.
 */
private static Icon nonNullIcon(Icon i) {
    return null;

    /*if (i != null) {
        return i;
    } else {
        if (BLANK_ICON == null) {
            BLANK_ICON = new ImageIcon(Utilities.loadImage("org/openide/resources/actions/empty.gif", true)); // NOI18N
        }
        return BLANK_ICON;
    }*/
}
 
Example #13
Source File: LogicalViewProviders.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Image getIcon(int type) {
    final Icon icon = info.getIcon();
    final Image img = icon == null ?
        super.getIcon(type) :
        ImageUtilities.icon2Image(icon);
    return !broken && compileOnSaveDisabled ?
        ImageUtilities.mergeImages(img, compileOnSaveDisabledBadge, 8, 0) :
        img;
}
 
Example #14
Source File: ChartPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateAction() {
    boolean fitsWidth = chart.fitsWidth();
    Icon icon = fitsWidth ? FIXED_SCALE_ICON : SCALE_TO_FIT_ICON;
    String name = fitsWidth ? Bundle.ACTION_FixedScale_name() : Bundle.ACTION_ScaleToFit_name();
    putValue(SHORT_DESCRIPTION, name);
    putValue(SMALL_ICON, icon);
}
 
Example #15
Source File: BootCPNodeFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private List<SourceGroup> getKeys () {
    final FileObject[] roots = ((JRENode)this.getNode()).pp.getBootstrapLibraries();
    if (roots.length == 0) {
        return Collections.<SourceGroup>emptyList();
    }
    final List<SourceGroup> result = new ArrayList<>(roots.length);
    for (FileObject root : roots) {
            FileObject file;
            Icon icon;
            Icon openedIcon;
            switch (root.toURL().getProtocol()) {
                case "jar":
                    file = FileUtil.getArchiveFile (root);
                    icon = openedIcon = ImageUtilities.loadImageIcon(ARCHIVE_ICON, false);
                    break;
                case "nbjrt":
                    file = root;
                    icon = openedIcon = ImageUtilities.loadImageIcon(MODULE_ICON, false);
                    break;
                default:
                    file = root;
                    icon = openedIcon = null;
            }
            if (file.isValid()) {
                result.add (new LibrariesSourceGroup(root,file.getNameExt(),icon, openedIcon));
            }
    }
    return result;
}
 
Example #16
Source File: AnalyzerUtil.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private static Icon getIconForFunctionSignatureChanged() {
	Icon baseIcon = new TranslateIcon(ResourceManager.getScaledIcon(
		ResourceManager.loadImage("images/FunctionScope.gif"), 22, 22), 10, 5);
	Icon pencilIcon = ResourceManager.loadImage("images/pencil.png");
	MultiIcon multiIcon = new MultiIcon(baseIcon, false, 32, 32);
	multiIcon.addIcon(pencilIcon);
	return multiIcon;
}
 
Example #17
Source File: JTextPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTextPane.insertIcon(Icon)} through queue
 */
public void insertIcon(final Icon icon) {
    runMapping(new MapVoidAction("insertIcon") {
        @Override
        public void map() {
            ((JTextPane) getSource()).insertIcon(icon);
        }
    });
}
 
Example #18
Source File: NameStateRenderer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Icon getIcon(byte state) {
    Icon icon = STATE_ICONS_CACHE.get(state);
    
    if (icon == null) {
        icon = new ThreadStateIcon(state, THREAD_ICON_SIZE, THREAD_ICON_SIZE);
        STATE_ICONS_CACHE.put(state, icon);
    }
    
    return icon;
}
 
Example #19
Source File: AlwaysEnabledAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Icon getIcon() {
    Icon retValue = super.getIcon();
    if( null == retValue && (null == getText() || getText().isEmpty()) ) {
        if (unknownIcon == null) {
            unknownIcon = ImageUtilities.loadImageIcon("org/openide/awt/resources/unknown.gif", false); //NOI18N
            //unknownIcon = ImageUtilities.loadImageIcon("org/openide/loaders/unknown.gif", false); //NOI18N
        }
        retValue = unknownIcon;
    }
    return retValue;
}
 
Example #20
Source File: TeamServicesSettingsModelTest.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Test
public void testDeletePasswords_Cancel() {
    teamServicesSettingsModel.getTableSelectionModel().setSelectionInterval(0, 0);
    when(Messages.showYesNoDialog(mockProject, TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_DELETE_MSG), TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_DELETE_TITLE), Messages.getQuestionIcon())).thenReturn(Messages.CANCEL);
    teamServicesSettingsModel.getTableModel().addServerContexts(new ArrayList<ServerContext>(ImmutableList.of(mockServerContext_GitRepo, mockServerContext_TfvcRepo)));
    teamServicesSettingsModel.deletePasswords();

    assertEquals(0, teamServicesSettingsModel.getDeleteContexts().size());
    assertEquals(2, teamServicesSettingsModel.getTableModel().getRowCount());
    assertEquals(mockServerContext_TfvcRepo, teamServicesSettingsModel.getTableModel().getServerContext(0));
    assertEquals(mockServerContext_GitRepo, teamServicesSettingsModel.getTableModel().getServerContext(1));
    verifyStatic(times(1));
    Messages.showYesNoDialog(eq(mockProject), eq(TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_DELETE_MSG)), eq(TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_DELETE_TITLE)), any(Icon.class));
}
 
Example #21
Source File: MinMaxCategoryRenderer.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an icon.
 *
 * @param shape  the shape.
 * @param fill  the fill flag.
 * @param outline  the outline flag.
 *
 * @return The icon.
 */
private Icon getIcon(Shape shape, final boolean fill, 
                     final boolean outline) {
    final int width = shape.getBounds().width;
    final int height = shape.getBounds().height;
    final GeneralPath path = new GeneralPath(shape);
    return new Icon() {
        public void paintIcon(Component c, Graphics g, int x, int y) {
            Graphics2D g2 = (Graphics2D) g;
            path.transform(AffineTransform.getTranslateInstance(x, y));
            if (fill) {
                g2.fill(path);
            }
            if (outline) {
                g2.draw(path);
            }
            path.transform(AffineTransform.getTranslateInstance(-x, -y));
        }

        public int getIconWidth() {
            return width;
        }

        public int getIconHeight() {
            return height;
        }
    };
}
 
Example #22
Source File: AsyncDialog.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
public void showOptionDialog(Component frame, Object message, String title, int optionType, int messageType,
		Icon icon, Object[] options, Object initialValue, ActionListener a) {
	actionListener = a;
	this.options = options;
	setListener(a);
	process(JOptionPane.showOptionDialog(frame, message, title, optionType, messageType, icon, options,
			initialValue));
	unsetListener();
}
 
Example #23
Source File: AssociationTest.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
public DisplayInfo( String name, String description, String toolTip, Icon icon )
{
    this.name = name;
    this.description = description;
    this.toolTip = toolTip;
    this.icon = icon;
}
 
Example #24
Source File: FileIconDemo.java    From pumpernickel with MIT License 5 votes vote down vote up
protected void refreshFile() {
	File file = new File(filePathField.getText());
	Icon icon;
	FileIcon fileIcon = getFileIcon();
	fileLabel.setText("");
	if (!file.exists()) {
		icon = new StrikeThroughIcon(Color.gray, 20);
		fileLabel.setText("File Missing");
	} else if (fileIcon != null) {
		icon = fileIcon.getIcon(file, false);
	} else {
		icon = UIManager.getIcon("FileView.fileIcon");
		fileLabel.setText("FileView.fileIcon");
	}
	int w = icon.getIconWidth();
	int h = icon.getIconHeight();
	if (sizeSlider.isEnabled()) {
		int m = sizeSlider.getValue();
		Dimension d = Dimension2D.scaleProportionally(new Dimension(w, h),
				new Dimension(m, m));
		if (d.width != w || d.height != h) {
			icon = IconUtils.createScaledIcon(icon, d.width, d.height);
			if (fileLabel.getText().length() == 0) {
				fileLabel.setText("Scaled");
			} else {
				fileLabel.setText(fileLabel.getText() + " - Scaled");
			}
		}
	} else if (!sizeSliderUsed) {
		sizeSlider.setValue(Math.max(w, h));
	}
	fileLabel.setIcon(icon);
}
 
Example #25
Source File: QuerySupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public AntUpdateHelper(UpdateHelper updateHelper, Project project, Icon icon, String elementName) {
    super(project, icon, elementName);
    this.updateHelper = updateHelper;

    AntProjectHelper projectHelper = updateHelper.getAntProjectHelper();
    projectHelper.addAntProjectListener(WeakListeners.create(AntProjectListener.class, this, projectHelper));
}
 
Example #26
Source File: DropDownButton.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void setRolloverIcon(Icon icon) {
    Icon arrow = updateIcons( icon, ICON_ROLLOVER );
    arrowIcons.remove( ICON_ROLLOVER_LINE );
    arrowIcons.remove( ICON_ROLLOVER_SELECTED_LINE );
    super.setRolloverIcon( hasPopupMenu() ? arrow : icon );
}
 
Example #27
Source File: IOTab.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sets icon to tab corresponding to specified IO
 * @param io IO to operate on
 * @param icon tab icon
 */
public static void setIcon(InputOutput io, Icon icon) {
    IOTab iot = find(io);
    if (iot != null) {
        iot.setIcon(icon);
    }
}
 
Example #28
Source File: FunctionBitPatternsGTreeNode.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public Icon getIcon(boolean expanded) {
	if (getChildren() == null || getChildren().isEmpty()) {
		return DISABLED_ICON;
	}
	return ENABLED_ICON;
}
 
Example #29
Source File: SynthTreeUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void drawCentered(Component c, Graphics graphics, Icon icon,
                            int x, int y) {
    int w = SynthIcon.getIconWidth(icon, paintContext);
    int h = SynthIcon.getIconHeight(icon, paintContext);

    SynthIcon.paintIcon(icon, paintContext, graphics,
                        findCenteredX(x, w),
                        y - h/2, w, h);
}
 
Example #30
Source File: JLabelTextComponent.java    From blog with Apache License 2.0 4 votes vote down vote up
public JLabelTextComponent(String text, Icon icon, int horizontalAlignment) {
	super(text, icon, horizontalAlignment);
	initDocument(document);
	setDocument(document);
}