List of usage examples for javax.swing ImageIcon getImage
@Transient
public Image getImage()
Image
. From source file:uk.sipperfly.ui.Exactly.java
/** * Creates new form MainFrame// w ww . j a va 2s. c o m */ public Exactly() { // this.emailIdList = new int[10]; this.list = new EntryList(this); this.bagInfo = new BagInfoList(this); this.email = new EmailList(this); initComponents(); initLogger(); this.uIManager = new UIManager(this); this.uIManager.setConfigurationFields(); this.uIManager.setEmailFields(); this.uIManager.setFtpFields(); this.uIManager.setBagInfoFields(true); this.uIManager.setTemplate(); ImageIcon img = new ImageIcon( Exactly.class.getClass().getResource("/uk/sipperfly/ui/resources/Exactly-logo.png")); this.setIconImage(img.getImage()); this.about.setIconImage(img.getImage()); String osName = System.getProperty("os.name").toLowerCase(); boolean isMacOs = osName.startsWith("mac os x"); if (isMacOs) { try { Class util = Class.forName("com.apple.eawt.Application"); Method getApplication = util.getMethod("getApplication", new Class[0]); Object application = getApplication.invoke(util); Class params[] = new Class[1]; params[0] = Image.class; Method setDockIconImage = util.getMethod("setDockIconImage", params); URL url = Exactly.class.getClass().getResource("/uk/sipperfly/ui/resources/Exactly-logo.png"); Image image = Toolkit.getDefaultToolkit().getImage(url); setDockIconImage.invoke(application, image); Method removeAboutMenuItem = util.getMethod("removeAboutMenuItem"); removeAboutMenuItem.invoke(application); } catch (ClassNotFoundException e) { Logger.getLogger(GACOM).log(Level.SEVERE, null, e); } catch (NoSuchMethodException e) { Logger.getLogger(GACOM).log(Level.SEVERE, null, e); // log exception } catch (InvocationTargetException e) { Logger.getLogger(GACOM).log(Level.SEVERE, null, e); // log exception } catch (IllegalAccessException e) { Logger.getLogger(GACOM).log(Level.SEVERE, null, e); // log exception } } }
From source file:us.mn.state.dot.tms.client.camera.FTPStream.java
/** Create an image icon from image data */ protected ImageIcon createIcon(byte[] idata) { ImageIcon icon = new ImageIcon(idata); if (icon.getIconWidth() == size.width && icon.getIconHeight() == size.height) return icon; Image im = icon.getImage().getScaledInstance(size.width, size.height, Image.SCALE_FAST); return new ImageIcon(im); }
From source file:verdandi.ui.SplashWindow.java
public void init() { URL imageURL = null;//from w ww. j av a 2s.co m InputStream descrIn = getClass().getClassLoader().getResourceAsStream("splash/content"); if (descrIn != null) { BufferedReader br = new BufferedReader(new InputStreamReader(descrIn)); List<String> lines = new ArrayList<String>(50); try { for (String line = br.readLine(); line != null; line = br.readLine()) { lines.add(line.trim()); } Random rnd = new Random(); int index = rnd.nextInt(lines.size()); imageURL = Thread.currentThread().getContextClassLoader().getResource("splash/" + lines.get(index)); } catch (IOException e) { LOG.error("Cannot load random splash data", e); } } else { LOG.debug("No random splash manifest found."); } if (imageURL == null) { LOG.debug("Random splash image not found. Using fallback"); imageURL = Thread.currentThread().getContextClassLoader().getResource("splash.png"); } ImageIcon icon = new ImageIcon(imageURL); tracker.addImage(icon.getImage(), 1); JLabel l = new JLabel(icon); getContentPane().add(l, BorderLayout.CENTER); pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension labelSize = l.getPreferredSize(); setLocation(screenSize.width / 2 - (labelSize.width / 2), screenSize.height / 2 - (labelSize.height / 2)); setVisible(true); screenSize = null; labelSize = null; }
From source file:view.BackgroundImageController.java
public void setGraphBackgroundImage(final VisualizationViewer vv, String resourceImagePath, final double xOffset, final double yOffset) { ImageIcon backgroundImage = new ImageIcon( Utils.loadImageFromResources(Logger.getLogger(getClass().getName()), resourceImagePath)); setGraphBackgroundImage(vv, backgroundImage, xOffset, yOffset); backgroundImage.getImage().flush(); Runtime.getRuntime().gc();//from w ww .j a v a2s . co m this.resourceImagePath = resourceImagePath; }
From source file:view.BackgroundImageController.java
public void setGraphBackgroundImage(final VisualizationViewer vv, final ImageIcon background, final double xOffset, final double yOffset) { removeBackgroundImage(vv);//w w w . j ava2 s . co m preRender = new VisualizationViewer.Paintable() { public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; AffineTransform oldXform = g2d.getTransform(); AffineTransform lat = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT) .getTransform(); AffineTransform vat = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW) .getTransform(); AffineTransform at = new AffineTransform(); at.concatenate(g2d.getTransform()); at.concatenate(vat); at.concatenate(lat); g2d.setTransform(at); g.drawImage(background.getImage(), (int) Math.round(-background.getIconWidth() / xOffset), (int) Math.round(-background.getIconHeight() / yOffset), background.getIconWidth(), background.getIconHeight(), vv); g2d.setTransform(oldXform); } public boolean useTransform() { return false; } }; vv.addPreRenderPaintable(preRender); background.getImage().flush(); Runtime.getRuntime().gc(); }
From source file:vista.ArchToxHome.java
/** * Creates new form ArchToxHome//from ww w . j a va 2 s. c o m */ public ArchToxHome() { initComponents(); this.setLocationRelativeTo(null); this.setResizable(false); ImageIcon img = new ImageIcon( "C:\\Users\\Jonathan\\Documents\\NetBeansProjects\\ArchTox\\src\\imagenes\\archtox.png"); Icon icono = new ImageIcon( img.getImage().getScaledInstance(LabelLogo.getWidth(), LabelLogo.getHeight(), Image.SCALE_SMOOTH)); LabelLogo.setIcon(icono); this.repaint(); // Dimension tamao = Toolkit.getDefaultToolkit().getScreenSize(); // this.setSize(tamao); }