List of usage examples for javax.swing ImageIcon getImage
@Transient
public Image getImage()
Image
. From source file:Charts2D.java
public Charts2D() { super("2D Charts"); setSize(720, 280);/*from www .ja va2s . c o m*/ getContentPane().setLayout(new GridLayout(1, 3, 10, 0)); getContentPane().setBackground(Color.white); int[] xData = new int[8]; int[] yData = new int[8]; for (int i = 0; i < xData.length; i++) { xData[i] = i; yData[i] = (int) (Math.random() * 100); if (i > 0) yData[i] = (yData[i - 1] + yData[i]) / 2; } JChart2D chart = new JChart2D(JChart2D.LineChart, xData.length, xData, yData, "Line Chart"); chart.setStroke(new BasicStroke(5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER)); chart.setLineColor(new Color(0, 28, 28)); getContentPane().add(chart); chart = new JChart2D(JChart2D.ColumnChart, xData.length, xData, yData, "Column Chart"); GradientPaint gp = new GradientPaint(0, 100, Color.white, 0, 300, Color.blue, true); chart.setGradient(gp); chart.setEffectIndex(JChart2D.Gradientffect); chart.setDrawShadow(true); getContentPane().add(chart); chart = new JChart2D(JChart2D.PieChart, xData.length, xData, yData, "Pie Chart"); ImageIcon icon = new ImageIcon("largeJava2slogo.GIF"); chart.setForegroundImage(icon.getImage()); chart.setEffectIndex(JChart2D.ImageEffect); chart.setDrawShadow(true); getContentPane().add(chart); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.MainM.java
/** * Constructs a new instance of the editor. * @param addPluginFile//ww w.j a va2s.co m */ public MainM(String applicationName, String[] args, String[] addon, SplashScreenInterface splashScreen, String addPluginFile, final boolean showMainFrame) { setupLogger(); ClassLoader cl = this.getClass().getClassLoader(); String path = this.getClass().getPackage().getName().replace('.', '/'); ImageIcon icon = new ImageIcon(cl.getResource(path + "/vanted_logo.png")); if (splashScreen != null && (splashScreen instanceof DBEsplashScreen)) { ((DBEsplashScreen) splashScreen).setIconImage(icon.getImage()); } splashScreen.setVisible(showMainFrame); GravistoMainHelper.createApplicationSettingsFolder(splashScreen); if (!showMainFrame && !(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted")).exists() && !(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected")).exists()) { // command line version automatically rejects // kegg try { new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected").createNewFile(); } catch (Exception e1) { e1.printStackTrace(); } } if (!(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted")).exists() && !(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected")).exists()) { ReleaseInfo.setIsFirstRun(true); splashScreen.setVisible(false); splashScreen.setText("Request KEGG License Status"); int result = askForEnablingKEGG(); if (result == JOptionPane.YES_OPTION) { try { new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted").createNewFile(); } catch (IOException e) { ErrorMsg.addErrorMessage(e); } } if (result == JOptionPane.NO_OPTION) { try { new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected").createNewFile(); } catch (IOException e) { ErrorMsg.addErrorMessage(e); } } if (result == JOptionPane.CANCEL_OPTION) { JOptionPane.showMessageDialog(null, "Startup of VANTED is aborted.", "VANTED Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } splashScreen.setVisible(true); } GravistoMainHelper.initApplicationExt(args, splashScreen, cl, addPluginFile, addon); }
From source file:javazoom.jlgui.player.amp.StandalonePlayer.java
/** * Load player front-end.//from w ww .j a v a 2 s .c o m */ public void loadUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { log.debug(ex); } config = Config.getInstance(); config.load(initConfig); config.setTopParent(this); if (showPlaylist != null) { if (showPlaylist.equalsIgnoreCase("true")) { config.setPlaylistEnabled(true); } else { config.setPlaylistEnabled(false); } } if (showEqualizer != null) { if (showEqualizer.equalsIgnoreCase("true")) { config.setEqualizerEnabled(true); } else { config.setEqualizerEnabled(false); } } if (config.isPlaylistEnabled()) eqFactor = 2; else eqFactor = 1; setTitle(Skin.TITLETEXT); ClassLoader cl = this.getClass().getClassLoader(); URL iconURL = cl.getResource("javazoom/jlgui/player/amp/jlguiicon.gif"); if (iconURL != null) { ImageIcon jlguiIcon = new ImageIcon(iconURL); setIconImage(jlguiIcon.getImage()); config.setIconParent(jlguiIcon); } setUndecorated(true); mp = new PlayerUI(); if ((showDsp != null) && (showDsp.equalsIgnoreCase("false"))) { mp.getSkin().setDspEnabled(false); } if (skinPath != null) { mp.getSkin().setPath(skinPath); } mp.getSkin().setSkinVersion(skinVersion); mp.loadUI(this); setContentPane(mp); setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight())); eqWin = new JWindow(this); eqWin.setContentPane(mp.getEqualizerUI()); eqWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight())); eqWin.setVisible(false); plWin = new JWindow(this); plWin.setContentPane(mp.getPlaylistUI()); plWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight())); plWin.setVisible(false); // Window listener addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { // Closing window (Alt+F4 under Win32) close(); } }); // Keyboard shortcut setKeyBoardShortcut(); // Display front-end setLocation(config.getXLocation(), config.getYLocation()); setVisible(true); if (config.isPlaylistEnabled()) plWin.setVisible(true); if (config.isEqualizerEnabled()) eqWin.setVisible(true); }
From source file:misc.DesktopDemo.java
/** * Load the "desktop" icon into our frame window. *///w w w. ja v a 2 s . c o m private void loadFrameIcon() { URL imgUrl = null; ImageIcon imgIcon = null; imgUrl = DesktopDemo.class.getResource("images/desk32.gif"); imgIcon = new ImageIcon(imgUrl); Image img = imgIcon.getImage(); this.setIconImage(img); }
From source file:agendapoo.View.FrmCadastroAtividade.java
private void setFrameIcon() { ImageIcon icon = new ImageIcon("src//agendapoo//imgs//file_add.png"); this.setIconImage(icon.getImage()); }
From source file:FileChooserDemo2.java
public void loadImage() { if (file == null) { thumbnail = null;/*from w w w.j a v a 2 s . com*/ return; } // Don't use createImageIcon (which is a wrapper for getResource) // because the image we're trying to load is probably not one // of this program's own resources. ImageIcon tmpIcon = new ImageIcon(file.getPath()); if (tmpIcon != null) { if (tmpIcon.getIconWidth() > 90) { thumbnail = new ImageIcon(tmpIcon.getImage().getScaledInstance(90, -1, Image.SCALE_DEFAULT)); } else { // no need to miniaturize thumbnail = tmpIcon; } } }
From source file:edu.ku.brc.specify.config.init.SpecifyDBSetupWizardFrame.java
/** * @throws HeadlessException/* w w w . j a v a 2 s . c o m*/ */ public SpecifyDBSetupWizardFrame() throws HeadlessException { super(); UIRegistry.loadAndPushResourceBundle("specifydbsetupwiz"); new MacOSAppHandler(this); UIRegistry.setTopWindow(this); // Now initialize AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); AppPrefsCache.setUseLocalOnly(true); SpecifyAppPrefs.setSkipRemotePrefs(true); SpecifyAppPrefs.initialPrefs(); Specify.adjustLocaleFromPrefs(); ImageIcon helpIcon = IconManager.getIcon(SpecifyDBSetupWizard.getIconName(), IconSize.Std32); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ JMenuBar menuBar = createMenus(); if (menuBar != null) { setJMenuBar(menuBar); } UIRegistry.register(UIRegistry.MENUBAR, menuBar); setIconImage( IconManager.getIcon(SpecifyDBSetupWizard.getIconName(), IconManager.IconSize.NonStd).getImage()); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); SpecifyDBSetupWizard wizPanel = new SpecifyDBSetupWizard(SpecifyDBSetupWizard.WizardType.Institution, new SpecifyDBSetupWizard.WizardListener() { @Override public void cancelled() { setVisible(false); //dispose(); doExit(true); } @Override public void hide() { setVisible(false); } @Override public void finished() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dispose(); doExit(true); } }); } @Override public void panelChanged(String title) { setTitle(getAppTitle(title)); } @Override public void helpContextChanged(String helpTarget) { if (getHelpMenuItem() != null) { HelpMgr.registerComponent(getHelpMenuItem(), helpTarget); } } }); setTitle(getAppTitle(getResourceString("MAIN_TITLE"))); setContentPane(wizPanel); pack(); }
From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.MainM.java
public MainM(final boolean showMainFrame, String applicationName, String[] args, String[] addon, String addPluginFile) {//ww w .j a v a2 s. c o m this(applicationName, args, addon, new DBEsplashScreen(applicationName, "", new RunnableWithSplashScreenReference() { private SplashScreenInterface ss; @Override public void run() { if (showMainFrame) { ClassLoader cl = this.getClass().getClassLoader(); String path = this.getClass().getPackage().getName().replace('.', '/'); ImageIcon icon = new ImageIcon(cl.getResource(path + "/vanted_logo.png")); final MainFrame mainFrame = MainFrame.getInstance(); if (icon != null && mainFrame != null) mainFrame.setIconImage(icon.getImage()); if (mainFrame == null) System.err.println("Internal Error: MainFrame is NULL"); else { Thread t = new Thread(new Runnable() { @Override public void run() { long waitTime = 0; long start = System.currentTimeMillis(); do { if (ErrorMsg.getAppLoadingStatus() == ApplicationStatus.ADDONS_LOADED) break; try { Thread.sleep(50); } catch (InterruptedException e) { } waitTime = System.currentTimeMillis() - start; } while (waitTime < 2000); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ss.setVisible(false); mainFrame.setVisible(true); } }); } }, "wait for add-on initialization"); t.start(); } } } @Override public void setSplashscreenInfo(SplashScreenInterface ss) { this.ss = ss; } }) { }, addPluginFile, showMainFrame); }
From source file:edu.ku.brc.specify.config.init.secwiz.SpecifyDBSecurityWizardFrame.java
/** * @throws HeadlessException/*from w w w . j a v a2 s . co m*/ */ public SpecifyDBSecurityWizardFrame() throws HeadlessException { super(); UIRegistry.loadAndPushResourceBundle("specifydbsetupwiz"); new MacOSAppHandler(this); UIRegistry.setTopWindow(this); // Now initialize AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); AppPrefsCache.setUseLocalOnly(true); SpecifyAppPrefs.setSkipRemotePrefs(true); SpecifyAppPrefs.initialPrefs(); ImageIcon helpIcon = IconManager.getIcon(SpecifyDBSecurityWizard.getIconName(), IconSize.Std16); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ JMenuBar menuBar = createMenus(); if (menuBar != null) { setJMenuBar(menuBar); } UIRegistry.register(UIRegistry.MENUBAR, menuBar); setIconImage( IconManager.getIcon(SpecifyDBSecurityWizard.getIconName(), IconManager.IconSize.NonStd).getImage()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); HelpMgr.setAppDefHelpId("security_wiz1"); SpecifyDBSecurityWizard wizPanel = new SpecifyDBSecurityWizard( new SpecifyDBSecurityWizard.WizardListener() { @Override public void cancelled() { setVisible(false); //dispose(); doExit(true); } @Override public void hide() { setVisible(false); } @Override public void finished() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dispose(); doExit(true); } }); } @Override public void panelChanged(String title) { setTitle(getAppTitle(title)); } }); setTitle(getAppTitle(getResourceString("MAIN_TITLE"))); setContentPane(wizPanel); pack(); }
From source file:com.floreantpos.model.MenuItem.java
public ImageIcon getScaledImage(int width, int height) { ImageIcon icon = new ImageIcon(getImageData()); Image scaledInstance = icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH); return new ImageIcon(scaledInstance); }