当前位置: 首页>>代码示例>>Java>>正文


Java JLabel.setIcon方法代码示例

本文整理汇总了Java中javax.swing.JLabel.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setIcon方法的具体用法?Java JLabel.setIcon怎么用?Java JLabel.setIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JLabel的用法示例。


在下文中一共展示了JLabel.setIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table,
        Object value,
        boolean isSelected,
        boolean hasFocus,
        int row,
        int column) {
    Component c = tableCellRenderer.getTableCellRendererComponent(table,
            value, isSelected, hasFocus, row, column);
    if (c instanceof JLabel) {
        JLabel l = (JLabel) c;
        l.setHorizontalTextPosition(JLabel.LEFT);
        int modelColumn = table.convertColumnIndexToModel(column);
        l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
    }
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TableSorter.java

示例2: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                                              boolean cellHasFocus) {
    JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    renderer.setBorder(BorderFactory.createEmptyBorder(1, 7, 1, 5));

    if (value instanceof ProfilingPoint) {
        boolean enabled = ((ProfilingPoint) value).isEnabled();
        renderer.setText(((ProfilingPoint) value).getName());
        renderer.setIcon(enabled ? ((ProfilingPoint) value).getFactory().getIcon() :
                                   ((ProfilingPoint) value).getFactory().getDisabledIcon());
        renderer.setEnabled(enabled);
    } else if (value instanceof ProfilingPointFactory) {
        renderer.setText(((ProfilingPointFactory) value).getType());
        renderer.setIcon(((ProfilingPointFactory) value).getIcon());
        renderer.setEnabled(true);
    } else {
        renderer.setIcon(null);
        renderer.setEnabled(true);
    }

    return renderer;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Utils.java

示例3: getTreeCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getTreeCellRendererComponent (
    JTree tree, Object value,
    boolean sel,
    boolean expanded,
    boolean leaf, int row,
    boolean hasFocus
) {
    JLabel l = (JLabel) super.getTreeCellRendererComponent (
        tree, value, sel, expanded, leaf, row, hasFocus
    );

    if (value instanceof DefaultMutableTreeNode) {
        l.setIcon (null);
        l.setText ((String) ((DefaultMutableTreeNode) value).getUserObject ());
        return l;
    }
    LanguagesNavigatorModel model = (LanguagesNavigatorModel) tree.getModel ();
    l.setIcon (getCIcon (model.getIcon (value)));
    l.setText (model.getDisplayName (value));
    return l;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:LanguagesNavigator.java

示例4: SpecialDiceButton

import javax.swing.JLabel; //导入方法依赖的package包/类
public SpecialDiceButton() {
  dialog = new JDialog(GameModule.getGameModule().getFrame());
  dialog.setLayout(new MigLayout("ins 0"));
  dialogLabel = new JLabel();
  dialogLabel.setIcon(resultsIcon);
  dialog.add(dialogLabel);
  final ActionListener rollAction = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      DR();
    }
  };
  launch = new LaunchButton(null, TOOLTIP, BUTTON_TEXT, HOTKEY, ICON, rollAction);
  final String desc = Resources.getString("Editor.SpecialDiceButton.symbols"); //$NON-NLS-1$
  setAttribute(NAME, desc);
  setAttribute(BUTTON_TEXT, desc);
  launch.setAttribute(TOOLTIP, desc);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:18,代码来源:SpecialDiceButton.java

示例5: showSplash

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
开发者ID:ser316asu,项目名称:SER316-Aachen,代码行数:20,代码来源:App.java

示例6: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	JLabel listCellRendererComponent = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
			isSelected, cellHasFocus);

	String text = textCache.get(value);
	ImageIcon icon = iconCache.get(value);
	if (text == null) {

		// get enum text
		text = I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.label." + i18nKeyPrefix + "." + value + ".label");
		if (text != null) {
			textCache.put(value, text);
		} else {
			text = i18nKeyPrefix + "." + value;
		}

		// create label icon
		String iconId = I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.label." + i18nKeyPrefix + "." + value + ".icon");
		if (iconId != null) {
			icon = SwingTools.createIcon("16/" + iconId);
			iconCache.put(value, icon);
		}
	}

	// set text and icon
	listCellRendererComponent.setText(text);
	listCellRendererComponent.setIcon(icon);

	return listCellRendererComponent;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:33,代码来源:EnumComboBoxCellRenderer.java

示例7: setPie1

