javax.swing.ImageIcon.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中javax.swing.ImageIcon.<init>()方法的一些代码示例,展示了ImageIcon.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageIcon.<init>()方法的具体详情如下:
包路径:javax.swing.ImageIcon
类名称:ImageIcon
方法名:<init>

ImageIcon.<init>介绍

暂无

代码示例

代码示例来源:origin: kevin-wayne/algs4

/**
 * Returns a {@link JLabel} containing this picture, for embedding in a {@link JPanel},
 * {@link JFrame} or other GUI widget.
 *
 * @return the {@code JLabel}
 */
public JLabel getJLabel() {
  if (image == null) return null;         // no image available
  ImageIcon icon = new ImageIcon(image);
  return new JLabel(icon);
}

代码示例来源:origin: loklak/loklak_server

/**
 * show the image as JFrame on desktop
 */
public void show() {
  JLabel label = new JLabel(new ImageIcon(this.image));
  JFrame f = new JFrame();
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.getContentPane().add(label);
  f.pack();
  f.setVisible(true);
}

代码示例来源:origin: libgdx/libgdx

public Splash (Frame frame, String imageFile, int minMillis) {
  super(frame);
  this.minMillis = minMillis;
  getContentPane().add(new JLabel(new ImageIcon(Splash.class.getResource(imageFile))), BorderLayout.CENTER);
  pack();
  setLocationRelativeTo(null);
  setVisible(true);
  startTime = System.currentTimeMillis();
}

代码示例来源:origin: stackoverflow.com

menu.setHorizontalTextPosition(SwingConstants.CENTER);
menu.setVerticalTextPosition(SwingConstants.BOTTOM);
menu.setIcon(new ImageIcon(image));
menuBar.add(menu);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

代码示例来源:origin: redwarp/9-Patch-Resizer

this.setIconImages(icons);
this.blueArrow = new ImageIcon(
  MainWindow.class.getResource("/img/blue_big.png"));
this.redArrow = new ImageIcon(
  MainWindow.class.getResource("/img/red_big.png"));
this.blueArrowSmall = new ImageIcon(
  MainWindow.class.getResource("/img/blue_small.png"));
this.redArrowSmall = new ImageIcon(
  MainWindow.class.getResource("/img/red_small.png"));
this.getContentPane().setLayout(new CardLayout(0, 0));
fileDialog.setTitle(Localization.get("image_types"));
this.getContentPane().add(createInputPanel(), "input");
this.getContentPane().add(createOutputPanel(), "output");

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws Exception {
  JFrame frame = new JFrame("Test");

  ImageIcon loading = new ImageIcon("ajax-loader.gif");
  frame.add(new JLabel("loading... ", loading, JLabel.CENTER));

  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(400, 300);
  frame.setVisible(true);
}

代码示例来源:origin: stackoverflow.com

public static final ImageIcon ICON_COMPUTER =  new ImageIcon("");
public static final ImageIcon ICON_DISK =  new ImageIcon("defaults1.png");
public static final ImageIcon ICON_FOLDER =   new ImageIcon("fol_orig.png");
public static final ImageIcon ICON_EXPANDEDFOLDER =  new ImageIcon("folder_open.png");
  s.getViewport().add(m_tree);
  getContentPane().add(s, BorderLayout.CENTER);
  setVisible(true);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void show(){
  frame = new JFrame("HDR View");
  label = new JLabel(new ImageIcon(image));
  frame.getContentPane().add(label);
  frame.setLayout(new FlowLayout());
  frame.pack();
  frame.setVisible(true);
}

代码示例来源:origin: libgdx/libgdx

public Splash (Frame frame, String imageFile, int minMillis) {
  super(frame);
  this.minMillis = minMillis;
  getContentPane().add(new JLabel(new ImageIcon(Splash.class.getResource(imageFile))), BorderLayout.CENTER);
  pack();
  setLocationRelativeTo(null);
  setVisible(true);
  startTime = System.currentTimeMillis();
}

代码示例来源:origin: kevin-wayne/algs4

/**
 * Returns a {@link JLabel} containing this picture, for embedding in a {@link JPanel},
 * {@link JFrame} or other GUI widget.
 *
 * @return the {@code JLabel}
 */
public JLabel getJLabel() {
  if (image == null) return null;         // no image available
  ImageIcon icon = new ImageIcon(image);
  return new JLabel(icon);
}

