List of usage examples for javax.swing ImageIcon getImage
@Transient
public Image getImage()
Image
. From source file:FilterSample.java
public void propertyChange(PropertyChangeEvent changeEvent) { String changeName = changeEvent.getPropertyName(); if (changeName.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { File file = (File) changeEvent.getNewValue(); if (file != null) { ImageIcon icon = new ImageIcon(file.getPath()); if (icon.getIconWidth() > PREFERRED_WIDTH) { icon = new ImageIcon( icon.getImage().getScaledInstance(PREFERRED_WIDTH, -1, Image.SCALE_DEFAULT)); if (icon.getIconHeight() > PREFERRED_HEIGHT) { icon = new ImageIcon( icon.getImage().getScaledInstance(-1, PREFERRED_HEIGHT, Image.SCALE_DEFAULT)); }/*from w w w. j av a 2s . c om*/ } setIcon(icon); } } }
From source file:FileChooserTest.java
/** * Constructs an ImagePreviewer./* ww w. j av a2 s . co m*/ * @param chooser the file chooser whose property changes trigger an image change in this * previewer */ public ImagePreviewer(JFileChooser chooser) { setPreferredSize(new Dimension(100, 100)); setBorder(BorderFactory.createEtchedBorder()); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName() == JFileChooser.SELECTED_FILE_CHANGED_PROPERTY) { // the user has selected a new file File f = (File) event.getNewValue(); if (f == null) { setIcon(null); return; } // read the image into an icon ImageIcon icon = new ImageIcon(f.getPath()); // if the icon is too large to fit, scale it if (icon.getIconWidth() > getWidth()) icon = new ImageIcon( icon.getImage().getScaledInstance(getWidth(), -1, Image.SCALE_DEFAULT)); setIcon(icon); } } }); }
From source file:gdt.jgui.console.JItemPanel.java
/** * The constructor./*from ww w . j a va 2 s.c o m*/ * @param console the main console. * @param locator$ the item's locator. */ public JItemPanel(JMainConsole console, String locator$) { this.console = console; this.locator$ = locator$; setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); setAlignmentX(Component.LEFT_ALIGNMENT); try { this.console = console; this.locator$ = locator$; Properties locator = Locator.toProperties(locator$); if (Locator.LOCATOR_TRUE.equals(locator.getProperty(Locator.LOCATOR_CHECKABLE))) { checkbox = new JCheckBox(); add(checkbox); if (Locator.LOCATOR_TRUE.equals(locator.getProperty(Locator.LOCATOR_CHECKED))) if (checkbox != null) checkbox.setSelected(true); } title$ = locator.getProperty(Locator.LOCATOR_TITLE); if (title$ != null) { title = new JLabel(title$, JLabel.LEFT); title.setText(title$); title.setOpaque(true); title.addMouseListener(new MousePopupListener()); title.setAlignmentX(Component.LEFT_ALIGNMENT); add(title, BorderLayout.WEST); icon$ = locator.getProperty(Locator.LOCATOR_ICON); if (icon$ != null) { byte[] ba = Base64.decodeBase64(icon$); ImageIcon icon = new ImageIcon(ba); Image image = icon.getImage().getScaledInstance(24, 24, 0); icon.setImage(image); title.setIcon(icon); } } else LOGGER.info("title is null"); } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:edu.ku.brc.ui.skin.SkinItem.java
/** * @return/* w ww . j av a 2 s . co m*/ */ public Image getBGImage() { if (bgImage == null) { if ((new File(imagePath)).exists()) { ImageIcon imgIcon = new ImageIcon(imagePath); bgImage = imgIcon.getImage(); } } return bgImage; }
From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.KgmlEdMain.java
/** * Constructs a new instance of the editor. *///from w w w.j a va 2s.c o m public KgmlEdMain(final boolean showMainFrame, String applicationName, String[] args) { // URL config, final ThreadSafeOptions tso = new ThreadSafeOptions(); SplashScreenInterface splashScreen = new DBEsplashScreen(applicationName, "", new Runnable() { public void run() { if (showMainFrame) { ClassLoader cl = this.getClass().getClassLoader(); String path = this.getClass().getPackage().getName().replace('.', '/'); ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png")); final MainFrame mainFrame = MainFrame.getInstance(); mainFrame.setIconImage(icon.getImage()); Thread t = new Thread(new Runnable() { 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); SplashScreenInterface ss = (SplashScreenInterface) tso.getParam(0, null); ss.setVisible(false); mainFrame.setVisible(true); } }, "wait for add-on initialization"); t.start(); } } }); tso.setParam(0, splashScreen); ClassLoader cl = this.getClass().getClassLoader(); String path = this.getClass().getPackage().getName().replace('.', '/'); ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png")); ((DBEsplashScreen) splashScreen).setIconImage(icon.getImage()); splashScreen.setVisible(true); GravistoMainHelper.createApplicationSettingsFolder(splashScreen); 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"); JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + "While " + DBEgravistoHelper.DBE_GRAVISTO_VERSION + " is available as a academic research tool at no cost to commercial and non-commercial users, for using<br>" + "KEGG related functions, it is necessary for all users to adhere to the KEGG license.<br>" + "For using " + DBEgravistoHelper.DBE_GRAVISTO_VERSION + " you need also be aware of information about licenses and conditions for<br>" + "usage, listed at the program info dialog and the " + DBEgravistoHelper.DBE_GRAVISTO_VERSION + " website (" + ReleaseInfo.getAppWebURL() + ").<br><br>" + DBEgravistoHelper.DBE_GRAVISTO_VERSION + " does not distribute information from KEGG but contains functionality for the online-access to information from KEGG wesite.<br><br>" + "<b>Before these functions are available to you, you should carefully read the following license information<br>" + "and decide if it is legit for you to use the KEGG related program functions. If you choose not to use the KEGG functions<br>" + "all other features of this application are still available and fully working.", DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + MenuItemInfoDialog.getKEGGlibText(), DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); int result = JOptionPane.showConfirmDialog(null, "<html><h3>Enable KEGG functions?", DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); 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 aborted.", DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } splashScreen.setVisible(true); } GravistoMainHelper.initApplicationExt(args, splashScreen, cl, null, null); }
From source file:gdt.jgui.tool.JIconSelector.java
/** * Create the context.//w ww.j av a2 s .c o m * @param console the main console. * @param locator$ the locator string. * @return the procedure context. */ @Override public JContext instantiate(JMainConsole console, String locator$) { this.console = console; try { panel.removeAll(); Properties locator = Locator.toProperties(locator$); entihome$ = locator.getProperty(Entigrator.ENTIHOME); entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); entityLabel$ = locator.getProperty(EntityHandler.ENTITY_LABEL); requesterResponseLocator$ = locator.getProperty(JRequester.REQUESTER_RESPONSE_LOCATOR); // System.out.println("IconSelector:instantiate:locator="+locator$); Entigrator entigrator = console.getEntigrator(entihome$); String icons$ = entigrator.ent_getHome(Entigrator.ICONS); File icons = new File(icons$); File[] fa = icons.listFiles(); if (fa == null) return this; ImageIcon icon; JLabel label; Image img; for (File aFa : fa) { icon = new ImageIcon(aFa.getPath()); img = icon.getImage(); img = img.getScaledInstance(smallIcon, smallIcon, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(img); label = new JLabel(); label.setIcon(icon); label.setName(aFa.getName()); label.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { try { JLabel label = (JLabel) me.getSource(); icon$ = label.getName(); byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); responseLocator$ = Locator.append(responseLocator$, ICON, icon$); JConsoleHandler.execute(JIconSelector.this.console, responseLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); panel.add(label); } } catch (Exception e) { LOGGER.severe(e.toString()); } return this; }
From source file:br.com.postalis.folhapgto.service.SvcFolhaPgtoImpl.java
private void gerarRelatorio(String nomeRel, String relJrxml, List<?> lista, Date dtRef) { JasperReport report = null;/*from w ww . j a v a 2s .c om*/ String caminhoCompletoRel = ""; try { String pasta = "C:\\POSTALIS\\RELATORIOS\\"; report = JasperCompileManager .compileReport(getClass().getResourceAsStream("/relatorios/" + relJrxml + ".jrxml")); ImageIcon gto = new ImageIcon(getClass().getResource("/imagens/Logo branca.jpg")); Map parametros = new HashMap(); parametros.put("logo", gto.getImage()); parametros.put("referencia", DataUtil.getDataS(dtRef, "MM/yyyy")); caminhoCompletoRel = pasta + nomeRel + "_" + DataUtil.getDataS(dtRef, "ddMMyyyy") + "_" + DataUtil.getDiaProcessamentoComHoraMinutoSegundo() + ".pdf"; JasperPrint print = JasperFillManager.fillReport(report, parametros, new JRBeanCollectionDataSource(lista)); JasperExportManager.exportReportToPdfFile(print, caminhoCompletoRel); File pdf = new File(caminhoCompletoRel); Desktop.getDesktop().open(pdf); } catch (JRException ex) { LOGGER.error("Erro construir o relatorio Jasper: " + ex); } catch (IOException ex) { LOGGER.error("Erro ao abrir o relatorio em PDF a partir da pasta: " + caminhoCompletoRel + ". Motivo: " + ex); } }
From source file:edu.ku.brc.ui.ProgressFrame.java
/** * @param title//www. j a v a2 s .com * @param iconName */ protected void createUI(final String title, final String iconName) { PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,5px,p,5px,p,10px,p")); CellConstraints cc = new CellConstraints(); overallProgress = new JProgressBar(); processProgress = new JProgressBar(); desc = createLabel(""); closeBtn = createButton("Cancel"); processProgress.setStringPainted(true); overallProgress.setStringPainted(true); desc.setHorizontalAlignment(SwingConstants.CENTER); builder.add(desc, cc.xywh(1, 1, 3, 1)); builder.add(createLabel("Process:"), cc.xy(1, 3)); // I18N builder.add(processProgress, cc.xy(3, 3)); builder.add(overallLbl = createLabel("Overall:"), cc.xy(1, 5)); // I18N builder.add(overallProgress, cc.xy(3, 5)); builder.add(closeBtn, cc.xy(1, 7)); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel mainPanel = new JPanel(new BorderLayout()); if (StringUtils.isNotEmpty(iconName)) { PanelBuilder iconBldr = new PanelBuilder( new FormLayout("8px, f:p:g,130px,f:p:g", "8px,f:p:g,130px,f:p:g, 8px")); iconBldr.add(new JLabel(IconManager.getIcon(iconName)), cc.xy(3, 3)); mainPanel.add(iconBldr.getPanel(), BorderLayout.WEST); mainPanel.add(builder.getPanel(), BorderLayout.CENTER); } else { mainPanel = builder.getPanel(); } setContentPane(mainPanel); setSize(new Dimension(500, 125)); setTitle(title); overallProgress.setIndeterminate(true); instance = this; closeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { instance.setVisible(false); System.exit(0); } }); setDefaultCloseOperation(DISPOSE_ON_CLOSE); ImageIcon appIcon = IconManager.getIcon("AppIcon"); //$NON-NLS-1$ if (appIcon != null) { setIconImage(appIcon.getImage()); } pack(); }
From source file:edu.ku.brc.specify.config.AgentSearchDialogES.java
/** * * @throws HeadlessException//ww w. j a v a 2s . com */ public AgentSearchDialogES(final Frame parent) throws HeadlessException { super(parent, getResourceString("AgentSearchTitle"), true); tableId = DBTableIdMgr.getInstance().getIdByShortName("agent"); String[] mappings = { "lastName", "lastname", "firstName", "firstname" }; for (int i = 0; i < mappings.length; i++) { formFieldToColumnMap.put(mappings[i], mappings[i + 1]); i++; } createUI(); setLocationRelativeTo(UIRegistry.get(UIRegistry.FRAME)); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); ImageIcon appIcon = IconManager.getIcon("AppIcon"); //$NON-NLS-1$ if (appIcon != null) { setIconImage(appIcon.getImage()); } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreeRenderer.java
/** * @param g2d// w w w . ja v a 2s . co m * @param xc * @param yc * @param imgIcon * @param hitsInx * @return */ private int drawIcon(final Graphics2D g2d, final int xc, final int yc, final ImageIcon imgIcon, final int hitsInx) { g2d.drawImage(imgIcon.getImage(), xc, yc, null); hitRects[hitsInx].setBounds(xc, yc, imgIcon.getIconWidth(), imgIcon.getIconHeight()); Point p = hitRects[hitsInx].getLocation(); SwingUtilities.convertPointToScreen(p, this); hitRects[hitsInx].setLocation(p); return imgIcon.getIconWidth() + iconSep; }