import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel setPie1() {
	int[] angle = new int[numClust];
	double[] prc = info.percent;
	int i;

	angle[0] = 0;
	for (i = 1; i < numClust; i++) {
		angle[i] = angle[i - 1] + (int) ((360) * prc[i - 1]);
	}
	for (; i < angle.length; i++) {
		angle[i] = 360;
	}
	final JLabel l = new JLabel();
	final pieChartIcon p = new pieChartIcon(numClust);
	l.addMouseMotionListener(new MouseMotionAdapter() {
		@Override
		public void mouseMoved(MouseEvent e) {
			int pos;

			pos = p.getPosXY(e.getX(), e.getY());

			if (pos != -1) {
				l.setToolTipText(tableClusters.getValueAt(pos, 2).toString());
			} else {
				l.setToolTipText("");
			}
		}
	});
	p.setAngle(angle);
	l.setIcon(p);
	return l;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:33,代码来源:KMeansInfoClustering.java

示例8: JWatMainPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
public JWatMainPanel(MainJwatWizard parent) {
	this.parent = parent;
	this.help = parent.getHelp();
	this.setLayout(new BorderLayout());
	JPanel upper = new JPanel(new FlowLayout());
	JLabel upperLabel = new JLabel();
	upperLabel.setPreferredSize(new Dimension(300, 10));
	upper.add(upperLabel);

	JPanel bottom = new JPanel(new FlowLayout());
	JLabel bottomLabel = new JLabel();
	bottomLabel.setPreferredSize(new Dimension(300, 10));
	bottom.add(bottomLabel);

	this.add(upper, BorderLayout.NORTH);
	this.add(bottom, BorderLayout.SOUTH);

	JPanel eastPanel = new JPanel(new FlowLayout());
	eastPanel.add(Box.createVerticalStrut(5), BorderLayout.NORTH);
	JPanel buttonPanel = new JPanel(new GridLayout(buttonAction.length, 1, 2, 15));
	eastPanel.add(buttonPanel, BorderLayout.CENTER);
	for (AbstractAction element : buttonAction) {
		buttonPanel.add(createButton(element));
	}
	JLabel imageLabel = new JLabel();
	imageLabel.setBorder(BorderFactory.createEmptyBorder(BUTTONSIZE - 5, 1, 0, 0));
	//imageLabel.setIcon(new ImageIcon(image));
	imageLabel.setIcon(new ImageIcon(new ImageIcon(imageURL).getImage().getScaledInstance(400, 315, Image.SCALE_SMOOTH)));
	imageLabel.setHorizontalAlignment(SwingConstants.RIGHT);
	imageLabel.setVerticalAlignment(SwingConstants.NORTH);

	//JLabel description = new JLabel("<html><body><h3>This is a simple<br>descirption added to this<br>page. Please do not mind it<br>will be replaced soon</h3></body></html>");
	//this.add(description,BorderLayout.WEST);
	this.add(imageLabel, BorderLayout.CENTER);
	this.add(eastPanel, BorderLayout.EAST);
	makeToolbar();
	makeMenubar();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:39,代码来源:JWatMainPanel.java

示例9: PinDialog

import javax.swing.JLabel; //导入方法依赖的package包/类
public PinDialog() throws Exception {
    super(noParentFrame, "PIN Dialog", true);

    final JPanel captchaPanel = new JPanel();
    captchaPanel.setLayout(new BoxLayout(captchaPanel, BoxLayout.Y_AXIS));

    final JLabel captchaImage = new JLabel();
    captchaImage.setIcon(new ImageIcon(client.getCaptchaImage(liveURL)));
    captchaPanel.add(captchaImage);

    captchaPanel.add(pinfield);
    getContentPane().add(captchaPanel);

    final JPanel buttonPane = new JPanel();

    final JButton btnLogin = new JButton("Login");
    buttonPane.add(btnLogin);
    btnLogin.addActionListener(e -> {
        setVisible(false);
        dispose();
    });

    final JButton btnReload = new JButton("Reload");
    buttonPane.add(btnReload);
    btnReload.addActionListener(e -> {
        try {
            captchaImage.setIcon(new ImageIcon(client.getCaptchaImage(liveURL)));
        } catch (final Exception ex) {
            logger.error("Get captcha image for pin faile! " + ex.getMessage());
            Zorro.indicateError();
        }
    });
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    pack();
    setVisible(true);
}
 
开发者ID:juxeii,项目名称:dztools,代码行数:38,代码来源:PinProvider.java

示例10: loadAvailableProps

import javax.swing.JLabel; //导入方法依赖的package包/类
private void loadAvailableProps() {
  Map<String, String> m = new TreeMap<>();
  for (Spritesheet s : Spritesheet.getSpritesheets()) {
    String spriteName = s.getName();
    if (spriteName.startsWith("prop-")) {
      String[] parts = spriteName.split("-");
      String propName = parts[1];
      if (!m.containsKey(propName)) {
        m.put(propName, spriteName);
      }
    }
  }

  this.comboBoxSpriteSheets.removeAllItems();
  for (String key : m.keySet()) {
    JLabel label = new JLabel();
    label.setText(key);
    String value = m.get(key);
    Spritesheet sprite = Spritesheet.find(value);
    if (sprite != null && sprite.getTotalNumberOfSprites() > 0) {
      BufferedImage img = sprite.getSprite(0);
      BufferedImage scaled = ImageProcessing.scaleImage(img, 24, 24, true);
      if (scaled != null) {
        label.setIcon(new ImageIcon(scaled));
      }
    }

    this.comboBoxSpriteSheets.addItem(label);
  }

}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:32,代码来源:PropPanel.java

示例11: buildIcon

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Builds the tool icon
 *
 * @return JComponent
 */
private JComponent buildIcon() {
    JLabel icon = new JLabel();
    try {
        icon.setIcon(new ImageIcon(ImageIO.read(getClass().getResourceAsStream("/VISNode_64.png"))));
        icon.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 15));
    } catch (IOException ex) {
        Logger.getLogger(AboutVISNodePanel.class.getName()).log(Level.SEVERE, null, ex);
    }
    return icon;
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:16,代码来源:AboutVISNodePanel.java

示例12: setPie2

import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel setPie2(int var) {
	int[] angle = new int[numClust];
	int i;

	angle[0] = 0;
	for (i = 1; i < numClust; i++) {
		angle[i] = angle[i - 1] + (int) ((360) * info.infoCluster[i].percVar[var]);
	}
	for (; i < angle.length; i++) {
		angle[i] = 360;
	}

	final JLabel l = new JLabel();
	pieChartVars = new pieChartIcon(numClust);
	l.addMouseMotionListener(new MouseMotionAdapter() {
		@Override
		public void mouseMoved(MouseEvent e) {
			int pos;

			pos = pieChartVars.getPosXY(e.getX(), e.getY());

			if (pos != -1) {
				l.setToolTipText(tableVars.getValueAt(pos, 1).toString());
			} else {
				l.setToolTipText("");
			}
		}
	});
	pieChartVars.setAngle(angle);
	l.setIcon(pieChartVars);
	return l;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:33,代码来源:KMeansInfoClustering.java

示例13: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
	if (value instanceof QuickFix) {
		label.setIcon((Icon) ((QuickFix) value).getAction().getValue(Action.SMALL_ICON));
	}
	return label;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:10,代码来源:QuickFixDialog.java

示例14: setup

import javax.swing.JLabel; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "cast"})
private void setup(JLabel label, Object value)
{
	Class<? extends WorkflowNode> klass = null;
	LanguageBundle name = null;

	if( value instanceof Class )
	{
		klass = (Class<? extends WorkflowNode>) value;
	}
	else
	{
		WorkflowNode node = (WorkflowNode) value;
		klass = node.getClass();
		name = node.getName();
	}

	Pair<String, Icon> defaults = nameAndIcon.get(klass);

	if( name != null )
	{
		label.setText(CurrentLocale.get(name, defaultString));
	}
	else
	{
		label.setText(defaults.getFirst());
	}

	label.setIcon(defaults.getSecond());
}
 
开发者ID:equella,项目名称:Equella,代码行数:31,代码来源:WorkflowCellRenderer.java

示例15: mouseExited

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * When the cursor exits a card, the card is moved back to its original
 * depth.
 *
 * @param e
 */
@Override
public void mouseExited(MouseEvent e) {
    if (game.getPhase().equals(PLAY_CARDS)) {
        JLabel label = (JLabel) e.getComponent();
        cardPanel.getCardsPane().setLayer(label, cardPanel.getLabelLayer(label));
        String card = (String) label.getClientProperty("name");
        label.setIcon(new ImageIcon("src/resources/images/" + card + ".png"));
        Point p = label.getLocation();
        Point p1 = new Point(p.x, LOW_Y);
        label.setLocation(p1);
        cardPanel.updateUI();
    }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:20,代码来源:CardListener.java


注:本文中的javax.swing.JLabel.setIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。