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

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

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

ImageIcon.getImage介绍

暂无

代码示例

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

//  Using ImageIO

String imageName = "timeLabel.jpg";
imageLabel.setIcon( new ImageIcon(ImageIO.read( new File(imageName) ) ) );

//  Or you can flush the image

String imageName = "timeLabel.jpg";
ImageIcon icon = new ImageIcon(imageName);
icon.getImage().flush();
imageLabel.setIcon( icon );

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

ImageIcon icon = new ImageIcon(filename);
  try {
    URL url = new URL(filename);
    icon = new ImageIcon(url);
  URL url = StdDraw.class.getResource(filename);
  if (url != null)
    icon = new ImageIcon(url);
return icon.getImage();

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

private static BufferedImage readImage(final ImageIcon imageIcon) {
  final Image tmpImage = imageIcon.getImage();
  final BufferedImage image = new BufferedImage(imageIcon.getIconWidth(), imageIcon.getIconHeight(),
      BufferedImage.TYPE_INT_ARGB);
  image.getGraphics().drawImage(tmpImage, 0, 0, null);
  tmpImage.flush();
  return image;
}

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

image = new ImageIcon(image).getImage();
    type = BufferedImage.TYPE_INT_ARGB;
  bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
g.drawImage(image, 0, 0, null);
g.dispose();
return bimage;

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

public static void main(String[] args) throws Exception
{
  double framerate = 12.0;
  double transitionDuration = 1; // seconds
  double slideDuration = 3; // seconds
  
  File photoDir = new File(args[0]);
  File[] files = photoDir.listFiles(new FilenameFilter(){
    public boolean accept(File dir, String name)
    {
      if(StringUtils.goLowerCase(name).endsWith("jpg"))
        return true;
      return false;
    }
  });
  
  
  int numFrames = (int)(files.length * framerate * (slideDuration + transitionDuration) + (transitionDuration * framerate));
  MJPEGGenerator m = new MJPEGGenerator(new File(args[1]), 640, 480, framerate, numFrames);
  for(int i = 0; i < files.length; i++)
  {
    System.out.println("processing file "+i);
    ImageIcon ii = new ImageIcon(files[i].getCanonicalPath());
    m.addImage(ii.getImage());
  }
  m.finishAVI();
}

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

System.err.println("No system tray available");
  return;
    TrayIcon oldTray[] = (TrayIcon[]) evt.getOldValue();
    TrayIcon newTray[] = (TrayIcon[]) evt.getNewValue();
    System.out.println(oldTray.length + " / " + newTray.length);
  return ((ImageIcon) icon).getImage();
} else {
  int w = icon.getIconWidth();

代码示例来源:origin: igniterealtime/Openfire

System.err.println("Error loading system tray library, system tray support disabled.");
  splash = new ImageIcon(getClass().getClassLoader().getResource("splash.gif"));
  splashLabel = new JLabel("", splash, JLabel.CENTER);
  onIcon = new ImageIcon(getClass().getClassLoader().getResource("openfire_on-16x16.gif"));
  offIcon = new ImageIcon(getClass().getClassLoader().getResource("openfire_off-16x16.gif"));
  frame.setIconImage(offIcon.getImage());
trayIcon = new TrayIcon(offIcon.getImage(), appName, menu);
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(actionListener);
frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
frame.pack();

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

_logMonitorFrame = new JFrame("LogFactor5");
_logMonitorFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
 _logMonitorFrame.setIconImage(new ImageIcon(lf5IconURL).getImage());
_logMonitorFrame.getContentPane().add(splitPane, BorderLayout.CENTER);
_logMonitorFrame.getContentPane().add(createToolBar(),
  BorderLayout.NORTH);
_logMonitorFrame.getContentPane().add(createStatusArea(),
  BorderLayout.SOUTH);

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

public BufferedImage loadImage(String url) {
  ImageIcon icon = new ImageIcon(url);
  Image image = icon.getImage();

  // Create empty BufferedImage, sized to Image
  BufferedImage buffImage = 
   new BufferedImage(
    image.getWidth(null), 
    image.getHeight(null), 
    BufferedImage.TYPE_INT_ARGB);

  // Draw Image into BufferedImage
  Graphics g = buffImage.getGraphics();
  g.drawImage(image, 0, 0, null);
  return buffImage;
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

private Icon createDisabledIcon() {
  if(defaultIcon instanceof ImageIcon) {
    Image i = GrayFilter.createDisabledImage(((ImageIcon) defaultIcon).getImage());
    return new ImageIcon(i);
  } else {
    BufferedImage bi = new BufferedImage(defaultIcon.getIconWidth(), defaultIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics g = bi.createGraphics();
    g.setColor(new Color(0, 0, 0, 0));
    g.fillRect(0, 0, defaultIcon.getIconWidth(), defaultIcon.getIconHeight());
    defaultIcon.paintIcon(null, g, 0, 0);
    g.dispose();
    Image i = GrayFilter.createDisabledImage(bi);
    return new ImageIcon(i);
  }
}

代码示例来源:origin: deathmarine/Luyten

this.setQuitOnWindowClosing();
this.setTitle(TITLE);
this.setIconImage(new ImageIcon(
    Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/resources/Luyten.png"))).getImage());
this.getContentPane().add(model);

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

JFrame newFrame = new JFrame("PhotoAlbum");

ImageIcon img = new ImageIcon("Photos/albumIcon.png");
newFrame.setIconImage(img.getImage());

代码示例来源:origin: apache/pdfbox

/**
 * Creates a modal dialog to display the given exception message.
 *
 * @param owner if non-null, then the dialog is positioned (centered) w.r.t. this component
 * @param icon the icon to display
 * @param t the exception to display
 */
public ErrorDialog(JComponent owner, Icon icon, Throwable t)
{
  setTitle(t.getClass().getName());
  setModal(true);
  if (icon instanceof ImageIcon)
  {
    setIconImage(((ImageIcon) icon).getImage());
  }
  setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  error = t;
  message = createErrorMessage(error);
  main = createContent();
  getContentPane().add(main);
  pack();
  position(this, owner);
}

代码示例来源:origin: abc9070410/JComicDownloader

protected void paintComponent( Graphics g )
  {
    ImageIcon icon = new ImageIcon( picFileString );
    Image img = icon.getImage();
    g.drawImage( img, 0, 0, icon.getIconWidth(),
           icon.getIconHeight(), icon.getImageObserver() );
    //frame.setSize( icon.getIconWidth(), icon.getIconHeight() );
  }
};

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

if (img.getImage() instanceof BufferedImage) {
  BufferedImage image = (BufferedImage) img.getImage();
  return new GraphicStyle2D(image, 0, 0);
  new BufferedImage(
      icon.getIconWidth() + border * 2,
      icon.getIconHeight() + border * 2,

代码示例来源:origin: igniterealtime/Openfire

@Override
public void paintComponent(Graphics g) {
  final Dimension size = pane.getSize();
  int x = (size.width - icon.getIconWidth()) / 2;
  int y = (size.height - icon.getIconHeight()) / 2;
  //  Approach 1: Dispaly image at at full size
  g.setColor(Color.white);
  g.fillRect(0, 0, size.width, size.height);
  g.drawImage(icon.getImage(), x, y, null);
  setOpaque(false);
  super.paintComponent(g);
}

代码示例来源:origin: chewiebug/GCViewer

protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  
  setBackground(Color.WHITE);
  
  // draw logo
  g.drawImage(logoIcon.getImage(),
      getWidth()/2 - logoIcon.getIconWidth()/2,
      getHeight()/2 - logoIcon.getIconHeight()/2,
      logoIcon.getIconWidth(),
      logoIcon.getIconHeight(),
      logoIcon.getImageObserver());
  drawVersionString(g, logoIcon);
}

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

Image img = new ImageIcon("duke.png").getImage();
BufferedImage bi = new BufferedImage(SCALE * img.getWidth(null),
                   SCALE * img.getHeight(null),
                   BufferedImage.TYPE_INT_ARGB);
grph.drawImage(img, 0, 0, null);
grph.dispose();

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

if(z.getHealth() == 50){
  z.setAlive(false);
  ImageIcon ii = new ImageIcon("Health.png");
  image = ii.getImage();
  g2D.drawImage(image, (int) z.getX(), (int) z.getY(), this);
  System.out.println("Zombie state: " + z.isAlive());
}

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

String path = "resources/back_img.png";
 ClassLoader cl = ImageHandler.class.getClassLoader();
 URL imgURL = cl.getResource(path);
 //URL imgURL = ImageHandler.class.getResource(path);
 if (imgURL != null) {
   ImageIcon icon = new ImageIcon(imgURL, description);
   Image img = icon.getImage();
   Image sizedImg = img.getScaledInstance(width, height, Image.SCALE_DEFAULT);
   return new ImageIcon(sizedImg);
 } else {
   System.err.println("Couldn't find file: " + path);
   return null;
 }

相关文章