List of usage examples for javax.swing ImageIcon getImage
@Transient
public Image getImage()
Image
. From source file:edu.ku.brc.specify.Specify.java
/** * @param imgEncoded uuencoded image string */// w ww .j a v a 2 s.c o m protected void setAppIcon(final String imgEncoded) { String appIconName = getIconName(); String innerAppIconName = "InnerAppIcon"; ImageIcon appImgIcon = null; if (StringUtils.isNotEmpty(imgEncoded)) { appImgIcon = GraphicsUtils.uudecodeImage("", imgEncoded); //$NON-NLS-1$ if (appImgIcon != null && appImgIcon.getIconWidth() == 32 && appImgIcon.getIconHeight() == 32) { appIcon.setIcon(appImgIcon); CustomDialog.setAppIcon(appImgIcon); CustomFrame.setAppIcon(appImgIcon); IconManager.register(innerAppIconName, appImgIcon, null, IconManager.IconSize.Std32); return; } } appImgIcon = IconManager.getImage(appIconName, IconManager.IconSize.Std32); //$NON-NLS-1$ appIcon.setIcon(appImgIcon); if (!UIHelper.isMacOS()) { ImageIcon otherAppIcon = IconManager.getImage(getOpaqueIconName(), IconManager.IconSize.Std32); //$NON-NLS-1$ if (otherAppIcon != null) { appImgIcon = otherAppIcon; } } CustomDialog.setAppIcon(appImgIcon); CustomFrame.setAppIcon(appImgIcon); IconManager.register(innerAppIconName, appImgIcon, null, IconManager.IconSize.Std32); this.topFrame.setIconImage(appImgIcon.getImage()); }
From source file:edu.ku.brc.specify.utilapps.BuildSampleDatabase.java
/** * Drops, Creates and Builds the Database. * // w w w .jav a 2 s. c o m * @throws SQLException * @throws IOException */ public boolean buildEmptyDatabase(final Properties props, final boolean doFromWizard) { createProgressFrame("Building Specify Database"); final String dbName = props.getProperty("dbName"); frame.adjustProgressFrame(); frame.setTitle("Building Specify Database"); if (!hideFrame) { UIHelper.centerWindow(frame); frame.setVisible(true); ImageIcon imgIcon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std16); if (imgIcon != null) { frame.setIconImage(imgIcon.getImage()); } } else { System.out.println("Building Specify Database Username[" + props.getProperty("dbUserName") + "]"); } frame.setProcessPercent(true); frame.setOverall(0, 4); frame.getCloseBtn().setVisible(false); steps = 0; SwingUtilities.invokeLater(new Runnable() { public void run() { frame.getProcessProgress().setIndeterminate(true); frame.getProcessProgress().setString(""); frame.setDesc("Creating Database Schema for " + dbName); frame.setOverall(steps++); } }); DatabaseDriverInfo driverInfo = (DatabaseDriverInfo) props.get("driver"); try { if (hideFrame) System.out.println("Creating schema"); String itUsername = props.getProperty("dbUserName"); String itPassword = props.getProperty("dbPassword"); boolean doBuild = true; if (doBuild) { SpecifySchemaGenerator.generateSchema(driverInfo, props.getProperty("hostName"), dbName, itUsername, itPassword); } SwingUtilities.invokeLater(new Runnable() { public void run() { frame.getProcessProgress().setIndeterminate(true); frame.getProcessProgress().setString(""); frame.setDesc("Logging into " + dbName + "...."); frame.setOverall(steps++); } }); String connStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Create, props.getProperty("hostName"), dbName); if (connStr == null) { connStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, props.getProperty("hostName"), dbName); } if (!UIHelper.tryLogin(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(), dbName, connStr, itUsername, itPassword)) { if (hideFrame) System.out.println("Login Failed!"); return false; } String saUserName = props.getProperty("saUserName"); // Master Username String saPassword = props.getProperty("saPassword"); // Master Password createSpecifySAUser(props.getProperty("hostName"), itUsername, itPassword, saUserName, saPassword, dbName); if (!UIHelper.tryLogin(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(), dbName, connStr, saUserName, saPassword)) { if (hideFrame) System.out.println("Login Failed!"); return false; } setSession(HibernateUtil.getCurrentSession()); //DataBuilder.setSession(session); SwingUtilities.invokeLater(new Runnable() { public void run() { frame.getProcessProgress().setIndeterminate(true); frame.getProcessProgress().setString(""); frame.setDesc("Creating database " + dbName + "...."); frame.setOverall(steps++); } }); Thumbnailer thumb = Thumbnailer.getInstance(); File thumbFile = XMLHelper.getConfigDir("thumbnail_generators.xml"); thumb.registerThumbnailers(thumbFile); thumb.setQuality(0.5f); thumb.setMaxSize(128, 128); File attLoc = getAppDataSubDir("AttachmentStorage", true); FileUtils.cleanDirectory(attLoc); AttachmentManagerIface attachMgr = new FileStoreAttachmentManager(attLoc); AttachmentUtils.setAttachmentManager(attachMgr); AttachmentUtils.setThumbnailer(thumb); if (hideFrame) System.out.println("Creating Empty Database"); createEmptyInstitution(props, true, true, doFromWizard, getTreeDirForClass(props, StorageTreeDef.class)); SwingUtilities.invokeLater(new Runnable() { public void run() { frame.getProcessProgress().setIndeterminate(true); frame.getProcessProgress().setString(""); frame.setDesc("Saving data into " + dbName + "...."); frame.setOverall(steps++); } }); if (hideFrame) System.out.println("Persisting Data..."); HibernateUtil.getCurrentSession().close(); if (hideFrame) System.out.println("Done."); frame.setVisible(false); frame.dispose(); SpecifyDeleteHelper.showTableCounts("EmptyDB.txt", true); return true; } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:edu.ku.brc.specify.utilapps.BuildSampleDatabase.java
/** * Drops, Creates and Builds the Database. * /*from ww w . j a v a 2 s.co m*/ * @throws SQLException */ protected void build(final String dbName, final String driverName, final Pair<String, String> dbUser, final Pair<String, String> saUser, final Pair<String, String> cmUser) throws SQLException { frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.pack(); Dimension size = frame.getSize(); size.width = Math.max(size.width, 500); frame.setSize(size); frame.setTitle("Building Specify Database"); if (!hideFrame) { UIHelper.centerWindow(frame); frame.setVisible(true); ImageIcon imgIcon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std16); if (imgIcon != null) { frame.setIconImage(imgIcon.getImage()); } } frame.setProcessPercent(true); frame.setOverall(0, 7 + this.selectedChoices.size()); frame.getCloseBtn().setVisible(false); String databaseHost = initPrefs.getProperty("initializer.host", "localhost"); frame.setTitle("Building -> Database: " + dbName + " Driver: " + driverName + " User: " + cmUser.first); steps = 0; SwingUtilities.invokeLater(new Runnable() { public void run() { frame.getProcessProgress().setIndeterminate(true); frame.getProcessProgress().setString(""); frame.setDesc("Creating Database Schema for " + dbName); frame.setOverall(steps++); } }); DatabaseDriverInfo driverInfo = DatabaseDriverInfo.getDriver(driverName); if (driverInfo == null) { String msg = "Couldn't find driver by name [" + driverInfo + "] in driver list."; showError(msg); throw new RuntimeException(msg); } String newConnStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, databaseHost, dbName, saUser.first, saUser.second, driverInfo.getName()); DBConnection.checkForEmbeddedDir(newConnStr); if (DBConnection.isEmbedded(newConnStr)) { try { Class.forName(driverInfo.getDriverClassName()); DBConnection testDB = DBConnection.createInstance(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(), dbName, newConnStr, saUser.first, saUser.second); testDB.getConnection(); } catch (Exception ex) { ex.printStackTrace(); } DBConnection.getInstance().setDatabaseName(null); } SpecifySchemaGenerator.generateSchema(driverInfo, databaseHost, dbName, dbUser.first, dbUser.second); SwingUtilities.invokeLater(new Runnable() { public void run() { frame.setDesc("Logging in..."); frame.setOverall(steps++); } }); if (UIHelper.tryLogin(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(), dbName, driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, databaseHost, dbName), saUser.first, saUser.second)) { createSpecifySAUser(databaseHost, dbUser.first, dbUser.second, saUser.first, saUser.second, dbName); boolean single = true; if (single) { SwingUtilities.invokeLater(new Runnable() { public void run() { frame.setDesc("Creating data..."); frame.setOverall(steps++); } }); try { Thumbnailer thumb = Thumbnailer.getInstance(); File thumbFile = XMLHelper.getConfigDir("thumbnail_generators.xml"); thumb.registerThumbnailers(thumbFile); thumb.setQuality(0.5f); thumb.setMaxSize(128, 128); frame.setDesc("Cleaning Attachment Cache..."); frame.setOverall(steps++); File attLoc = getAppDataSubDir("AttachmentStorage", true); try { FileUtils.cleanDirectory(attLoc); } catch (IOException e) { String msg = "failed to connect to directory location to delete directory: " + attLoc; log.warn(msg); showError(msg); } AttachmentManagerIface attachMgr = new FileStoreAttachmentManager(attLoc); AttachmentUtils.setAttachmentManager(attachMgr); AttachmentUtils.setThumbnailer(thumb); // save it all to the DB setSession(HibernateUtil.getCurrentSession()); //DataBuilder.setSession(session); createDisciplines(cmUser.first, cmUser.second); attachMgr.cleanup(); frame.setDesc("Done Saving data..."); frame.setOverall(steps++); frame.setDesc("Copying Preferences..."); frame.setOverall(steps++); AppPreferences remoteProps = AppPreferences.getRemote(); for (Object key : initPrefs.keySet()) { String keyStr = (String) key; if (!keyStr.startsWith("initializer.") && !keyStr.startsWith("useragent.")) { remoteProps.put(keyStr, (String) initPrefs.get(key)); } } AppPreferences.getRemote().flush(); frame.setDesc("Build Completed."); frame.setOverall(steps++); assignPermssions(); log.info("Done"); } catch (Exception e) { e.printStackTrace(); try { rollbackTx(); log.error("Failed to persist DB objects", e); showError("Failed to persist DB objects"); return; } catch (Exception e2) { log.error( "Failed to persist DB objects. Rollback failed. DB may be in inconsistent state.", e2); showError("Failed to persist DB objects. Rollback failed."); return; } } } } else { log.error("Login failed"); showError("Login failed"); return; } System.out.println("All done"); if (frame != null) { frame.processDone(); } // Set the Schema Size into Locale Prefs String schemaKey = "schemaSize"; int schemaFileSize = 0; File schemaFile = XMLHelper.getConfigDir("specify_datamodel.xml"); if (schemaFile != null) { schemaFileSize = (int) schemaFile.length(); AppPreferences.getLocalPrefs().putInt(schemaKey, schemaFileSize); } JOptionPane.showMessageDialog(getTopWindow(), "The build completed successfully.", "Complete", JOptionPane.INFORMATION_MESSAGE); }
From source file:net.sourceforge.squirrel_sql.client.gui.HelpViewerWindow.java
/** * Create user interface.//from www.j a v a2s . c o m */ private void createGUI() throws IOException { setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final SquirrelResources rsrc = _app.getResources(); final ImageIcon icon = rsrc.getIcon(SquirrelResources.IImageNames.VIEW); if (icon != null) { setIconImage(icon.getImage()); } Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setBorder(BorderFactory.createEmptyBorder()); splitPane.setOneTouchExpandable(true); splitPane.setContinuousLayout(true); splitPane.add(createContentsTree(), JSplitPane.LEFT); splitPane.add(createDetailsPanel(), JSplitPane.RIGHT); contentPane.add(splitPane, BorderLayout.CENTER); splitPane.setDividerLocation(200); contentPane.add(new HtmlViewerPanelToolBar(_app, _detailPnl), BorderLayout.NORTH); Font fn = _app.getFontInfoStore().getStatusBarFontInfo().createFont(); _statusBar.setFont(fn); contentPane.add(_statusBar, BorderLayout.SOUTH); pack(); SwingUtilities.invokeLater(new Runnable() { public void run() { _detailPnl.setHomeURL(_homeURL); _tree.expandRow(0); _tree.expandRow(2); if (_app.getSquirrelPreferences().isFirstRun()) { _tree.setSelectionRow(1); } else { _tree.setSelectionRow(3); } _tree.setRootVisible(false); } }); _detailPnl.addListener(new IHtmlViewerPanelListener() { public void currentURLHasChanged(HtmlViewerPanelListenerEvent evt) { selectTreeNodeForURL(evt.getHtmlViewerPanel().getURL()); } public void homeURLHasChanged(HtmlViewerPanelListenerEvent evt) { // Nothing to do. } }); }
From source file:nl.softwaredesign.exporter.ODTExportFormat.java
/** * TODO Move to utility class?// w ww.java2 s . c o m * Extract the content data (bytes) from the given image. * @param icon image to get bytes for * @param format desired format for image * @param background Color to use as background if transparency in image * @param width Desired width of the image in the byte array * @param height Desired width of the image in the byte array * @return the bytes of the image * @throws IOException */ private byte[] imageToBytes(ImageIcon icon, String format, Color background, int width, int height) throws IOException { Iterator writers = ImageIO.getImageWritersByFormatName(format); ImageWriter writer = (ImageWriter) writers.next(); ByteArrayOutputStream output = new ByteArrayOutputStream(); ImageOutputStream ios = ImageIO.createImageOutputStream(output); writer.setOutput(ios); BufferedImage img; if ("png".equalsIgnoreCase(format) || "gif".equalsIgnoreCase(format)) { img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); } else { img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); } WaitingObserver observer = new WaitingObserver(); if (!img.getGraphics().drawImage(icon.getImage(), 0, 0, width, height, background, observer)) { try { observer.waitForDone(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return new byte[0]; } } IIOMetadata metadata = writer.getDefaultImageMetadata(new ImageTypeSpecifier(img), writer.getDefaultWriteParam()); if (format.equalsIgnoreCase("jpg")) { Element tree = (Element) metadata.getAsTree("javax_imageio_jpeg_image_1.0"); Element jfif = (Element) tree.getElementsByTagName("app0JFIF").item(0); jfif.setAttribute("Xdensity", Integer.toString(72)); jfif.setAttribute("Ydensity", Integer.toString(72)); jfif.setAttribute("resUnits", "1"); metadata.setFromTree("javax_imageio_jpeg_image_1.0", tree); } else { double dotsPerMilli = 7.2 / 2.54; IIOMetadataNode horiz = new IIOMetadataNode("HorizontalPixelSize"); horiz.setAttribute("value", Double.toString(dotsPerMilli)); IIOMetadataNode vert = new IIOMetadataNode("VerticalPixelSize"); vert.setAttribute("value", Double.toString(dotsPerMilli)); IIOMetadataNode dim = new IIOMetadataNode("Dimension"); dim.appendChild(horiz); dim.appendChild(vert); IIOMetadataNode root = new IIOMetadataNode("javax_imageio_1.0"); root.appendChild(dim); metadata.mergeTree("javax_imageio_1.0", root); } writer.write(null, new IIOImage(img, null, metadata), null); return output.toByteArray(); }
From source file:openlr.mapviewer.gui.MapViewerGui.java
/** * Creates a new map viewer gui and initializes all components. * * @param mapHolder/*from w w w . j a va 2s .com*/ * the map holder * @throws MapViewerException * If an error occurs when setting up the parameters for the UI * elements */ public MapViewerGui(final MapsHolder mapHolder) throws MapViewerException { // 1. add Menubar FileChooserFactory fcf = new DirectoryRememberingFileChooserFactory(); CodingPropertiesHolder codingPropertiesHolder = createCodingPropertiesHolder(); setJMenuBar(new MapViewerMenuBar(this, codingPropertiesHolder, fcf)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("OpenLR - Map Viewer"); setSize(WIDTH, HEIGHT); StatusBar statusBar = new StatusBar(); LocationPanel locPanel = new LocationPanel(mapHolder, codingPropertiesHolder); locPanel.setFileChooserFactory(fcf); // trigger the shutdown manager when the application window is closed addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { ShutDownManager.getInstance().statShutDown(); } }); // 2. add Toolbar ToolBar toolBar = new ToolBar(mapHolder, locPanel, fcf, statusBar); prepareMouseListener(mapHolder, statusBar); JPanel panel = new JPanel(new MigLayout("insets 0", "[][grow]", "[][grow][grow][]")); panel.add(toolBar, "north, span"); // +++++ 1. ADD locationPanel TO PANEL ++++++ panel.add(locPanel, "grow"); // add map panels JPanel mapsPanel = new MapPanelsHolder(mapHolder); mapsPanel.setSize(WIDTH, HEIGHT); panel.add(mapsPanel, "grow, wrap, span 1 3"); LocationReferencePanel esp = new LocationReferencePanel(mapHolder, statusBar, codingPropertiesHolder); esp.setFileChooserFactory(fcf); // +++++ 3. ADD LocationReferencePanel TO PANEL ++++++ panel.add(esp, "growx"); panel.add(statusBar, "south, span"); getContentPane().add(panel); if (ICON_URL != null) { ImageIcon im = new ImageIcon(ICON_URL); setIconImage(im.getImage()); } setLocationRelativeTo(null); }
From source file:org.apache.cocoon.reading.ImageReader.java
protected void processStream(InputStream inputStream) throws IOException, ProcessingException { if (hasTransform()) { if (getLogger().isDebugEnabled()) { getLogger().debug("image " + ((width == 0) ? "?" : Integer.toString(width)) + "x" + ((height == 0) ? "?" : Integer.toString(height)) + " expires: " + expires); }/*from w w w. j av a 2s . co m*/ /* * NOTE (SM): * Due to Bug Id 4502892 (which is found in *all* JVM implementations from * 1.2.x and 1.3.x on all OS!), we must buffer the JPEG generation to avoid * that connection resetting by the peer (user pressing the stop button, * for example) crashes the entire JVM (yes, dude, the bug is *that* nasty * since it happens in JPEG routines which are native!) * I'm perfectly aware of the huge memory problems that this causes (almost * doubling memory consuption for each image and making the GC work twice * as hard) but it's *far* better than restarting the JVM every 2 minutes * (since this is the average experience for image-intensive web application * such as an image gallery). * Please, go to the <a href="http://developer.java.sun.com/developer/bugParade/bugs/4502892.html">Sun Developers Connection</a> * and vote this BUG as the one you would like fixed sooner rather than * later and all this hack will automagically go away. * Many deep thanks to Michael Hartle <mhartle@hartle-klug.com> for tracking * this down and suggesting the workaround. * * UPDATE (SM): * This appears to be fixed on JDK 1.4 */ try { byte content[] = readFully(inputStream); ImageIcon icon = new ImageIcon(content); BufferedImage original = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB); BufferedImage currentImage = original; currentImage.getGraphics().drawImage(icon.getImage(), 0, 0, null); if (width > 0 || height > 0) { double ow = icon.getImage().getWidth(null); double oh = icon.getImage().getHeight(null); if (usePercent) { if (width > 0) { width = Math.round((int) (ow * width) / 100); } if (height > 0) { height = Math.round((int) (oh * height) / 100); } } AffineTransformOp filter = new AffineTransformOp(getTransform(ow, oh, width, height), AffineTransformOp.TYPE_BILINEAR); WritableRaster scaledRaster = filter.createCompatibleDestRaster(currentImage.getRaster()); filter.filter(currentImage.getRaster(), scaledRaster); currentImage = new BufferedImage(original.getColorModel(), scaledRaster, true, null); } if (null != grayscaleFilter) { grayscaleFilter.filter(currentImage, currentImage); } if (null != colorFilter) { colorFilter.filter(currentImage, currentImage); } // JVM Bug handling if (JVMBugFixed) { JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); JPEGEncodeParam p = encoder.getDefaultJPEGEncodeParam(currentImage); p.setQuality(this.quality[0], true); encoder.setJPEGEncodeParam(p); encoder.encode(currentImage); } else { ByteArrayOutputStream bstream = new ByteArrayOutputStream(); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bstream); JPEGEncodeParam p = encoder.getDefaultJPEGEncodeParam(currentImage); p.setQuality(this.quality[0], true); encoder.setJPEGEncodeParam(p); encoder.encode(currentImage); out.write(bstream.toByteArray()); } out.flush(); } catch (ImageFormatException e) { throw new ProcessingException( "Error reading the image. " + "Note that only JPEG images are currently supported."); } finally { // Bugzilla Bug 25069, close inputStream in finally block // this will close inputStream even if processStream throws // an exception inputStream.close(); } } else { // only read the resource - no modifications requested if (getLogger().isDebugEnabled()) { getLogger().debug("passing original resource"); } super.processStream(inputStream); } }
From source file:org.apache.cocoon.reading.RepoImageReader.java
/** * @return the time the read source was last modified or 0 if it is not * possible to detect//from w w w. j a v a2 s . c om */ /* public long getLastModified() { if (hasRanges()) { // This is a byte range request so we can't use the cache, return null. return 0; } if (quickTest) { return inputSource.getLastModified(); } final String systemId = (String) documents.get(request.getRequestURI()); // Note: getURI() might be null in some incomplete implementations final String sourceURI = inputSource.getURI(); if (systemId == null || (sourceURI != null && sourceURI.equals(systemId))) { return inputSource.getLastModified(); } documents.remove(request.getRequestURI()); return 0; }*/ protected void processStream(InputStream inputStream) throws IOException, ProcessingException { if (inputStream != null) { if (hasTransform()) { if (getLogger().isDebugEnabled()) { getLogger().debug("image " + ((width == 0) ? "?" : Integer.toString(width)) + "x" + ((height == 0) ? "?" : Integer.toString(height)) + " expires: " + expires); } try { byte content[] = readFully(inputStream); ImageIcon icon = new ImageIcon(content); BufferedImage original = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB); BufferedImage currentImage = original; currentImage.getGraphics().drawImage(icon.getImage(), 0, 0, null); if (width > 0 || height > 0) { double ow = icon.getImage().getWidth(null); double oh = icon.getImage().getHeight(null); if (usePercent) { if (width > 0) { width = Math.round((int) (ow * width) / 100); } if (height > 0) { height = Math.round((int) (oh * height) / 100); } } AffineTransformOp filter = new AffineTransformOp(getTransform(ow, oh, width, height), AffineTransformOp.TYPE_BILINEAR); WritableRaster scaledRaster = filter.createCompatibleDestRaster(currentImage.getRaster()); filter.filter(currentImage.getRaster(), scaledRaster); currentImage = new BufferedImage(original.getColorModel(), scaledRaster, true, null); } JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); JPEGEncodeParam p = encoder.getDefaultJPEGEncodeParam(currentImage); p.setQuality(this.quality[0], true); encoder.setJPEGEncodeParam(p); encoder.encode(currentImage); out.flush(); } catch (ImageFormatException e) { throw new ProcessingException( "Error reading the image. " + "Note that only JPEG images are currently supported."); } finally { // Bugzilla Bug 25069, close inputStream in finally block // this will close inputStream even if processStream throws // an exception inputStream.close(); } } else { try { InputStream is = inputStream; long expires = parameters.getParameterAsInteger("expires", -1); if (expires > 0) { response.setDateHeader("Expires", System.currentTimeMillis() + expires); } response.setHeader("Accept-Ranges", "bytes"); byte[] buffer = new byte[8192]; int length; while ((length = is.read(buffer)) > -1) { out.write(buffer, 0, length); } is.close(); out.flush(); } catch (RuntimeException e) { throw e; } finally { // Bugzilla Bug 25069, close inputStream in finally block // this will close inputStream even if processStream throws // an exception inputStream.close(); } } } else { throw new IOException("Deals: Problem, resource not found or Repository not working correctly"); } }
From source file:org.ayound.js.debug.ui.DebugMainFrame.java
public DebugMainFrame() throws HeadlessException { super(Messages.getString("DebugMainFrame.ApplicationName")); //$NON-NLS-1$ initAction();//from w w w.j a va2s . com BorderLayout layout = new BorderLayout(); this.setLayout(layout); JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); initToolBar(); setSize(800, 600); ImageIcon jsIcon = new ImageIcon(DebugMainFrame.class.getResource("icons/js.png")); //$NON-NLS-1$ setIconImage(jsIcon.getImage()); setExtendedState(JFrame.MAXIMIZED_BOTH); initMainLayout(); setVisible(true); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); initListener(); initReadMe(); }
From source file:org.cagrid.installer.Installer.java
public void run() { ImageIcon myImage = new ImageIcon( Thread.currentThread().getContextClassLoader().getResource("images/caGrid_small.png")); Wizard wizard = new Wizard(this.model); wizard.showInFrame("caGrid " + model.getProperty("cagrid.version") + " Installation Wizard", myImage.getImage()); }