Problem in displaying  gif image on to the JFrame

i added gif image in to the jframe but when i run that image the image get distorted very much.

public class MyFrame extends JFrame
     private static final String sIMAGE_PATH = "My\\Path\\To\\Image\\fileName.gif";
     public MyFrame()
          super("Frame with image on it");
          init();
     private void init()
          JPanel panel = new JPanel(new BorderLayout());
          ImageIcon image = new ImageIcon(sIMAGE_PATH);
          JLabel label = new JLabel(image);
          panel.add(label, BorderLayout.CENTER);
          this.setContentPane(panel);
     }Hope this helps..

Similar Messages

  • Problem with displaying BLOB images on JSP page using a servlet

    hi. I have a big problem with displaying BLOB images using JSP. I have a servlet that connects to the oracle database, gets a BLOB image , reads it, and then displays it using a BinaryStream. The problem is , this works only when i directly call that servlet, that is http://localhost:8080/ImageServlet. It doesn't work when i try to use that servlet to display my image on my JSP page (my JSP page displays only a broken-image icon ) I tried several coding approaches with my servlet (used both Blob and BLOB objects), and they work just fine as long as i display images explicitly using only the servlet.
    Here's what i use : ORACLE 10g XE , Eclipse 3.1.2, Tomcat 5.5.16 , JDK 1.5
    here is one of my image servlet's working versions (the essential part of it) :
                   BLOB blob=null;
              rset=st.executeQuery("SELECT * FROM IMAGES WHERE ID=1");
              while (rset.next())
                   blob=((OracleResultSet)rset).getBLOB(2);
              response.reset();
              response.setContentType("image/jpeg");
              response.addHeader("Content-Disposition","filename=42.jpeg");
                    ServletOutputStream ostr=response.getOutputStream();
                   InputStream istr=blob.getBinaryStream(1L);
                    int size=blob.getBufferSize();
              int len=-1;
                    byte[] buff = new byte[size];
                         while ((len=istr.read( buff ))!=-1 ) {
                   ostr.write(buff,0,len);
             response.flushBuffer();
             ostr.close(); and my JSP page code :
    <img src="/ImageServlet" border="0"  > If you could just tell me what i'm doing wrong here , or if you could show me your own solutions to that problem , i would be very greatful ,cos i'm realy stuck here , and i'm rather pressed for time too. Hope someone can help.

    I turns out that it wasn't that big of a problem after all. All i had to do was to take the above code and place it into another JSP page instead of into a servlet like i did before. Then i just used that page as a source for my IMG tag in my first JSP. It works perfectly well. Why this doesn't work for servlets i still don't know, but it's not a problem form me anymore . Ofcourse if someone knows the answer , go ahead and write. I would still appriceatte it.
    here's the magic tag : <img src="ImageJSP.jsp" border="0"  > enjoy : )

  • Problem Saving Gererating GIF Image

    Hello, we are having a problem in production environment when try to right mouse and select Print on an mii grid. Works just fine in all of our non-production environments. Checked the System Security pull downs and they all matched non-prod. Was not sure which one to compare, was not a ImageStorageServlet on pull down menu.
    After right mouse and select Print on grid, get:
    -Java Applet Window popup message - Problem Saving Gererating GIF Image
    -Then - blank browser page - .../XMII/ImageStorageServlet/View/null
    - Non-production servers works fine produces grid on browser page - XMII/ImageStorageServlet/View/2084280301
    NetWeaver Log:
    Location - com.sap.xmii.servlet.ImageStorageServlet
    Full Message Text
    ImageStorage - Error saving GIF file 
    Full Message Text
    ImageStorage - Error generating GIF output
    Any help would be appreciated.
    Thanks

    David,
    Have you put in a support ticket for this? I recommend doing so since its occurring in your production environment. You should also attach your log files as well.
    Regards,
    Kevin

  • Mail and Safari dont display GIF images

    After about a weeks worth of use, I realized that Safari and Mail dont display GIF images unless I download them and open them in Preview. Even then, I have to manually click each image to see the pictures motion. Sometimes in stead of the question mark, I will get the first picture of the sequence, but none more. Does anyone know how to fix this?

    i dont have a solution, i just said it because i was tired of seeing it unanswered. Sorry, STILL haven't fixed this

  • Problem with display an image on JFrame in Java 6

    I'm trying to display an image on JFrame in this way:
    1.) I'm creating a variable in the class:
        private Image imgSpeaker = null;2.) I'm overiting the paint method:
    public void paint(Graphics g) {
            super.paint(g);   
            g.drawImage(imgSpeaker, 330, 230, null);  
        }3.) In the constructor I'm using this code:
       imgSpeaker = Toolkit.getDefaultToolkit().getImage("D:\\speaker.gif");
            MediaTracker trop = new MediaTracker(this);
            trop.addImage(imgSpeaker,0);
            try {
                trop.waitForID(0);    // waiting untill downloading progress will be complite
            } catch (Exception e) {
                System.err.println(e);
            }        The Image will be displayed on form, but if I catch the window and move it (for example: down as possible)
    the image is not refreshed (repainted). What I'm doing wrong? I've been used this solution in Java 5 and everything
    works perfectly. Any of described methods aren't depricated... Anyone can help me?

    Thanks for your code, I've been tryed to apply your solution (with create a Buffered Image), but it still not working correctly. Firstly, the image isn't loading, and secondly the basic problem is not give in. Why have you been using "bg2d.draw(img, x, y, w, h, frame);" not in the paint method?
    I'm use "Free Design" layout. Below I put on completly code from Netbeans.
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.MediaTracker;
    import java.awt.image.BufferedImage;
    public class ImageTest extends javax.swing.JFrame {
        private Image imgSpeaker = null;
        private BufferedImage bi = null;
        private MediaTracker trop = null;
        public ImageTest() { 
                initComponents();
                trop = new java.awt.MediaTracker(this);
                imgSpeaker = java.awt.Toolkit.getDefaultToolkit().getImage("D:\\speaker.gif");
                try {
                    trop.addImage(imgSpeaker, 0);
                    trop.waitForID(0);
                } catch (java.lang.Exception e) {
                    java.lang.System.err.println(e);
                bi = new java.awt.image.BufferedImage(100, 100, java.awt.image.BufferedImage.TYPE_INT_RGB);
                java.awt.Graphics2D bg2d = (java.awt.Graphics2D) bi.createGraphics();
                trop.addImage(bi, 1);
    //            java.io.File f = new java.io.File("D:\\speaker.gif");
    //            try {
    //                bi = javax.imageio.ImageIO.read(f);
    //            } catch (IOException e) {
    //               java.lang.System.err.println(e);
        public void paint(Graphics g) {
    //      super.paint(g);
           try {                                                   
                trop.waitForAll();                                 
            } catch (Exception e) {
                System.err.println(e);
            g.drawImage(bi, 50, 100, imgSpeaker.getHeight(this), imgSpeaker.getHeight(this), this);
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
        private void initComponents() {
            jButton1 = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jButton1.setText("jButton1");
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(283, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(44, 44, 44))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(252, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(25, 25, 25))
            pack();
        }// </editor-fold>
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new ImageTest().setVisible(true);
        private javax.swing.JButton jButton1;
    }

  • Safari on iPad does not display GIF image anymore after upgrade to iOS 4.3

    1) Could anybody (especially those in Apple iOS or Safari teams) advise me why the Safari on my iPad cannot display some images (probably in GIF formats) on some webpages anymore, after I upgrade my iPad to iOS 4.3? These images on the webpages can be properly displayed on when my IPad runs with iOS 4.2.1. There should be no problem with these embedded image files because they can still be properly display in Safari running on my Macbook air.
    2) Is there any solution to this problem?
    3) Is it possible to downgrade my iPad back to iOS 4.2.1?

    I am having the same issue with two different ipads (one Wifi and one Wifi-3g) running on our home network (Verizon FIOS). The website in question is www.tvwc.com and the main logo in the upper left corner, a .gif, does not display, only a "?". Other images on the site, in .jpg format, display correctly.
    I was running 4.2.1 and am now just upgrading to 4.3.

  • Why can't Firefox 23 display GIF images crisply?

    If I drag a 9x9 2-color GIF into Firefox 23.0 it displays blurry/stretched. If I view the same image file in Chrome or even IE it displays at a crisp, pixel-perfect 9x9. The blurriness in FF is new since I updated. What's wrong? Known bug?
    Not that it is relevant here, but let me confirm that this test was with a raw image file, not scaled...and my screen zoom is at 100%.
    ( For an online example, here... http://joelncocker.com/ ...you can see my unscaled 9x9 logo GIF at the bottom right. )

    If the screen height is too low (less than 900px) then the footer is covered by the background image, so I didn't spot this image initially. The same happens if I zoom the page.
    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Note that such issues can be caused by HiDPI support in current Firefox versions on Windows.
    Code changes regarding HiDPI support for high resolution displays have landed in Firefox 22 and later (bug #844604).
    *https://support.mozilla.org/kb/forum-response-Zoom-feature-on-Firefox-22
    *http://kb.mozillazine.org/about:config
    You can set the layout.css.devPixelsPerPx pref on the <b>about:config</b> page to 1.0 (current default value is -1.0) to restore the behavior of previous Firefox versions.
    If necessary adjust layout.css.devPixelsPerPx starting with 1.0 in 0.1 or 0.05 steps (1.0 or 0.9) to make icons show correctly.<br />
    Use an extension to adjust the text size in the user interface and the page zoom in the browser window.
    Use this extension to adjust the font size for the user interface.
    *Theme Font & Size Changer: https://addons.mozilla.org/firefox/addon/theme-font-size-changer/
    You can look at the Default FullZoom Level or NoScript extension if web pages need to be adjusted after changing the layout.css.devPixelsPerPx pref.
    *Default FullZoom Level: https://addons.mozilla.org/firefox/addon/default-fullzoom-level/
    *NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/
    *https://support.mozilla.org/kb/forum-response-Zoom-feature-on-Firefox-22

  • Found and resolved a problem when transferring GIF images thru iCloud

    I had problems getting GIF images to upload to iCloud on Windows Vista.
    After several failed attempts to upload a GIF image from the UPLOADS folder, I renamed the image using PAINT to a JPG image and the transfer occrued immediately.
    Apparently the upload feature in Photstream does not work with GIF images.
    Anyone out there experiencing a similar kind of problem?

    It's like looking for a needle in a haystack. What the following line does is replace the literal string "name" with $username_$number:
    $newname = str_replace  ('name', "$username_$number", $name);
    Is the literal string "name" in the name of the uploaded files?
    The way to debug this type of thing is to use echo at various stages to display what certain variables contain:
    echo '$name is: ' . $name . '<br />';
    By exposing the values stored in variables at different stages of a script, you can tell if it's working the way you expected.

  • I am trying to set up virtual servers with Netscape Enterprise Server 3.6. Can get home page to display but images linked to the page won't display and links to other pages won't work.

     

    hi,
    If your home page of the virtual server is displayed then,you have set the virtual server properly.
    check the links and source of the images or directories in the HTML source code of the home page.
    this should solve ur problem. If not notify me.
    Regards
    T.Raghulan.
    [email protected]

  • Problem of displaying JPEG images

    I just got my new Power Mac G5 computer. I am Also new to the MAC world. I put in a CD, which is filled with all JPEG files, into my DVD drive. From the desktop, I double click the CD icon; no problem, I saw all the JPEG files. I then tried to view the images by double clicking them; however, some of them were display successfully thru Preview and some were not. For the images, which had trouble to be displayed, had error message saying the files were not recognizable or data were corrupted.
    I also tried to drag the file from CD folder to iPhoto icon, I got the same error message (not recognizable or data corrupted).
    I had no trouble in viewing all these images from Windows 2000. I have no idea what's wrong.
    Please help, thanks!
    Howard
    Power Mac G5   Mac OS X (10.4.2)  

    Hi Howard,
    Drag all the images to the desktop first. Now open iPhoto and drag the images into an open iPhoto viewing window (library view)
    If you put the images in folders to organize them, then each folder dragged into an open iPhoto window will be imported as a roll with the folders name.
    Lori

  • Import and Display GIF images

    Hi,
    I'm trying to manage images in Abap program.
    Reading on this forum, I'm able to import BMP e TIFF files (via SE78) and display them into a customer control.
    Now I'm trying to manage also GIF images.
    I'm using tc SMW0 to import gif images but with no result.
    This is what I done:
    1. call SMW0
    2. select BINARY DATA
    3. Run (no parameters specified)
    4. New button
    5. Import the GIF file.
    The system display the "No MIME type assigned to object D:\logo.gif" and no images is added.
    What I have to do?
    Thanks
    Salvatore

    Hi Salvatore,
      To display the images in Container you need to
      maintain tem in Business documnets.
      Follow the below steps :
    1) Goto tcode OAER.
    2) Give class name, as type 'OT' and Key name.
    3) Execute it and here you create document and select
       screen in the Document types then upload the bmp or
       gif file and save it.
    4) After that use this in when displaying in Container.
    Thanks&Regards,
    Siri.
    Kindly award points if it is useful.
    Message was edited by: Srilatha T

  • Problem with display of images in applets

    Hi all,
    When I run this program, the appletviewer window is showing no output (i.e. no image). I'm using the netbeans IDE 5.0.
    Blue hills.jpg is present in both the src folder and build folder.
    * <applet code="image" width =800 height=600>
    * <param name="img" value="Blue hills.jpg">
    * <\applet>
    import java.awt.*;
    import java.applet.*;
    public class image extends Applet {
    Image img;
    public void init() {
    img=getImage(getDocumentBase(), getParameter("img"));
    public void paint(Graphics g){
    g.drawImage(img,0,0,this);
    Please help in figuring out the problem....

    It will be looking for it in the folder with the HTML that invokes the applet.
    If you want to pack the image in with the applet then use getResource instead.
    And spaces in the name are probably not the best idea.

  • Problem in displaying selected page items in the title in Graph

    Hi There;
    I have a problem in displaying selected value of named page item in the graphs.
    Eg. I have in my worksheet a page item named "Location"; when I use "&WorksheetName &Location" in the title of worksheet it is displaying both the worksheet title and value of selected page item "Location" in my example.
    But when I use the same (&WorksheetName &Location) in the title of graph or Axis of the graph, it would show up only the name of the worksheet but not the value of page item "Location", instead it would print "&Location"
    Any idea why it is not able to reference the select page item in Discoverer graph? I am using Oracle BI Discoverer 10.1.2.1.
    Thanks in Advance,
    Regards,
    Nidhi Jethoo

    Hi Michael;
    Thanks a lot. It might not have been considered necessary but you do require, e.g in my case I am plotting Average value of a Parameter and it does make sense in including the name/value of Parameter(surface water temp/bottom watter temp) as an Axis instead of just a constant Parameter or say Average Parameter. So that user can plot the variation of different parameters by changing the page items and when user changes the value of parameter and export the graph he/she has the parameter name(actual value) in the graph.
    But I can include all the parameters (&Parameters) or all the page items(using &PageItems) in graph then why not individual page-item and individual parameter.
    I would log a SR and see what they say.
    Thanks again,
    Nidhi

  • Displaying .jpg images stored in the database

    I created a table and a form to store .jpg images then display the .jpg files in a dynamic page.
    I can insert the images and display the dynamic page but selecting the HREF link will not dispaly the .jpg file.
    I used the Metalink DocID: Note:68016.1 Subject:Browsing database image objects to create the package.
    The package code is as follows
    Create or Replace PACKAGE OREF.IMG
    as
    PROCEDURE select_img_table;
    PROCEDURE retrieve_img_data(img_id varchar2);
    end;
    Create or Replace PACKAGE BODY OREF.IMG
    AS
    PROCEDURE select_img_table AS
    CURSOR c1 IS SELECT id, name FROM filestore;
    BEGIN
    htp.bodyopen;
    FOR i IN c1 LOOP
    htp.print(TO_CHAR(i.id));
    htp.print(i.name);
    htp.anchor('../../pls/oref/IMG.retrieve_img_data?img_id='||to_char(i.id),'jpg',null,null);
    htp.br;
    htp.bodyclose;
    END LOOP;
    END select_img_table;
    PROCEDURE retrieve_img_data(img_id varchar2) AS
    Lob_field BLOB;
    buffer RAW(32767);
    offset BINARY_INTEGER:=1;
    buffer_size NUMBER:=32767;
    BEGIN
    SELECT object INTO lob_field FROM filestore WHERE id=img_id;
    OWA_UTIL.MIME_HEADER('image/jpg');
    LOOP
    DBMS_LOB.READ(lob_field,buffer_size,offset,buffer);
    htp.prn(UTL_RAW.CAST_TO_VARCHAR2(buffer));
    offset:=offset+buffer_size;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    null;
    END retrieve_img_data;
    END img;
    *The dynamic page Code is as follows:
    <HTML>
    <HEAD>
    <TITLE>Display Filestore Table</TITLE>
    </HEAD>
    <BODY>
    <H2>Display of .jpg files in the Filestore Table</H2>
    <ORACLE>select id, ''||name||''
    from oref.filestore</ORACLE>
    </BODY>
    </HTML>

    You'll need to provide a full URL link to the image ("http://mywebserver/file/images_personnel/28.jpg"), not just a relative path.  Remember, the email client that is used to view the email content knows nothing of the internals of your web server - it can only follow a complete URL to get images and other resources.
    -Carl V.

  • How to display an image located in the WEB-INF directory?

    Basically, When a user registers, they a directory is created with their username that holds images that they can upload. How do I display those images. All I am holding in the database is the location of the images.
    ive tried
    <img src="/WEB-INF/users/testuser/picture.jpg" />
    but this doesnt work and for obvious security reasons shouldnt.. but is there another way of doing what i want to do? perhaps a custom tag? thanks
    Jazz

    You would have to write a generic servlet that would return an image
    <img src="/getImage?user=testuser&pic=picture.jpg" />Your servlet would basically fetch the file from under web-inf, and then stream it back to the user.
    Methods to use:
    servletContext.getRealPath() (to help find the file on disk), relative to your web app
    getOutputStream (as opposed to getWriter)
    It is only in this way that you can access files on the server outside of the public web directories.
    Hope this helps
    Cheers,
    evnafets

Maybe you are looking for