类javax.swing.Icon源码实例Demo

下面列出了怎么用javax.swing.Icon的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: org.alloytools.alloy   文件: PreferencesDialog.java
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);
        }
    };
}
 
@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;
}
 
源代码3 项目: ghidra   文件: AnalyzerUtil.java
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");

	}
}
 
源代码4 项目: netbeans   文件: JExtendedRadioButton.java
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));
}
 
源代码5 项目: visualvm   文件: ProfilerTabbedPane.java
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));
}
 
源代码6 项目: openjdk-8   文件: SynthTableUI.java
/**
 * {@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;
}
 
@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]);
	}
	
}
 
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);
}
 
源代码9 项目: ghidra   文件: AnalyzerUtil.java
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;
}
 
@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));
}
 
源代码11 项目: netbeans   文件: Actions.java
/**
 * 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;
    }*/
}
 
源代码12 项目: freecol   文件: Utility.java
/**
 * 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;
}
 
源代码13 项目: jdk8u60   文件: AquaFileView.java
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;
}
 
源代码14 项目: desktopclient-java   文件: Notifier.java
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);
}
 
源代码15 项目: netbeans   文件: ChartPanel.java
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);
}
 
源代码16 项目: netbeans   文件: LogicalViewProviders.java
@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;
}
 
源代码17 项目: netbeans   文件: BootCPNodeFactory.java
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;
}
 
源代码18 项目: openjdk-jdk9   文件: JTextPaneOperator.java
/**
 * 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);
        }
    });
}
 
源代码19 项目: netbeans   文件: AlwaysEnabledAction.java
@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;
}
 
源代码20 项目: netbeans   文件: NameStateRenderer.java
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;
}
 
源代码21 项目: opensim-gui   文件: MinMaxCategoryRenderer.java
/**
 * 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;
        }
    };
}
 
源代码22 项目: osp   文件: AsyncDialog.java
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();
}
 
源代码23 项目: attic-polygene-java   文件: AssociationTest.java
public DisplayInfo( String name, String description, String toolTip, Icon icon )
{
    this.name = name;
    this.description = description;
    this.toolTip = toolTip;
    this.icon = icon;
}
 
源代码24 项目: pumpernickel   文件: FileIconDemo.java
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);
}
 
源代码25 项目: netbeans   文件: QuerySupport.java
@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));
}
 
源代码26 项目: netbeans   文件: DropDownButton.java
@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 );
}
 
源代码27 项目: netbeans   文件: IOTab.java
/**
 * 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);
    }
}
 
源代码28 项目: ghidra   文件: FunctionBitPatternsGTreeNode.java
@Override
public Icon getIcon(boolean expanded) {
	if (getChildren() == null || getChildren().isEmpty()) {
		return DISABLED_ICON;
	}
	return ENABLED_ICON;
}
 
源代码29 项目: dragonwell8_jdk   文件: SynthTreeUI.java
/**
 * {@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);
}
 
源代码30 项目: snap-desktop   文件: TableViewPagePanel.java
public TableViewPagePanel(TopComponent topComponent, String helpId, String titlePrefix, Icon iconForSwitchToChartButton) {
    super(topComponent, helpId, titlePrefix);
    this.iconForSwitchToChartButton = iconForSwitchToChartButton;
}
 
 类所在包
 同包方法