本文整理汇总了Java中javax.swing.Icon类的典型用法代码示例。如果您正苦于以下问题:Java Icon类的具体用法?Java Icon怎么用?Java Icon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Icon类属于javax.swing包,在下文中一共展示了Icon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreferredSize
import javax.swing.Icon; //导入依赖的package包/类
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
if (PREFERRED_HEIGHT == -1) {
GenericToolbar tb = new GenericToolbar();
tb.setBorder(getBorder());
tb.setBorderPainted(isBorderPainted());
tb.setRollover(isRollover());
tb.setFloatable(isFloatable());
Icon icon = Icons.getIcon(GeneralIcons.SAVE);
tb.add(new JButton("Button", icon)); // NOI18N
tb.add(new JToggleButton("Button", icon)); // NOI18N
tb.add(new JTextField("Text")); // NOI18N
JComboBox c = new JComboBox();
c.setEditor(new BasicComboBoxEditor());
c.setRenderer(new BasicComboBoxRenderer());
tb.add(c);
tb.addSeparator();
PREFERRED_HEIGHT = tb.getSuperPreferredSize().height;
}
dim.height = getParent() instanceof JToolBar ? 1 :
Math.max(dim.height, PREFERRED_HEIGHT);
return dim;
}
示例2: uninstallDefaults
import javax.swing.Icon; //导入依赖的package包/类
/**
* {@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;
}
示例3: makeInfoPanel
import javax.swing.Icon; //导入依赖的package包/类
private JPanel makeInfoPanel(String message, Icon icon) {
JLabel infoIcon = new JLabel(icon);
infoIcon.setVerticalAlignment(SwingConstants.TOP);
JPanel infoPanel = new JPanel(new BorderLayout(20, 0));
infoPanel.setBorder(BorderFactory.createEmptyBorder(12, 16, 16, 4));
infoPanel.add(infoIcon, BorderLayout.WEST);
int width;
if (centerComponent != null) {
width = (int) centerComponent.getPreferredSize().getWidth() - 88; // icon plus padding
if (width < 420) {
width = 420;
}
} else {
width = 420;
}
infoTextLabel = new FixedWidthEditorPane(width, message);
// set the background as for infoPanel such that infoTextLabel looks like a JLabel
infoTextLabel.setBackground(infoPanel.getBackground());
infoPanel.add(infoTextLabel, BorderLayout.CENTER);
return infoPanel;
}
示例4: getIcon
import javax.swing.Icon; //导入依赖的package包/类
private static Icon getIcon(Prop prop) {
String cacheKey = Game.getEnvironment().getMap().getName() + "-" + prop.getName() + "-" + prop.getMapId() + "-tree";
BufferedImage propImag;
if (ImageCache.IMAGES.containsKey(cacheKey)) {
propImag = ImageCache.IMAGES.get(cacheKey);
} else {
final String name = "prop-" + prop.getSpritesheetName().toLowerCase() + "-" + PropState.INTACT.toString().toLowerCase();
final String fallbackName = "prop-" + prop.getSpritesheetName().toLowerCase();
Spritesheet sprite = Spritesheet.find(name);
if (sprite == null) {
sprite = Spritesheet.find(fallbackName);
}
if (sprite == null) {
return null;
}
propImag = ImageProcessing.scaleImage(sprite.getSprite(0), 16, 16, true);
ImageCache.IMAGES.put(cacheKey, propImag);
}
return new ImageIcon(propImag);
}
示例5: getIcon
import javax.swing.Icon; //导入依赖的package包/类
private Icon getIcon(String plotterName, boolean selected) {
// check to decide which icon size should be loaded
if (!isSmallIconsUsed()) {
if (selected) {
return SwingTools.createImage("icons/chartPreview/" + ICON_SIZE + "/" + plotterName.replace(' ', '_')
+ ".png");
} else {
return SwingTools.createImage("icons/chartPreview/" + ICON_SIZE + "/" + plotterName.replace(' ', '_')
+ "-grey.png");
}
} else {
if (selected) {
return SwingTools.createImage("icons/chartPreview/" + SMALL_ICON_SIZE + "/"
+ plotterName.replace(' ', '_') + ".png");
} else {
return SwingTools.createImage("icons/chartPreview/" + SMALL_ICON_SIZE + "/"
+ plotterName.replace(' ', '_') + "-grey.png");
}
}
}
示例6: createMenuIcon
import javax.swing.Icon; //导入依赖的package包/类
private static Icon createMenuIcon(Icon icon, Component decorator) {
int h = menuIconSize();
int w = UIUtils.isAquaLookAndFeel() ? h + 4 : h;
BufferedImage i = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics g = i.getGraphics();
if (decorator != null) {
decorator.setSize(w, h);
decorator.paint(g);
}
icon.paintIcon(null, g, (w - icon.getIconWidth()) / 2, (h - icon.getIconHeight()) / 2);
g.dispose();
return new ImageIcon(i);
}
示例7: paintIcon
import javax.swing.Icon; //导入依赖的package包/类
@Override
public void paintIcon(ComponentDrawContext c, int x, int y) {
FactoryDescription desc = description;
if (desc != null && !desc.isFactoryLoaded()) {
Icon icon = desc.getIcon();
if (icon != null) {
icon.paintIcon(c.getDestination(), c.getGraphics(), x + 2, y + 2);
return;
}
}
ComponentFactory source = getFactory();
if (source != null) {
AttributeSet base = getBaseAttributes();
source.paintIcon(c, x, y, base);
}
}
示例8: getIcon
import javax.swing.Icon; //导入依赖的package包/类
public @Override Icon getIcon(File _f) {
File f = FileUtil.normalizeFile(_f);
Icon original = fsv.getSystemIcon(f);
if (original == null) {
// L&F (e.g. GTK) did not specify any icon.
original = EMPTY;
}
if ( isPlatformDir( f ) ) {
if ( original.equals( lastOriginal ) ) {
return lastMerged;
}
lastOriginal = original;
lastMerged = new MergedIcon(original, BADGE, -1, -1);
return lastMerged;
}
else {
return original;
}
}
示例9: getIconsForOpenProjects
import javax.swing.Icon; //导入依赖的package包/类
/**
* @return map of maven artifact mapped to project icon
*/
private Map<Artifact, Icon> getIconsForOpenProjects() {
Map<Artifact, Icon> result = new HashMap<Artifact, Icon>();
//NOTE: surely not the best way to get the project icon
Project[] openProjects = OpenProjects.getDefault().getOpenProjects();
for (Project project : openProjects) {
NbMavenProject mavenProject = project.getLookup().lookup(NbMavenProject.class);
if (null != mavenProject) {
Artifact artifact = mavenProject.getMavenProject().getArtifact();
//get icon from opened project
Icon icon = ProjectUtils.getInformation(project).getIcon();
if (null != icon) {
result.put(artifact, icon);
}
}
}
return result;
}
示例10: getCloseTabImage
import javax.swing.Icon; //导入依赖的package包/类
private static Icon getCloseTabImage() {
if( null == closeTabImage ) {
String path = UIManager.getString("nb.close.tab.icon.enabled.name" ); //NOI18N
if( null != path ) {
closeTabImage = ImageUtilities.loadImageIcon(path, true); // NOI18N
}
}
if( null == closeTabImage ) {
if( isWindows8LaF() || isWindows10LaF() ) {
closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/win8_bigclose_enabled.png", true); // NOI18N
} else if( isWindowsVistaLaF() ) {
closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/vista_close_enabled.png", true); // NOI18N
} else if( isWindowsXPLaF() ) {
closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/xp_close_enabled.png", true); // NOI18N
} else if( isWindowsLaF() ) {
closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/win_close_enabled.png", true); // NOI18N
} else if( isAquaLaF() ) {
closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/mac_close_enabled.png", true); // NOI18N
} else if( isGTKLaF() ) {
closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/gtk_close_enabled.png", true); // NOI18N
} else {
closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/metal_close_enabled.png", true); // NOI18N
}
}
return closeTabImage;
}
示例11: getModuleDirectiveIcon
import javax.swing.Icon; //导入依赖的package包/类
/**
* Returns an icon for the given {@link ModuleElement.DirectiveKind}.
* @param kind the {@link ModuleElement.DirectiveKind} to return an icon for.
* @return the icon
* @since 1.45
*/
public static Icon getModuleDirectiveIcon(@NonNull final ModuleElement.DirectiveKind kind) {
Parameters.notNull("kind", kind); //NOI18N
switch (kind) {
case EXPORTS:
return ImageUtilities.loadImageIcon(EXPORTS_ICON, true);
case REQUIRES:
return ImageUtilities.loadImageIcon(REQUIRES_ICON, true);
case USES:
return ImageUtilities.loadImageIcon(USES_ICON, true);
case PROVIDES:
return ImageUtilities.loadImageIcon(PROVIDES_ICON, true);
case OPENS:
return ImageUtilities.loadImageIcon(OPENS_ICON, true);
default:
throw new IllegalArgumentException(kind.toString());
}
}
示例12: createTab
import javax.swing.Icon; //导入依赖的package包/类
/**
* Creates a tabpage title component with close button and registers it to
* hidden tabs
*
* @return the new tab
*/
private JPanel createTab(String title, Icon icon, final Component component) {
JPanel tab = new JPanel(new BorderLayout(0, 0));
tab.setOpaque(false);
JLabel lbl = new JLabel(title, icon, SwingConstants.LEFT);
tab.add(lbl, BorderLayout.WEST);
return tab;
}
示例13: createHeaderButton
import javax.swing.Icon; //导入依赖的package包/类
/**
* Creates a new button for displaying on the left hand side.
*/
private JButton createHeaderButton(String text, String iconPath)
{
Icon icon = new ImageIcon(Editor.class.getResource(iconPath));
JButton button = new JButton(text, icon);
button.setBorderPainted(false);
button.setContentAreaFilled(false);
button.addActionListener(buttonListener);
return button;
}
示例14: mergeIcons
import javax.swing.Icon; //导入依赖的package包/类
/**
* Utility method merging 2 icons.
*/
private static Icon mergeIcons(Icon icon1, Icon icon2, int x, int y, Component c) {
int w = 0, h = 0;
if (icon1 != null) {
w = icon1.getIconWidth();
h = icon1.getIconHeight();
}
if (icon2 != null) {
w = icon2.getIconWidth() + x > w ? icon2.getIconWidth() + x : w;
h = icon2.getIconHeight() + y > h ? icon2.getIconHeight() + y : h;
}
if (w < 1) w = 16;
if (h < 1) h = 16;
java.awt.image.ColorModel model = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment ().
getDefaultScreenDevice ().getDefaultConfiguration ().
getColorModel (java.awt.Transparency.BITMASK);
java.awt.image.BufferedImage buffImage = new java.awt.image.BufferedImage (model,
model.createCompatibleWritableRaster (w, h), model.isAlphaPremultiplied (), null);
java.awt.Graphics g = buffImage.createGraphics ();
if (icon1 != null) {
icon1.paintIcon(c, g, 0, 0);
}
if (icon2 != null) {
icon2.paintIcon(c, g, x, y);
}
g.dispose();
return new ImageIcon(buffImage);
}
示例15: _getRolloverSelectedIcon
import javax.swing.Icon; //导入依赖的package包/类
private Icon _getRolloverSelectedIcon() {
Icon icon = null;
icon = arrowIcons.get( mouseInArrowArea ? ICON_ROLLOVER_SELECTED : ICON_ROLLOVER_SELECTED_LINE );
if( null == icon ) {
Icon orig = regIcons.get( ICON_ROLLOVER_SELECTED );
if( null == orig )
orig = regIcons.get( ICON_ROLLOVER );
if( null == orig )
orig = regIcons.get( ICON_NORMAL );
icon = new IconWithArrow( orig, !mouseInArrowArea );
arrowIcons.put( mouseInArrowArea ? ICON_ROLLOVER_SELECTED : ICON_ROLLOVER_SELECTED_LINE, icon );
}
return icon;
}