Display image in JPanel without saving any file to disk

Hi,
I am fetching images from database. I am saving this image, display in JPanel and delete it. But this is not actually I want.
I wish to fetch this image as stream , store in memory and display in JPanel without saving any fiel in disk.
I wonder if it is Possible or any used implementation that I can use in my project. Any idea or experienced knowledge is enough.
Thanks

In what format is the image coming to you from the database? If it's an InputStream subclass, just use javax.imageio.ImageIO:
InputStream in = getImageInputStream();
BufferedImage image = null;
try {
   image = ImageIO.read(in);
} finally {
   in.close();
// ... Display image in your JPanel as you have beenIf you receive the image as an array of bytes, use the same method as above, but with a ByteArrayInputStream:
byte[] imageData = getImageData();
ByteArrayInputStream in = new ByteArrayInputStream(imageData);
BufferedImage image = null;
try {
   image = ImageIO.read(in);
} finally {
   in.close();
// ... Display image in your JPanel as you have been

Similar Messages

  • Ctrl+E to open in CS2 without saving a file on disk?

    Is there a way to Ctrl+E to open DNG as a PSD on CS2 WITHOUT having it automatically save a psd file on my hard drive?

    Damian, no "flame" taken lol
    I totally agree ... yes, having CS2 files in LR is great ... but not on every file I go to CS2 I need to save ... there are (sad to say) 100's of files I might do something "quickly" to in CS2 and save as a JPG ... that I totally do not want to save the PSD file. and I don't want to have to go back and have to look for and delete them.
    So, chances are those ... "snap shots" ... I can quickly duplicate what I did with the DNG anytime ... which is probably mostly there.
    Example ... a picture of a Women/Girl ... the image in LR is good to go .. but, because "they" want all flaws gone ... I have to run the "snap shot" thru my Plug-in.
    * also doing multiple copys for a HDR stack ... I want LR to send it to CS2 ... but I only want 1 copy of the PSD file to be in LR. (because I will have to delete the others)
    imho,
    * It's all about "choice" , and I could do this in ACR / CS2. ... yes, there are many DNG's I will want to have a PSD file generated and listed in LR automatically. But, I want to be able to choose which one's ... because this will save me time.
    p.s. I also do NOT like the way "Folders" are handled in LR.
    I don't want to see everything in the sub-folders on the TOP folder. It's confusing file management imho.
    If, I create a PSD file for a shoot ... I want it in a sub-folder PSD where all my PSD's will be. (not mixed in with my DNG's)
    imho, something powerful that gives choice ... on Ctrl+E on the pop up window you can CHOOSE to save ... and if you want it, in a Sub-folder ... which you can name. Like PSD (and if it already exists ... LR will put it there) ... now that's organized and powerful to me.

  • HT201077 Is there a way to delete files locally, on iPad, after they have been backed up in iCloud, without losing any files?

    Is there a way to delete files locally, on iPad, after they have been backed up in iCloud, without losing any files? Because iCloud is seeming like it actually doesn't back up anything.. Just clogs up all storage space on every device with duplicate images/videos. I am looking for a delete when backed up feature. Does that exist?

    quote:
    Originally posted by:
    Michael Hager
    The problem with any boxed software is that the developers
    can NEVER know how every possible customer will use the software.
    That's why, as a developer, they need to make
    the software have MANY more checkboxes in the options screen to
    allow the user to use the software the way they need to, not the
    way the developers THINK they will need to. Just look at Microsoft
    as a poor example of this--I am never so frustrated as when trying
    to use ANY of their Office products, which make easy tasks
    difficult and do not include some of the most common options that
    competing products have.
    quote:
    The Dreamweaver check out system actually works very well if
    it’s set up properly and administered strictly. If you set it
    up on your testing server with everyone set up on their work
    stations correctly it will tell you who has a file locked for
    editing. Once everyone is working as a team with good supervision
    and division of tasks under a strict policy set by management,
    Dreamweaver will work very well for your purposes. You
    shouldn’t have to lock and unlock files manually since the
    check in-check out function will do it for you nicely. When you are
    satisfied that all is well with the site or particular pages, then
    someone in a managing position can release or authorize release to
    the live site.
    The problem is that I am the only person using
    DW in the organization, everyone else is using Frontpage...blah...
    You and Murray have both alluded to a separate "testing"
    server. Perhaps I can make this system work by setting up the
    testing server as a duplicate of the development server in my site
    manager. Then I would have to manually publish the files from the
    testing server to the live production server myself. What a pain!!!
    I can not believe that I am the only person in the world that has a
    setup like this -- it seems very common to me. I would assume most
    government organizations are set up identically as us.
    <sigh>

  • Memory on my macbook air keeps disappearing.  I have 120 gigs and I am down to 150mb without adding any files.

    Memory on my macbook air keeps disappearing.  I have 120 gigs and I am down to 150mb without adding any files.

    Thanks...I have tried the various options and the only item of interest is that my only account on this computer says it has 102 gig of memory used up.  However, when I open and look at the individual files, they add up to less than 15 gigs.

  • How do you remove files from your start up disk without deleting any files?, How do you remove files from your start up disk without deleting any files?

    Hi,
    I was wondering if anyone knew how to remove files from the start up disk without deleting any files?
    I am unable to add any more photos and even download the latest updates because the start up disk is full....
    Is it possible to move the files off the start up disk without deleting them?
    I would appreciate feedback,
    Thanks
    Sammy

    Well you can move them to an external drive but this will delete them from the internal drive. Which is what you have to do to free up disk space.

  • Is data stored anywhere in the system without SAVEing the file manually

    Hello All,
    I need to know whether the data is saved anywhere even before I save the document manually ?
    If so, where can I find that temporarily saved data?
    Ex: While writing any WORD document, you can see the draft version of any file saved after 2 mins without save.
    Regards,
    Vijaya

    Hi, data is not stored in system without SAVEing the program.
    However, if you have pressed F8 ( executed the program without saving), then a message come REPS<reportname> temporarily saved (program gets buffered for temporary compilation) .
    If after this you close your session and try to open the report in new session, a popup would come giving you option of using saved version or temporary version.
    This is the closest SAP gets to MS WORD file crash recovery style.

  • Having trouble displaying image in JPanel

    I want to display an image in jpanel making it to scale to the size of the panel.
    And later i should be able to draw on that image , i am really new to all this , but i have to finish it soon.
    This is the code i am compiling and getting error
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class LocaterClient extends JFrame
         JPanel panel;
         public LocaterClient()
              super("LocaterClient");
              panel = new JPanel();
              panel.setSize(374,378);
              panel.setOpaque(false);
              panel.setVisible(true);
         getContentPane().add(panel);
         /*JFrame f = new JFrame();
         f.setSize(374,378);
         f.getContentPane().add(panel);*/
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              ImageIcon img = new ImageIcon("World_MER.jpg");
              ImageIcon fillImage = new ImageIcon(img.getImage().getScaledInstance
    (getWidth(), getHeight(),Image.SCALE_REPLICATE));
              g.drawImage(fillImage.getImage(), 0,0, this);
         public static void main(String args[])
              LocaterClient lc = new LocaterClient();
              lc.setDefaultCloseOperation( EXIT_ON_CLOSE );
              lc.pack();
              lc.setVisible(true);
    This is the error i am getting
    LocaterClient.java:24: cannot resolve symbol
    symbol : method paintComponent (java.awt.Graphics)
    location: class javax.swing.JFrame
    super.paintComponent(g);
    ^
    1 error
    If i remove super.paintComponent(g); line it compiles and runs but i get a tiny panel without the image.
    PLease help me , i am not evn sure is this is the procedure should i follow , because i should be able to draw on that image later on .
    Please provide me with some sample code.

    import javax.swing.*;
    import java.awt.*;
    public class ImagePainter extends JPanel{
      private Image img;
      public ImagePainter(){
        img = Toolkit.getDefaultToolkit().getImage("MyImage.gif");
      public void paintComponent(Graphics g){
        g.drawImage(img,0,0,getSize().width,getSize().height);
      public static void main(String[]args){
        JFrame frame = new JFrame();
        frame.getContentPane.add(new ImagePainter());
        frame.setSize(500,500);
        frame.show();

  • Navigate to next document without saving any changes in last document in AxWebBrowser

    Hi,
    I am opening MS Office Document file in AxWebBrowser after that i navigate to next Office Document ,before navigating i saved the last document like this
    AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_SAVE, SHDocVw.OLECMDF.OLECMDF_ENABLED)
    but how can i navigate to next Document without saving it if it also have any changes?
    if i do not use above line of code it ask for "Save","Don't Save" and "Cancel" before navigating to next document.
    help me thankx

    Hi,
    I am opening MS Office Document file in AxWebBrowser after that i navigate to next Office Document ,before navigating i saved the last document like this
    AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_SAVE, SHDocVw.OLECMDF.OLECMDF_ENABLED)
    but how can i navigate to next Document without saving it if it also have any changes?
    if i do not use above line of code it ask for "Save","Don't Save" and "Cancel" before navigating to next document.
    help me thankx
    Hello,
    In this case, we need to get the object for that document inside the NavigateComplete2 event.
    And then we could call its
    close method before we navigate to the other document.
    For get the document object we could refer to the sample shared in
    How to use the WebBrowser control in Visual Basic to open an Office document
    Public Class Form1
    Dim OpenFileDialog1 As OpenFileDialog = New OpenFileDialog()
    Dim oDocument As Object
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Dim strFileName As String
    'Find the Office document.
    With OpenFileDialog1
    .FileName = ""
    .ShowDialog()
    strFileName = .FileName
    End With
    'If the user does not cancel, open the document.
    If strFileName.Length Then
    oDocument = Nothing
    AxWebBrowser1.Navigate(strFileName)
    End If
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Button1.Text = "Browse"
    With OpenFileDialog1
    .Filter = "Office Documents " & _
    "(*.docx, *.xlsx, *.ppt)|*.docx;*.xlsx;*.ppt"
    .FilterIndex = 1
    End With
    End Sub
    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As _
    System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    oDocument = Nothing
    End Sub
    Private Sub AxWebBrowser1_NavigateComplete2(ByVal sender As Object, _
    ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) _
    Handles AxWebBrowser1.NavigateComplete2
    On Error Resume Next
    oDocument = e.pDisp.Document
    'Note: You can use the reference to the document object to
    ' automate the document server.
    MsgBox("File opened by: " & oDocument.Application.Name)
    End Sub
    End Class
    And for closing part, we could refer to
    How to: Programmatically Close Documents.
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • See PDF attachments without saving the file

    Until a couple of weeks ago, I click on the attachment and the Adobe program will open the file and after that I decided if want to save the file.
    Now, when I click on the attachment, I get the "Save file" screen.
    then I have to open Adobe and go to where the file was saved to see the attachment.
    How can I see an attachment without saving it?

    Have you checked Application setting for PDF in Firefox? See https://support.mozilla.com/en-US/kb/Managing%20file%20types
    Update your Java: [https://support.mozilla.com/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java]

  • Need to display image on JPanel

    Hello
    I am trying to implement a graphical version of the Knights Tour. I am done with the algorithm part of the problem itself. I am having problem with displaying the chess board. Although seemingly straightforward the images will not display on the JPanel. Below is a sample of what I am trying to do. Can anyone explain why the code does not work even though it seems okay. Thanks and best regards.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    public class test extends JFrame { 
    public test(){ 
    panel pane = new panel();
    getContentPane().add(pane);
    public static void main(String[]args){   
    test tst = new test();
    tst.setSize(500,500);
    tst.show();
    public class panel extends JPanel{   // inner class
    private Image img;
    private ImageIcon icon;
    public panel(){
    icon = new ImageIcon("cross.gif");
    img = icon.getImage();
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D)g;
    System.out.println("I am here");
    g.drawImage(img,40,40,this);
    }

    package com.lc.util.swing ;
    import java.awt.Color ;
    import java.awt.Graphics ;
    import java.awt.Image;
    import java.awt.Insets;
    import java.awt.Dimension ;
    import java.awt.image.ImageObserver ;
    import javax.swing.JPanel;
    import javax.swing.border.Border;
    * Panel displaying an {@link Image}.
    * <ul>
    * <li>8 positions,</li>
    * <li>
    * can stretch image for filling the whole available area, or diminish
    * its size if too large in width or height,
    * </li>
    * <li>respects borders (as defined by
    * {@link javax.swing.JComponent#setBorder( javax.swing.border.Border ) JComponent.setBorder}
    * </li>
    * </ul>
    * @author Laurent Caillette
    * @version $Revision: 1.1.1.1 $ $Date: 2002/02/19 22:12:04 $
    public class JImagePanel extends JPanel {
    public JImagePanel() {
    imageObserver = this ;
    * Constructeur assignant une image.
    public JImagePanel( Image image ) {
    this() ;
    setImage( image ) ;
    private Image image ;
    private ImageObserver imageObserver ;
    public void setImage( Image image ) {
    this.image = image ;
    adjustPreferredSize();
    public void setBorder( Border newBorder ) {
    super.setBorder( newBorder ) ;
    adjustPreferredSize() ;
    private void adjustPreferredSize() {
    if( image != null ) {
    int w = image.getWidth( imageObserver ) ;
    int h = image.getHeight( imageObserver ) ;
    Border border = getBorder() ;
    if( border != null ) {
    Insets insets = border.getBorderInsets( this ) ;
    if( insets != null ) {
    w += ( insets.left + insets.right ) ;
    h += ( insets.top + insets.bottom ) ;
    Dimension dim = new Dimension( w, h ) ;
    this.setPreferredSize( dim ) ;
    private int placement = CENTER ;
    public int getPlacement() { return placement ; }
    public void setPlacement( int placement ) {
    if( ( placement < CENTER ) || ( placement > STRETCH ) ) {
    throw new IllegalArgumentException( "Unsupported placement value" ) ;
    this.placement = placement ;
    public void paint( Graphics gr ) {
    // x of Image to draw
    int x ;
    // y of Image to draw
    int y ;
    // width of Image to draw
    int iw ;
    // height of Image to draw
    int ih ;
    // thickness of left border
    int bl = 0 ;
    // thickness of upper border
    int bt = 0 ;
    // thickness of right border
    int br = 0 ;
    // thickness of lower border
    int bb = 0 ;
    // width of drawable area
    int pw = this.getWidth() ;
    // height of drawable area
    int ph = this.getHeight() ;
    // Handle borders
    Insets insets = null ;
    Border border = getBorder() ;
    if( border != null ) {
    insets = getBorder().getBorderInsets( this ) ;
    if( insets != null ) {
    bl = insets.left ;
    br = insets.right ;
    bb = insets.bottom ;
    bt = insets.top ;
    pw = pw - bl - br ;
    ph = ph - bt - bb ;
    // Always display background, for supporting transparency.
    super.paint( gr ) ;
    if( image != null ) {
    iw = image.getWidth( imageObserver ) ;
    ih = image.getHeight( imageObserver ) ;
    if( ( placement == STRETCH ) ||
    ( iw > pw ) ||
    ( ih > ph )
    gr.drawImage(image, bl, bt, pw, ph, imageObserver ) ;
    } else {
    iw = image.getWidth( imageObserver ) ;
    ih = image.getHeight( imageObserver ) ;
    switch( placement ) {
    case CENTER :
    x = ( pw - iw ) / 2 ;
    y = ( ph - ih ) / 2 ;
    break ;
    case NORTH :
    x = ( pw - iw ) / 2 ;
    y = 0 ;
    break ;
    case NORTHEAST :
    x = pw - iw ;
    y = 0 ;
    break ;
    case EAST :
    x = pw - iw ;
    y = (ph - ih ) / 2 ;
    break ;
    case SOUTHEAST :
    x = pw - iw ;
    y = ph - ih ;
    break ;
    case SOUTH :
    x = ( pw - iw ) / 2 ;
    y = ph - ih ;
    break ;
    case SOUTHWEST :
    x = 0 ;
    y = ph - ih ;
    break ;
    case WEST :
    x = 0 ;
    y = ( ph - ih ) / 2 ;
    break ;
    case NORTHWEST :
    x = 0 ;
    y = 0 ;
    break ;
    default :
    throw new IllegalArgumentException(
    "Unsupported placement value" ) ;
    // Add border offset
    x += bl ;
    y += bt ;
    gr.drawImage( image, x, y, this ) ;
    public final static int CENTER = 0 ;
    public final static int NORTH = 1 ;
    public final static int NORTHEAST = 2 ;
    public final static int EAST = 3 ;
    public final static int SOUTHEAST = 4 ;
    public final static int SOUTH = 5 ;
    public final static int SOUTHWEST = 6 ;
    public final static int WEST = 7 ;
    public final static int NORTHWEST = 8 ;
    public final static int STRETCH = 9 ;

  • Display image using JPanel

    i have got buffered image from webcam using jmf. i want to display it on JPanel.
    i override paint() but it doesn't display as it captures
    when i maximize window it then displays
    urgent help needed

    The bounds of your JPanel may be incorrect. You should try the setBounds(int x, int y, int width, int height) method on it.
    Please past your code for more help :p

  • AE CC 2014 Export to C4D not saving any file

    I just got into CC (was using CS6) and today I wanted to export a C4D file from AE, like I have done always with AE CS6, but there seems to be a problem. I click on export, Maxon Cinema 4D Exporter, then select the folder and type the file name, click save and it closes like normal, but the file I supposedly saved, is not created anywhere. Anyone has the same issue?

    Apparently the problem is with the folder I was saving the file. I saved it to another hard drive and it saves the file just fine. Is there a limitation for a folder structure?
    Another issue is that the scene only includes the camera and not the solids or text layers. If I export from AE CS6 it includes all that.

  • Saving .ATT files to disk instead of emailing them?

    In using Captivate 5.5 for reporting quiz results, the Help PDF states under "Specify e-mail preferences":
    4.  Specify whether the CSV content must be sent in the body of the e-mail, or as an attachment. The CSV content can be sent as an attachment only over Internet Explorer. 
    Note: The CSV content is sent as an attachment with the .att extension. Rename the file to a .csv extension and open it in Microsoft Excel.
    We are using Kronos that needs the CSV output to a file system location, not sent as an email.
    Can you save .ATT files to disk instead of emailing them??
    Thank you.

    Hello jckrueger,
    It is unclear as to the type of disk you would like to save incoming faxes to, however you can send incoming faxes (or scanned documents) directly to email or a network folder with your imageCLASS D1370.
    Here are the steps for your reference to forward faxes to email or a file server:
    NOTE:  When a fax document is transferred to an email or a file server, the document is converted to a PDF file.
    Setting Document Transfer (Automatic Forwarding):
    This allows you to specify whether a document is automatically transferred during receiving and where to be transferred.
    NOTE:
    Destinations that can be specified:
    You can specify the followings as destinations.
    - Fax
    - E-mail (D1370 only)
    - File server (D1370 only)
    - Group destination
    1. Press (Menu).
    2. Select <System Settings> using [^] or [v] and press [OK].
    3. Select <Forwarding Settings> using [^] or [v] and press [OK].
    4. Select <Off> or <On> using [^] or [v] and press [OK].
    <On> Starts to transfer received documents. Next, you need to configure transfer destinations.
    <Off> Transfer is not performed.
    When <On> is selected:
    You can specify where to forward. You can specify only by the following approaches:
    "Specifying destinations using one-touch keys"
    "Specifying destinations using coded dial codes"
    "Specifying destinations using the address book"
    5. Press (Menu) to close the menu screen.
    If further assistance is needed or this does not address your inquiry, please feel free to Contact Us and we'll be glad to help you further.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • How to display a blob in a new window (without saving as file)

    Hi,
    I have been using the excellent as_pdf3 PLSql utility to create a pdf at run time. The result works great if I save the blob to file, however, I don't want to clutter up the "server", so I would like to send the blob down to the user by opening a new window (pdf reader) and then give the user the option to save where they wish.
    I am running Apex 4.1.1, Oracle 11GXE with Apex Listener under Glassfish opensource on Ubuntu Server 11.2.
    I've hunted left right and centre, and either I've not got the correct combination of words in the search, or the question has never been raised.
    Can anyone give me some pointers and/or code to assist ?

    I will try this when I get back home - travelling at the moment.
    A bit more background....... I have a Function that is called to produce a yearly calendar view of rentals for a home, along with the rental prices - this has already been written using the as_pdf3 package, which can either physically create the report on the server (using utl_file), or it can return the blob direct.
    On the screen, the user can select the years that they wish to see in the report, push a button which will pass the parameters into the above said function, and then launch the "blob" in another window (as the blob is PDF format, it would launch the users PDF reader) - if the user then wants to save the report, they can do (using PDF reader) - this avoids me a) saving and housekeeping a file(s) on the server, b) I don't have to enable utl_file for the schema

  • Problem displaying image in jpanel

    Hi,I have posted this on the applet board, but I think its also a general programming problem, so apologies if it isn't relevant to this board, just say so and I'll remove it!
    I've got an applet that receives a variable from a PHP page as a parameter. The variable is "map1.png" the map this variable refers to sits in the same folder as the applet.
    I want to use this variable along with getDocumentBase() to create a URL which will then be used to display an image within a jPanel called mapPane.
    the code I currently have is:
    // get image url
    String mapURL = getParameter("mapURL");
    //set variable for image
    Image map_png;
    // set media tracker
    MediaTracker mt;
    //initialise media tracker     
    mt = new MediaTracker(this);
    map_png = getImage(getDocumentBase(),mapURL);
    // tell the MediaTracker to kep an eye on this image, and give it ID 1;
    mt.addImage(map_png,1);
    // now tell the mediaTracker to stop the applet execution
    // until the images are fully loaded.
    try
    mt.waitForAll();
    catch (InterruptedException e) {}
    // draw image onto mapPane
    mapPane.getGraphics().drawImage(map_png, 200, 200, null);
    Currently the Parameter is being passed into the applet (i've written it out within the applet) but the image is not being displayed. Does anyone have any suggestions about what I'm doing wrong?
    Cheers
    Steve

    hi,
    No, don't get any exceptions, the Java Console has a message:
    <terminated>JavaImageEditor[Java Applet]C:\Program Files\Java\jre1.6.0\bin\javaw.exe
    Cheers
    Steve

Maybe you are looking for