List of usage examples for javax.swing ImageIcon getImage
@Transient
public Image getImage()
Image
. From source file:Main.java
public static void main(String[] a) { ImageIcon imageIcon = new ImageIcon("yourFile.gif"); Image image = imageIcon.getImage(); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ImageIcon icon = new ImageIcon("yourFile.gif"); Image normalImage = icon.getImage(); Image grayImage = GrayFilter.createDisabledImage(normalImage); Icon warningIcon = new ImageIcon(grayImage); JLabel warningLabel = new JLabel(warningIcon); JLabel label3 = new JLabel("Warning", icon, JLabel.CENTER); frame.add(warningLabel, "Center"); frame.add(label3, "South"); frame.setSize(300, 200);//from www . j a v a2s. co m frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Background Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final ImageIcon imageIcon = new ImageIcon("draft.gif"); JTextArea textArea = new JTextArea() { Image image = imageIcon.getImage(); Image grayImage = GrayFilter.createDisabledImage(image); {/*from www.java2 s .c o m*/ setOpaque(false); } public void paint(Graphics g) { g.drawImage(grayImage, 0, 0, this); super.paint(g); } }; JScrollPane scrollPane = new JScrollPane(textArea); Container content = frame.getContentPane(); content.add(scrollPane, BorderLayout.CENTER); frame.setSize(250, 250); frame.setVisible(true); }
From source file:JTextAreaBackgroundSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Background Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final ImageIcon imageIcon = new ImageIcon("yourFile.gif"); JTextArea textArea = new JTextArea() { Image image = imageIcon.getImage(); Image grayImage = GrayFilter.createDisabledImage(image); {//from www .jav a2s . c om setOpaque(false); } public void paint(Graphics g) { g.drawImage(grayImage, 0, 0, this); super.paint(g); } }; JScrollPane scrollPane = new JScrollPane(textArea); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(250, 250); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { ImageIcon ii = new ImageIcon("C:/Java_Dev/test.jpg"); BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = (Graphics2D) bi.createGraphics(); g2d.addRenderingHints(/*from w w w. j a va 2 s. co m*/ new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY)); boolean b = g2d.drawImage(ii.getImage(), 0, 0, 50, 50, null); System.out.println(b); ImageIO.write(bi, "jpg", new File("C:/Java_Dev/test.jpg")); }
From source file:org.jfree.graphics2d.demo.BufferedImageDemo.java
/** * Starting point for the demo./* w w w .ja v a 2 s. com*/ * * @param args ignored. * * @throws IOException */ public static void main(String[] args) throws IOException { BufferedImage image = new BufferedImage(600, 400, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); ImageIcon icon = new ImageIcon(BufferedImageDemo.class.getResource("jfree_chart_1.jpg")); g2.rotate(Math.PI / 12); g2.setStroke(new BasicStroke(2.0f)); g2.setPaint(Color.WHITE); g2.fill(new Rectangle(0, 0, 600, 400)); g2.setPaint(Color.RED); g2.draw(new Rectangle(0, 0, 600, 400)); g2.drawImage(icon.getImage(), 10, 20, null); ImageIO.write(image, "png", new File("image-test.png")); }
From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java
/** * Launch the application./*from w w w.j a va2 s. c om*/ */ public static void main(final String[] args) { File baseDir = new File(System.getProperty("basedir", ".")); final Injector inj = Guice.createInjector(new AppModule(baseDir)); final ConfigController configCtrl = inj.getInstance(ConfigController.class); try { UIManager.setLookAndFeel(configCtrl.getLookAndFeelClassName()); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); } ExceptionHandler exceptionHandler = inj.getInstance(ExceptionHandler.class); Thread.setDefaultUncaughtExceptionHandler(exceptionHandler); // This is necessary because an UncaughtExceptionHandler does not work in modal dialogs System.setProperty("sun.awt.exception.handler", ExceptionHandler.class.getName()); EventQueue.invokeLater(new Runnable() { @Override public void run() { try { AppFrame frame = inj.getInstance(AppFrame.class); Rectangle bounds = configCtrl.getFrameBounds(); if (bounds != null) { frame.setBounds(bounds); } ImageIcon icon = new ImageIcon( getResource("com/mgmtp/perfload/loadprofiles/ui/perfLoad_Logo_bild_64x64.png")); frame.setIconImage(icon.getImage()); frame.updateLists(); frame.updateGraph(); frame.addTableListeners(); frame.setUpEventBus(); frame.setExtendedState(configCtrl.getFrameState()); frame.setVisible(true); } catch (Exception ex) { ex.printStackTrace(); } } }); }
From source file:edu.ku.brc.specify.tools.ireportspecify.MainFrameSpecify.java
/** * @param args//w w w . ja v a 2s . co m */ public static void main(String[] args) { log.debug("********* Current [" + (new File(".").getAbsolutePath()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // This is for Windows and Exe4J, turn the args into System Properties // Set App Name, MUST be done very first thing! //UIRegistry.setAppName("iReports4Specify"); //$NON-NLS-1$ UIRegistry.setAppName("Specify"); //$NON-NLS-1$ UIRegistry.setEmbeddedDBPath(UIRegistry.getDefaultEmbeddedDBPath()); // on the local machine AppBase.processArgs(args); AppBase.setupTeeForStdErrStdOut(true, false); // Then set this IconManager.setApplicationClass(Specify.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$ Specify.setUpSystemProperties(); AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); adjustLocaleFromPrefs(); HibernateUtil.setListener("post-commit-update", new edu.ku.brc.specify.dbsupport.PostUpdateEventListener()); //$NON-NLS-1$ HibernateUtil.setListener("post-commit-insert", new edu.ku.brc.specify.dbsupport.PostInsertEventListener()); //$NON-NLS-1$ HibernateUtil.setListener("post-commit-delete", new edu.ku.brc.specify.dbsupport.PostDeleteEventListener()); //$NON-NLS-1$ ImageIcon helpIcon = IconManager.getIcon(IconManager.makeIconName("AppIcon"), IconSize.Std16); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ try { UIHelper.OSTYPE osType = UIHelper.getOSType(); if (osType == UIHelper.OSTYPE.Windows) { UIManager.setLookAndFeel(new PlasticLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue()); } else if (osType == UIHelper.OSTYPE.Linux) { UIManager.setLookAndFeel(new PlasticLookAndFeel()); } } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(MainFrameSpecify.class, e); log.error("Can't change L&F: ", e); //$NON-NLS-1$ } if (UIHelper.isLinux()) { Specify.checkForSpecifyAppsRunning(); } if (UIRegistry.isEmbedded()) { ProcessListUtil.checkForMySQLProcesses(new ProcessListener() { @Override public void done(PROC_STATUS status) // called on the UI thread { if (status == PROC_STATUS.eOK || status == PROC_STATUS.eFoundAndKilled) { startupContinuing(); // On UI Thread } } }); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { startupContinuing(); } }); } }
From source file:Main.java
public static ImageIcon scaleImage(ImageIcon i, int x, int y) { return new ImageIcon(i.getImage().getScaledInstance(x, y, Image.SCALE_SMOOTH)); }
From source file:Main.java
/** * /* w w w.j a va2 s.c o m*/ * @param image * @return */ public static BufferedImage toBufferedImage(ImageIcon image) { return toBufferedImage(image.getImage()); }