本文整理了Java中javax.swing.JLabel.setIcon()
方法的一些代码示例,展示了JLabel.setIcon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setIcon()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setIcon
暂无
代码示例来源:origin: runelite/runelite
void loadHeaderIcon(BufferedImage img)
{
overallIcon.setIcon(new ImageIcon(img));
}
代码示例来源:origin: stackoverflow.com
Image image=GenerateImage.toImage(true); //this generates an image file
ImageIcon icon = new ImageIcon(image);
JLabel thumb = new JLabel();
thumb.setIcon(icon);
代码示例来源:origin: runelite/runelite
private JPanel makeSkillPanel(HiscoreSkill skill)
{
JLabel label = new JLabel();
label.setFont(FontManager.getRunescapeSmallFont());
label.setText("--");
String skillName = (skill == null ? "combat" : skill.getName().toLowerCase());
String directory = "/skill_icons";
if (skillName.equals("combat") || skillName.equals("overall"))
{
// Cannot use SpriteManager as HiscorePlugin loads before a Client is available
directory += "/";
}
else
{
directory += "_small/";
}
String skillIcon = directory + skillName + ".png";
log.debug("Loading skill icon from {}", skillIcon);
label.setIcon(new ImageIcon(ImageUtil.getResourceStreamFromClass(getClass(), skillIcon)));
boolean totalLabel = skill == HiscoreSkill.OVERALL || skill == null; //overall or combat
label.setIconTextGap(totalLabel ? 10 : 4);
JPanel skillPanel = new JPanel();
skillPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
skillPanel.setBorder(new EmptyBorder(2, 0, 2, 0));
skillLabels.add(label);
skillPanel.add(skillLabels.get(skillLabels.size() - 1));
return skillPanel;
}
代码示例来源:origin: runelite/runelite
final JLabel imageLabel = new JLabel();
imageLabel.setToolTipText(buildToolTip(item));
imageLabel.setVerticalAlignment(SwingConstants.CENTER);
imageLabel.setIcon(new ImageIcon(transparentImage));
};
itemImage.onChanged(addTransparency);
代码示例来源:origin: haraldk/TwelveMonkeys
private static void addImage(Container pParent, ImageReader pReader, int pImageNo, String pName) throws IOException {
final JLabel label = new JLabel();
final BufferedImage image = pReader.read(pImageNo);
label.setIcon(new Icon() {
private static final int SIZE = 110;
public void paintIcon(Component c, Graphics g, int x, int y) {
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.DARK_GRAY);
g.fillRoundRect(x, y, SIZE, SIZE, 10, 10);
g.drawImage(image, (SIZE - image.getWidth()) / 2 + x, (SIZE - image.getHeight()) / 2 + y, null);
}
public int getIconWidth() {
return SIZE;
}
public int getIconHeight() {
return SIZE;
}
});
label.setText("" + image.getWidth() + "x" + image.getHeight() + ": " + pName);
label.setToolTipText(image.toString());
pParent.add(label);
}
代码示例来源:origin: stackoverflow.com
String mycon="image1.png";
JLabel MyImage;
public LottoGUI(String one, String two,String three) {
Container C= getContentPane();
C.setLayout(new FlowLayout());
MyImage = new JLabel(new ImageIcon(mycon));
JButton labb = new JButton("OK!");
labb.addActionListener(this);
C.add(MyImage);
C.add(labb)
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==labb){
MyImage.setIcon(newIcon);
}
}
代码示例来源:origin: redwarp/9-Patch-Resizer
public AboutDialog(JFrame parent) {
this.setResizable(false);
this.setSize(new Dimension(400, 250));
this.getContentPane().setLayout(new BorderLayout(0, 0));
JLabel lblResizer = new JLabel(Localization.get("app_name") + " "
+ Configuration.getVersion());
lblResizer.setBorder(new EmptyBorder(10, 10, 10, 10));
lblResizer.setVerticalTextPosition(SwingConstants.BOTTOM);
lblResizer.setIconTextGap(10);
lblResizer.setFont(lblResizer.getFont().deriveFont(
lblResizer.getFont().getStyle() | Font.BOLD, 16f));
lblResizer.setIcon(new ImageIcon(AboutDialog.class
.getResource("/img/icon_64.png")));
this.getContentPane().add(lblResizer, BorderLayout.NORTH);
JTextArea txtrResizerIsA = new JTextArea();
txtrResizerIsA.setEditable(false);
txtrResizerIsA.setWrapStyleWord(true);
txtrResizerIsA.setBorder(new EmptyBorder(0, 10, 10, 10));
txtrResizerIsA.setFont(UIManager.getFont("Label.font"));
txtrResizerIsA.setLineWrap(true);
txtrResizerIsA.setText(Localization.get("about_text"));
txtrResizerIsA.setBackground(new Color(0, 0, 0, 0));
this.getContentPane().add(txtrResizerIsA, BorderLayout.CENTER);
this.setLocationRelativeTo(parent);
}
代码示例来源:origin: marytts/marytts
jLabel_ToolName = new javax.swing.JLabel();
jLabel_VersionNum = new javax.swing.JLabel();
jLabel_DFKILogo = new javax.swing.JLabel();
jButton_OK = new javax.swing.JButton();
jLabel_ToolIcon = new javax.swing.JLabel();
jLabel_DFKILogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/dfki_logo.jpg")));
jButton_OK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/ok_16x16.png")));
jButton_OK.setText("OK");
jButton_OK.setPreferredSize(new java.awt.Dimension(95, 25));
jLabel_ToolIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/redstop_48x48.png")));
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/mary_logo.png")));
代码示例来源:origin: stackoverflow.com
ImageIcon icon = new ImageIcon(imgURL);
JLabel thumb = new JLabel();
thumb.setIcon(icon);
代码示例来源:origin: stackoverflow.com
JList list = new JList(files);
list.setCellRenderer(new FileListCellRenderer());
gui.add(new JScrollPane(list));
label = new JLabel();
label.setOpaque(true);
fileSystemView = FileSystemView.getFileSystemView();
label.setIcon(fileSystemView.getSystemIcon(file));
label.setText(fileSystemView.getSystemDisplayName(file));
label.setToolTipText(file.getPath());
代码示例来源:origin: runelite/runelite
public void setIcon(Icon icon)
{
final ImageIcon imageIcon = new ImageIcon(this.getClass().getResource(icon.getFile()));
iconWrapperLabel.setIcon(imageIcon);
}
代码示例来源:origin: stackoverflow.com
JLabel label = new JLabel("Java Technology Dive Log");
ImageIcon image = null;
try {
image = new ImageIcon(ImageIO.read(
new URL("http://i.imgur.com/6mbHZRU.png")));
} catch(MalformedURLException mue) {
label.setIcon(image);
panel.add(label);
代码示例来源:origin: marytts/marytts
jTextPane_PromptDisplay = new javax.swing.JTextPane();
jTextPane_nextSentence = new javax.swing.JTextPane();
jLabel_SessionStatus = new javax.swing.JLabel();
jPanel_AdminControls = new javax.swing.JPanel();
jScrollPane_PromptSet = new javax.swing.JScrollPane();
jButton_Play = new javax.swing.JButton();
jSeparator_MessageBar = new javax.swing.JSeparator();
jLabel_MessageBar = new javax.swing.JLabel();
jCheckBox_PlayClosingBeep = new javax.swing.JCheckBox();
jLabel_MessageBarIcon = new javax.swing.JLabel();
jButton_Display = new javax.swing.JButton();
jMenuBar_AdminWindow = new javax.swing.JMenuBar();
.setText("This is a long and boring test sentence, the only purpose of which is to see how to break between lines without making any difference across the windows.");
jLabel_SessionStatus.setIcon(new javax.swing.ImageIcon(getClass()
.getResource("/marytts/tools/redstart/stopped_48x48.png")));
jLabel_SessionStatus.addMouseListener(new java.awt.event.MouseAdapter() {
jButton_Record.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/recording_16x16.png")));
jButton_Record.setText("Record");
jButton_Record.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton_Play.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/playing_16x16.png")));
jButton_Play.setText("Play");
jButton_Play.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
代码示例来源:origin: libgdx/libgdx
public void addValue (final Value value) {
JLabel valueNameLabel = new JLabel(value.getName() + ":");
valuesPanel.add(valueNameLabel, new GridBagConstraints(0, -1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
final JLabel valueValueLabel = new JLabel();
valuesPanel.add(valueValueLabel, new GridBagConstraints(1, -1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
valueValueLabel.setOpaque(true);
if (value.getObject() instanceof java.awt.Color)
valueValueLabel.setIcon(getColorIcon((java.awt.Color)value.getObject()));
else
valueValueLabel.setText(value.toString());
valueValueLabel.addMouseListener(new MouseAdapter() {
public void mouseEntered (MouseEvent evt) {
valueValueLabel.setBackground(selectedColor);
}
public void mouseExited (MouseEvent evt) {
valueValueLabel.setBackground(null);
}
public void mouseClicked (MouseEvent evt) {
Object oldObject = value.getObject();
value.showDialog();
if (!value.getObject().equals(oldObject)) {
effect.setValues(values);
updateValues();
updateFont();
}
}
});
}
代码示例来源:origin: stackoverflow.com
add(jScrollPane1);
label = new JLabel();
label.setOpaque(true);
fileSystemView = FileSystemView.getFileSystemView();
label.setIcon(fileSystemView.getSystemIcon(file));
label.setText(fileSystemView.getSystemDisplayName(file));
label.setToolTipText(file.getPath());
代码示例来源:origin: wiztools/rest-client
@Override
public void setBody(byte[] body, ContentType type) {
// Call parent:
super.setBody(body, type);
// Generate UI:
try {
BufferedImage img = ImageIO.read(new ByteArrayInputStream(body));
jl.setIcon(new ImageIcon(img));
}
catch(IOException ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: magefree/mage
private void setTabTitle(int tabIndex, String title, String iconResourceName) {
// tab caption with left sided icon
// https://stackoverflow.com/questions/1782224/jtabbedpane-icon-on-left-side-of-tabs
JLabel lbl = new JLabel(title);
Icon icon = new ImageIcon(getClass().getResource(iconResourceName));
lbl.setIcon(icon);
lbl.setIconTextGap(5);
lbl.setHorizontalTextPosition(SwingConstants.RIGHT);
tabsList.setTabComponentAt(tabIndex, lbl);
}
代码示例来源:origin: marytts/marytts
jPanel_SpeakerWindow = new javax.swing.JPanel();
jTextPane_PromptDisplay = new javax.swing.JTextPane();
jLabel_SessionStatus = new javax.swing.JLabel();
jProgressBar_SpeakerProgress = new javax.swing.JProgressBar();
jLabel_PromptCount = new javax.swing.JLabel();
jLabel_PromptTotal = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane_nextSentence = new javax.swing.JTextPane();
jTextPane_PromptDisplay.setAutoscrolls(false);
jLabel_SessionStatus.setIcon(new javax.swing.ImageIcon(getClass()
.getResource("/marytts/tools/redstart/stopped_64x64.png")));
代码示例来源:origin: libgdx/libgdx
public void addValue (final Value value) {
JLabel valueNameLabel = new JLabel(value.getName() + ":");
valuesPanel.add(valueNameLabel, new GridBagConstraints(0, -1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
final JLabel valueValueLabel = new JLabel();
valuesPanel.add(valueValueLabel, new GridBagConstraints(1, -1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
valueValueLabel.setOpaque(true);
if (value.getObject() instanceof java.awt.Color)
valueValueLabel.setIcon(getColorIcon((java.awt.Color)value.getObject()));
else
valueValueLabel.setText(value.toString());
valueValueLabel.addMouseListener(new MouseAdapter() {
public void mouseEntered (MouseEvent evt) {
valueValueLabel.setBackground(selectedColor);
}
public void mouseExited (MouseEvent evt) {
valueValueLabel.setBackground(null);
}
public void mouseClicked (MouseEvent evt) {
Object oldObject = value.getObject();
value.showDialog();
if (!value.getObject().equals(oldObject)) {
effect.setValues(values);
updateValues();
updateFont();
}
}
});
}
代码示例来源:origin: apache/felix
public test(String filename) {
super(filename);
setDefaultCloseOperation(EXIT_ON_CLOSE);
//image = getToolkit().getImage(filename);
ImageIcon image =loadIcon("EventedStateVariable");
//image.setImageObserver(this);
JPanel panel = new JPanel();
panel.add(new JLabel(image));
JLabel lab = new JLabel();
lab.setIcon(image);
panel.add(lab);
this.getContentPane().add(panel);
}
内容来源于网络,如有侵权,请联系作者删除!