代码示例来源:origin: stackoverflow.com

import javax.swing.JFrame;
import javax.swing.ImageIcon;

class JFrameTest
{
  public static void main(String _[])
  {
    JFrame jFrame = new JFrame("Hello World!!");
    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jFrame.setIconImage(new ImageIcon("c:/home/ravi/creampink.png").getImage());
    jFrame.setSize(400,400);
    jFrame.setVisible(true);
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

public CategoryNodeRenderer() {
 _panel.setBackground(UIManager.getColor("Tree.textBackground"));
 if (_sat == null) {
  // Load the satellite image.
  String resource =
    "/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif";
  URL satURL = getClass().getResource(resource);
  _sat = new ImageIcon(satURL);
 }
 setOpaque(false);
 _checkBox.setOpaque(false);
 _panel.setOpaque(false);
 // The flowlayout set to LEFT is very important so that the editor
 // doesn't jump around.
 _panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
 _panel.add(_checkBox);
 _panel.add(this);
 setOpenIcon(_sat);
 setClosedIcon(_sat);
 setLeafIcon(_sat);
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws MalformedURLException {
   URL url = new URL("<URL to your Animated GIF>");
   Icon icon = new ImageIcon(url);
   JLabel label = new JLabel(icon);
   JFrame f = new JFrame("Animation");
   f.getContentPane().add(label);
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.pack();
   f.setLocationRelativeTo(null);
   f.setVisible(true);
 }

代码示例来源:origin: stackoverflow.com

package com.stackoverflow.test;

import java.net.URL;
import javax.swing.*;  // Wild carded for brevity. 
            // Actual code imports single classes
public class Main {
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable(){
      public void run() {
        URL url = Main.class.getResource(
                   "/resources/stackoverflow.png");
        ImageIcon icon = new ImageIcon(url);
        JFrame frame = new JFrame();
        frame.add(new JLabel(icon));
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      }
    });
  }
}

代码示例来源: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: dcevm/dcevm

private JComponent getBanner() {
  try {
    BufferedImage img = ImageIO.read(getClass().getResource("splash.png"));
    JLabel title = new JLabel(new ImageIcon(img));
    title.setPreferredSize(new Dimension(img.getWidth() + 10, img.getHeight()));
    title.setOpaque(true);
    title.setBackground(new Color(238, 238, 255));
    return title;
  } catch (Exception ignore) {
  }
  return new JLabel();
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

DemoRootPane() {
    textArea = createTextArea();
    setText("JavaExample.txt");
    textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVA);

    scrollPane = new RTextScrollPane(textArea, true);
    Gutter gutter = scrollPane.getGutter();
    gutter.setBookmarkingEnabled(true);
    URL url = getClass().getResource("bookmark.png");
    gutter.setBookmarkIcon(new ImageIcon(url));
    getContentPane().add(scrollPane);
    ErrorStrip errorStrip = new ErrorStrip(textArea);
//errorStrip.setBackground(java.awt.Color.blue);
    getContentPane().add(errorStrip, BorderLayout.LINE_END);
    setJMenuBar(createMenuBar());
  }

代码示例来源:origin: loklak/loklak_server

/**
   * show the images as stream of JFrame on desktop
   */
  public void show() {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
    JLabel label = null;
    while (true) {
      for (int i = 0; i < this.frames.size(); i++) {
        Frame frame = this.frames.get(i);
        if (label == null) {
          label = new JLabel(new ImageIcon(frame.image));
          f.getContentPane().add(label);
          f.pack();
        } else {
          label.getGraphics().drawImage(frame.image,0,0, label);
        }
        try {Thread.sleep(frame.delayMillis);} catch (InterruptedException e) {}
      }
    }
  }
}

代码示例来源: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) {
panel.add(label);

代码示例来源:origin: plantuml/plantuml

private JComponent getNorthLabel() {
  final JLabel text = new JLabel("PlantUML (" + Version.versionString() + ")");
  final Font font = text.getFont().deriveFont(Font.BOLD, (float) 20.0);
  text.setFont(font);
  final JPanel ptext = new JPanel();
  ptext.add(text);
  final JLabel icon = new JLabel(new ImageIcon(PSystemVersion.getPlantumlImage()));
  final JPanel result = new JPanel(new BorderLayout());
  result.add(ptext, BorderLayout.CENTER);
  result.add(icon, BorderLayout.EAST);
  return result;
}

相关文章