List of usage examples for javax.swing ImageIcon getImage
@Transient
public Image getImage()
Image
. From source file:net.sourceforge.atunes.kernel.modules.notify.CommonNotificationEngine.java
/** * Stores audio object in a temporal folder so it can be used from * third-party notification engines//from w ww.j a v a 2s . c o m * * @param audioObject * @param osManager * @return */ protected final String getTemporalImage(final IAudioObject audioObject, final IOSManager osManager) { ImageIcon imageForAudioObject = this.beanFactory.getBean(ILocalAudioObjectImageHandler.class) .getImage(audioObject, ImageSize.SIZE_200); if (imageForAudioObject == null) { imageForAudioObject = this.audioObjectGenericImageFactory .getGenericImage(audioObject, GenericImageSize.MEDIUM) .getIcon(this.lookAndFeelManager.getCurrentLookAndFeel().getPaintForSpecialControls()); } return net.sourceforge.atunes.utils.FileUtils.getPath(this.temporalDiskStorage.addImage( ImageUtils.toBufferedImage(imageForAudioObject.getImage()), UUID.randomUUID().toString())); }
From source file:LayeredPaneDemo.java
public LayeredPaneDemo() { super("Custom MDI: Part II"); setSize(570, 400);/*from w ww . j a v a 2 s . co m*/ getContentPane().setBackground(new Color(244, 232, 152)); getLayeredPane().setOpaque(true); InnerFrame[] frames = new InnerFrame[5]; for (int i = 0; i < 5; i++) { frames[i] = new InnerFrame("InnerFrame " + i); frames[i].setBounds(50 + i * 20, 50 + i * 20, 200, 200); getLayeredPane().add(frames[i]); } WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); ImageIcon image = new ImageIcon("spiral.gif"); setIconImage(image.getImage()); addWindowListener(l); setVisible(true); }
From source file:edu.ku.brc.ui.ImageDisplay.java
/** * Constructor with ImageIcon.//ww w . ja v a2 s. c om * @param imgIcon the icon to be displayed * @param isEditMode whether it is in browse mode or edit mode * @param hasBorder whether it has a border */ public ImageDisplay(final ImageIcon imgIcon, boolean isEditMode, boolean hasBorder) { this(imgIcon.getIconWidth(), imgIcon.getIconHeight(), isEditMode, hasBorder); setImage(imgIcon.getImage()); }
From source file:tn.mariages.gui.Accueil.java
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened int h = Toolkit.getDefaultToolkit().getScreenSize().height; int w = Toolkit.getDefaultToolkit().getScreenSize().width; Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(-27, -16); this.setSize(144, h + 16); this.setExtendedState(this.MAXIMIZED_VERT); System.out.println("H " + h); JFrame LogoFrame = new JFrame("Logo"); LogoFrame.setSize(w - 45, h + 16);/* w w w .j av a2 s . c o m*/ LogoFrame.setExtendedState(this.MAXIMIZED_HORIZ); this.setAlwaysOnTop(true); //LogoFrame.setExtendedState(LogoFrame.MAXIMIZED_BOTH); LogoFrame.setLocation(65, -16); JPanel logoPanel = new JPanel(); LogoFrame.add(logoPanel); ImageIcon icon; try { icon = new ImageIcon(new URL("http://www.images.tn/upload/original/1394208853.png")); /// TO CHANGE icon = new ImageIcon(icon.getImage().getScaledInstance(400, 400, BufferedImage.SCALE_SMOOTH)); JLabel logoLabel = new JLabel(icon); logoPanel.add(logoLabel); logoLabel.setAlignmentX(CENTER_ALIGNMENT); logoLabel.setAlignmentY(400); } catch (MalformedURLException ex) { Logger.getLogger(ListeFeatProd.class.getName()).log(Level.SEVERE, null, ex); } LogoFrame.setVisible(true); // TODO add your handling code here: }
From source file:fr.isen.browser5.Util.UrlLoader.java
public void setTabTitleFavicon() { String title = doc.title();/*from w ww .j a v a 2s .c om*/ title = Str.shortenString(title, 12); int tabIndex = tabView.getCurrentTabIndex(); JPanel tabPanel = (JPanel) tabView.getCurrentFrame().getTabPane().getTabComponentAt(tabIndex); JLabel titleLabel = (JLabel) tabPanel.getComponent(0); titleLabel.setText(title); String baseUrl = pageUrl.getProtocol() + "://" + pageUrl.getHost(); Element element = doc.head().select("link[href~=.*\\.(ico|png)]").first(); String favicoUrlStr = ""; if (element != null) { favicoUrlStr = element.attr("abs:href"); } else { element = doc.head().select("meta[itemprop=image]").first(); if (element != null) { favicoUrlStr = baseUrl + element.attr("content"); } } ImageIcon icon = null; try { if (!favicoUrlStr.isEmpty()) { if (favicoUrlStr.endsWith(".ico")) { java.util.List<BufferedImage> imgs = ICODecoder.read(new URL(favicoUrlStr).openStream()); icon = new ImageIcon(imgs.get(0)); } else { icon = new ImageIcon(new URL(favicoUrlStr)); } icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_DEFAULT)); } } catch (IOException e) { e.printStackTrace(); } titleLabel.setIcon(icon); HistoryEntry historyEntry = new HistoryEntry(title, pageUrl.toString(), Instant.now().getEpochSecond(), icon, -1L); globalHistoryDAO.create(historyEntry); }
From source file:gg.msn.ui.panel.MainPanel.java
@Override public void paint(Graphics g) { super.paint(g); try {/*from w w w. ja va2 s.co m*/ Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); //render per utenti Facebook if (ChatClientView.protocol.equals(ChatClientView.FACEBOOK_PROTOCOL)) { final FacebookUser user = (FacebookUser) value; int textY = (getHeight() / 2) + (g2.getFont().getSize() / 2); //name string g2.setFont(list.getFont()); g2.drawString(user.name, WHITE_SPACE + IMAGE_LATE + 3, textY); //status string // g2.setFont(list.getFont()); // g2.drawString(user.status, WHITE_SPACE + IMAGE_LATE + 3, textY); //icon ImageIcon icon = user.portrait; //log.debug("icon [" + icon + "]"); //ImageIcon scaledIcon = new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_AREA_AVERAGING)); g2.drawImage(icon.getImage(), WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE, IMAGE_LATE, null); // g2.setColor(Color.WHITE); // g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE, IMAGE_LATE, ARC_SIZE, ARC_SIZE); // g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - ((IMAGE_LATE+1) / 2), IMAGE_LATE+1, IMAGE_LATE+1, ARC_SIZE, ARC_SIZE); // g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - ((IMAGE_LATE+2) / 2), IMAGE_LATE+2, IMAGE_LATE+2, ARC_SIZE, ARC_SIZE); //render per utenti Client // log.debug("user status [" + user.status + "]"); // log.debug("user online status [" + user.onlineStatus + "]"); if (StringUtils.equals(user.status, FacebookUser.STATUS_ONLINE)) { g2.setColor(Color.GREEN); g2.fillOval(getWidth() - STATUS_ICON_OFFSET, (getHeight() / 2) - (STATUS_ICON_WIDTH / 2), STATUS_ICON_WIDTH, STATUS_ICON_WIDTH); } else { g2.setColor(Color.GRAY); g2.fillOval(getWidth() - STATUS_ICON_OFFSET, (getHeight() / 2) - (STATUS_ICON_WIDTH / 2), STATUS_ICON_WIDTH, STATUS_ICON_WIDTH); } } else { g2.setFont(list.getFont()); int textY = (getHeight() / 2) + (g2.getFont().getSize() / 2); Client client = (Client) value; // setText((client).getNick()); ImageIcon icon = null; try { new ImageIcon(client.getImage()); } catch (Exception e) { // log.debug("immgine non presente"); icon = ThemeManager.getTheme().get(ThemeManager.USER_ICON); } g2.drawString(client.getNick(), WHITE_SPACE + IMAGE_LATE + 3, textY); //log.debug("icon [" + icon + "]"); //ImageIcon scaledIcon = new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_AREA_AVERAGING)); g2.drawImage(icon.getImage(), WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE, IMAGE_LATE, null); // setFont(list.getFont()); // setIcon(scaledIcon); } } catch (Exception e) { log.warn(e); } }
From source file:eu.delving.sip.Application.java
private Application(final File storageDir) throws StorageException { GroovyCodeResource groovyCodeResource = new GroovyCodeResource(getClass().getClassLoader()); final ImageIcon backgroundIcon = new ImageIcon(getClass().getResource("/delving-background.png")); desktop = new JDesktopPane() { public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(backgroundIcon.getImage(), 0, 0, desktop); }/* www .j a v a 2 s .c o m*/ }; desktop.setMinimumSize(new Dimension(MINIMUM_DESKTOP_SIZE)); resizeTimer = new Timer(DEFAULT_RESIZE_INTERVAL, new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { resizeTimer.stop(); for (JInternalFrame frame : desktop.getAllFrames()) { if (frame instanceof FrameBase) { ((FrameBase) frame).ensureOnScreen(); } } } }); desktop.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent componentEvent) { resizeTimer.restart(); } }); Preferences preferences = Preferences.userNodeForPackage(SipModel.class); feedback = new VisualFeedback(home, desktop, preferences); HttpClient httpClient = createHttpClient(storageDir); SchemaRepository schemaRepository; try { schemaRepository = new SchemaRepository(new SchemaFetcher(httpClient)); } catch (IOException e) { throw new StorageException("Unable to create Schema Repository", e); } ResolverContext context = new ResolverContext(); Storage storage = new StorageImpl(storageDir, schemaRepository, new CachedResourceResolver(context)); context.setStorage(storage); context.setHttpClient(httpClient); sipModel = new SipModel(desktop, storage, groovyCodeResource, feedback, preferences); CultureHubClient cultureHubClient = isStandalone(storageDir) ? null : new CultureHubClient(sipModel, httpClient); if (cultureHubClient != null) uploadAction = new UploadAction(sipModel, cultureHubClient); expertMenu = new ExpertMenu(desktop, sipModel, cultureHubClient, allFrames); statusPanel = new StatusPanel(sipModel); home = new JFrame(titleString()); home.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent componentEvent) { allFrames.getViewSelector().refreshView(); } }); JPanel content = (JPanel) home.getContentPane(); content.setFocusable(true); FrameBase dataSetFrame = cultureHubClient != null ? new DataSetHubFrame(sipModel, cultureHubClient) : new DataSetStandaloneFrame(sipModel, schemaRepository); LogFrame logFrame = new LogFrame(sipModel); feedback.setLog(logFrame.getLog()); allFrames = new AllFrames(sipModel, content, dataSetFrame, logFrame); desktop.setBackground(new Color(190, 190, 200)); content.add(desktop, BorderLayout.CENTER); sipModel.getMappingModel().addChangeListener(new MappingModel.ChangeListener() { @Override public void lockChanged(MappingModel mappingModel, final boolean locked) { sipModel.exec(new Swing() { @Override public void run() { unlockMappingAction.setEnabled(locked); } }); } @Override public void functionChanged(MappingModel mappingModel, MappingFunction function) { } @Override public void nodeMappingChanged(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping, NodeMappingChange change) { } @Override public void nodeMappingAdded(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping) { } @Override public void nodeMappingRemoved(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping) { } @Override public void populationChanged(MappingModel mappingModel, RecDefNode node) { } }); importAction = new ImportAction(desktop, sipModel); attachAccelerator(importAction, home); validateAction = new ValidateAction(sipModel, allFrames.prepareForInvestigation(desktop)); unlockMappingAction = new UnlockMappingAction(sipModel); attachAccelerator(unlockMappingAction, home); selectAnotherMappingAction = new SelectAnotherMappingAction(sipModel); attachAccelerator(selectAnotherMappingAction, home); content.add(createStatePanel(), BorderLayout.SOUTH); content.add(allFrames.getSidePanel(), BorderLayout.WEST); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); screen.height -= 30; home.setSize(screen); home.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); ImageIcon logo = new ImageIcon(getClass().getResource("/sip-creator-logo.png")); home.setIconImage(logo.getImage()); home.setJMenuBar(createMenuBar()); home.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent windowEvent) { quit(); } }); home.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); sipModel.getDataSetModel().addListener(new DataSetModel.SwingListener() { @Override public void stateChanged(DataSetModel model, DataSetState state) { statusPanel.setState(state); switch (state) { case ABSENT: sipModel.exec(new Work() { @Override public void run() { sipModel.getDataSetFacts().set(null); sipModel.getStatsModel().setStatistics(null); } @Override public Job getJob() { return Job.CLEAR_FACTS_STATS; } }); home.setTitle(titleString()); sipModel.seekReset(); break; default: DataSetModel dataSetModel = sipModel.getDataSetModel(); home.setTitle(String.format(titleString() + " - [%s -> %s]", dataSetModel.getDataSet().getSpec(), dataSetModel.getPrefix().toUpperCase())); sipModel.getReportFileModel().refresh(); break; } } }); attachAccelerator(new QuitAction(), home); attachAccelerator(statusPanel.getButtonAction(), home); }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * //from w w w. j a v a 2 s . c om */ protected void buildUI() { SchemaLocalizerXMLHelper slxh = new SchemaLocalizerXMLHelper(schemaType, tableMgr); localizableIO = slxh; localizableIO.load(false); //stripToSingleLocale("pt", slxh); LocalizableStrFactory localizableStrFactory = new LocalizableStrFactory() { public LocalizableStrIFace create() { SpLocaleItemStr str = new SpLocaleItemStr(); str.initialize(); return str; } public LocalizableStrIFace create(String text, Locale locale) { return new SpLocaleItemStr(text, locale); // no initialize needed for this constructor } }; LocalizerBasePanel.setLocalizableStrFactory(localizableStrFactory); SchemaLocalizerXMLHelper.setLocalizableStrFactory(localizableStrFactory); schemaLocPanel = new SchemaLocalizerPanel(null, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, webLinkMgrCache, schemaType); schemaLocPanel.setLocalizableIO(localizableIO); schemaLocPanel.setStatusBar(statusBar); boolean useDisciplines = AppPreferences.getLocalPrefs().getBoolean("SCHEMA_DISP", false); schemaLocPanel.setUseDisciplines(useDisciplines); // rods - for now //schemaLocPanel.setIncludeHiddenUI(true); schemaLocPanel.buildUI(); schemaLocPanel.setHasChanged(localizableIO.didModelChangeDuringLoad()); statusBar.setSectionText(1, schemaType == SpLocaleContainer.CORE_SCHEMA ? getResourceString("SchemaLocalizerFrame.FULL_SCHEMA") //$NON-NLS-1$ : getResourceString("SchemaLocalizerFrame.WB_SCHEMA")); //$NON-NLS-1$ UIRegistry.setStatusBar(statusBar); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); String title = "File"; //$NON-NLS-1$ String mneu = "F"; //$NON-NLS-1$ JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "Save"; //$NON-NLS-1$ mneu = "S"; //$NON-NLS-1$ JMenuItem saveMenuItem = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", false, //$NON-NLS-1$ new ActionListener() { public void actionPerformed(ActionEvent e) { write(); } }); saveMenuItem.setEnabled(false); title = "Export"; //$NON-NLS-1$ mneu = "E"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { export(); } }); title = "SchemaLocalizerFrame.ExportLOCALE"; //$NON-NLS-1$ mneu = "SchemaLocalizerFrame.ExportLOCALEMnu"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { exportSingleLocale(); } }); title = "Exit"; //$NON-NLS-1$ mneu = "x"; //$NON-NLS-1$ if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { shutdown(); } }); } /* JMenu toolMenu = UIHelper.createMenu(menuBar, "Tools", "T"); UIHelper.createMenuItem(toolMenu, "Create Resource Files", "C", "", true, new ActionListener() { public void actionPerformed(ActionEvent e) { createResourceFiles(); } }); */ menuBar.add(SchemaI18NService.getInstance().createLocaleMenu(this, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("locale")) //$NON-NLS-1$ { schemaLocPanel.localeChanged((Locale) evt.getNewValue()); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); } } })); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setSize(800, 600); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(schemaLocPanel, BorderLayout.CENTER); mainPanel.add(statusBar, BorderLayout.SOUTH); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); setContentPane(mainPanel); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); schemaLocPanel.setSaveMenuItem(saveMenuItem); schemaLocPanel.getContainerList().setEnabled(true); AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); ImageIcon helpIcon = IconManager.getIcon("AppIcon", IconSize.Std16); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ AppPrefsCache.setUseLocalOnly(true); SpecifyAppPrefs.loadColorAndFormatPrefs(); if (localizableIO.didModelChangeDuringLoad()) { saveMenuItem.setEnabled(true); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(getResourceString("SchemaLocalizerFrame.CHG_TO_SCHEMA")); //$NON-NLS-1$ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JTextPane tp = new JTextPane(); JScrollPane js = new JScrollPane(); js.getViewport().add(tp); tp.setContentType("text/html"); tp.setText(((SchemaLocalizerXMLHelper) localizableIO).getChangesBuffer()); frame.setContentPane(js); frame.pack(); frame.setSize(400, 500); frame.setVisible(true); } }); } }
From source file:nl.phanos.liteliveresultsclient.gui.ResultsWindows.java
private void showPhoto() { int pheight = jScrollPane1.getPreferredSize().height; if (jCheckBoxMenuItem2.getState() == true && this.resultFile != null && this.resultFile.Photo != null) { ImageIcon myPicture = new ImageIcon(this.resultFile.Photo); Dimension dim = getScaledDimension(myPicture.getIconWidth(), myPicture.getIconHeight(), LayerdPane.getWidth() / 2, pheight); Image image = myPicture.getImage(); // transform it Image newimg = image.getScaledInstance(dim.width, dim.height, java.awt.Image.SCALE_SMOOTH); // scale it the smooth way myPicture = new ImageIcon(newimg); // transform it back photolabel.setIcon(myPicture);/* ww w. j av a 2s. co m*/ photopanel.setPreferredSize(new Dimension(LayerdPane.getWidth() / 2, pheight)); System.out.println(myPicture.getIconWidth()); } else { photopanel.setPreferredSize(new Dimension(0, pheight)); } repaint(); }
From source file:LayeredPaneDemo2.java
public LayeredPaneDemo2() { super("Custom MDI: Part III"); setSize(570, 400);//from w w w. j a v a2s. c om getContentPane().setBackground(new Color(244, 232, 152)); getLayeredPane().setOpaque(true); // VERY IMPORTANT!! ImageIcon ii = new ImageIcon("earth.jpg"); InnerFrame[] frames = new InnerFrame[5]; for (int i = 0; i < 5; i++) { frames[i] = new InnerFrame("InnerFrame " + i); frames[i].setBounds(50 + i * 20, 50 + i * 20, 200, 200); frames[i].getContentPane().add(new JScrollPane(new JLabel(ii))); getLayeredPane().add(frames[i]); } WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); ImageIcon image = new ImageIcon("spiral.gif"); setIconImage(image.getImage()); addWindowListener(l); setVisible(true); }