Image is NULL exception, problems displaying a png file

Hi people,
I want to display a simple image using j2me on my siemens sl45i emu.
I'm using the following code to load my png 8x8(created with photoshop, 2bpp) image:
public void load()
try
testImage = Image.createImage("res/enemy1.png");
catch (Exception e)
System.err.print("Ladefehler: " + e);
when I want to display the image using the follwing code:
private void render(Graphics g)
g.drawImage(testImage,0,0,0);
g.drawString("**** you!", 0, 0, Graphics.TOP|Graphics.LEFT);
I'm getting the following exception:
java.lang.NullPointerException: Image is null.
Why do I get this exception when I want to display the image and not when I'm loading the image(something like "couldn't load image..." )....
I've placed enemy1.png in a folder called "res" in my jar file. Displaying text does work so I don't understand why I can't display an image...
Any help would be great!
Thanx in advance, alex

This can't be possible!
private void load()
     GameGraphics.getInstance().load();
     Player.getInstance().load();
I'm printing debug messages in both load()-methods and I'm getting an exception in the player class because gamegraphics didn't finish loading (I can see it from the debugging messages)

Similar Messages

  • Problem in using PNG files....

    Hi everybody...
    Whenever i use ImageIo.read(filename) function to read a PNG file....it returns a bufferedImage with Type = 0....
    and i cannot use this type of image to perform convolution operations....
    how can i solve this??....
    Another problem is that whenever i save it using the write method....the size of the new file is way too large than original image.
    ( ex - 250 kb(source image) - 1.5Mb(saved image))
    how can i solve this??
    plzz someone help me...
    itz urgent!!

    I'm making educated guesses here but I suspect you may be loading a palettised (ie <16M color) file and convolution probably requires true color - you can convert by creating a new image and rendering into it.
    As for writing out, you can adjust the write settings by tailoring the relevant ImageWriteParams... there should be plenty of info around if you Google.

  • Problem displaying an Excel File: Please Help

    Hello,
    I spent 3 hours this morning reading the forum on how to display an Excel file in the browser using JSP and I apologize in advance if the answer is in the forum.
    I cut and paste many examples: My goal is to display an excel file on the browser.
    Below is the code but the result is a disaster (please se after the code the result).
    My question is how can I display an excel file using the browser. What's wrong with my code. Apparently it worked for many people on the forum.
    Please help. I must do that by tomorrow and I had spent already so many hours.
    THANK YOU SO MUCH IN ADVANCE.
    So far the forum had helped me a lot.
    <%@ page language="java" import="java.io.*" %>
    <%
    String myfile = new String("/temp/temp.xls");
    File fileName = new File(myfile);
    // Setup our streams
    FileInputStream fis = null;
    ServletOutputStream out1 = response.getOutputStream();
    // Set content type and other response header
    response.setContentType(getServletContext().getMimeType(fileName.getName()));
    //response.setContentType("application/excel-document");
    //response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition","attachment; filename=\"" + fileName.getName());
    response.setContentLength((int) fileName.length());
    // Read in the file from the correct place and stream it to the user
    int iRead;
    FileInputStream stream = null;
    try
    stream = new FileInputStream(myfile);
    while ((iRead = stream.read()) != -1)
    out1.write(iRead);
    out1.flush();
    } catch (IOException i) {}
    %>
    RESULT:
    ������>�� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ���@����\p Yahel Malkin B�a�=���=��@�7 �������Oh��+'��0p08 P \h� Yahel Malkinn@�|�$�+�@�|�$�+�������.��+,��0�HP X`hp x ��� competitivePricingReportSave Worksheets���� ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Root Entry�������� �F��T�+�����Workbook������������SummaryInformation(����DocumentSummaryInformation8������������

    For those who are having the same problem than me here the solution:
    In fact I was only interested in saving the file
    <%@ page language="java" import="java.io.*" %>
    <%
    String myfile = new String("/temp/temp.csv");
    response.setContentType ("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "attachment; filename=\""+myfile+"\"");
    int iRead;
    // Setup our streams
    FileInputStream fis = null;
    ServletOutputStream out1 = response.getOutputStream();
    FileInputStream stream = null;
    try
    stream = new FileInputStream(myfile);
    while ((iRead = stream.read()) != -1) {
    out1.write(iRead);
    out1.flush();
    } catch (IOException i) {}
    %>

  • Problem with the PNG file icon

    Hello. This is the first time I'm posting something here, so please be merciful. :) Yesterday I saw that the file icons of the PNG files are not the blue ones (like we all know them, after installing Photoshop CS3), but the default Windows (I'm using Windows XP SP3) icons. I mean like when I don't have a program to open a given file, that is how it looks like. But when I double click on the PNG file it opens right away, so in my eyes there is a problem, of some kind, with the ICO file itself. The strangest thing is that this ICO file is not missing, deleted or moved! This happened only with the PNG files. All other Photoshop related files are ok and have their respective icons. Can someone tell me how to change the PNG file icon, so I can choose manually the ICO file.

    @roshlioto This is a windows issue NOT Photoshops. So wrong place on the Internet.
    However, you right click on the shortcut/icon whatever, (in Windows) and choose the icon/app you wish to associate with a given file.

  • Problem Displaying generated Markup File (CLOB column)

    Dear Colleague,
    I am attempting to display the results of a generated Markup File in a Forms Text Item. The code (Below) is in a WHEN-BUTTON-PRESSED trigger.
    Step 1: generates the markup file and stores it in the MARKUP_DOCUMENTS table.
    Step 2: Copies the clob column DOCUMENT to the clob variable MYCLOB
    --> At Step 2, my form crashes !!!
    Is Oracle Forms not able to process CLOBs? The form was compiled as if there was no problem.
    How can I access the results of the generated Markup File in the MARKUP_DOCUMENTS table and present it to the Oracle Forms user?
    Best regards,
    Randy
    declare
    myclob clob := empty_clob();
    read_amount number(4):= 500;
    read_offset number(4):= 1;
    buffer varchar2(500) ;
    begin
    -- Step 1:
    ctx_doc.markup(index_name => 'documents_index',
    textkey => to_char(:hitlist_block.id),
    text_query => :search_block.search_clause,
    restab => 'markup_documents',
    query_id => '1',
    plaintext => TRUE);
    -- Step 2:
    SELECT document
    INTO myclob
    FROM markup_documents
    WHERE query_id = 1;
    -- Step 3:
    dbms_lob.read(myclob, read_amount, read_offset, buffer);
    -- Step 4:
    :markup_block.markup_text := buffer;
    go_block ('markup_block');
    exception
    when others then
    message ('Document could not be displayed: '||dbms_error_text);
    end;

    Hello,
    This is what i use to display an HTML Forms Text Item:
    Declare
       lc$Texte  Varchar2(2000) ;
       lf$fic client_text_io.file_type ;
    Begin
       lf$fic := client_text_io.fopen('c:\test.htm', 'w');
       client_text_io.put_line( lf$fic, '<html>' ) ;
       client_text_io.put_line( lf$fic, '<script language="JavaScript">' ) ;
       client_text_io.put_line( lf$fic, 'parent.window.resizeTo(600,400);' ) ;
       client_text_io.put_line( lf$fic, '</script>' ) ;
       client_text_io.put_line( lf$fic, '<body>' ) ;
       client_text_io.put_line( lf$fic, '<FONT face="sans-serif" color=#1B62AB size=2>' ) ;
       client_text_io.put_line( lf$fic, replace( :MAILS.TEXTE, CHR(10), '<br>') ) ;
       client_text_io.put_line( lf$fic, '</body></html>' ) ;
       client_text_io.fclose( lf$fic ) ;
       client_host('cmd /C START "x" iexplore.exe c:\test.htm' ) ;
       client_host('del c:\test.htm' ) ;
    End;Francois

  • Problem - Photoshop Saving PNG files too large

    An issue has recently cropped up with Photoshop for me.
    Whenever I try to create a png-24 object using "Save for Web", in the program it will tell me that the file should be only around 1kb, it will end up in the folder 10-15kb, much more than I had intended.
    This has only started happening recently, and when I have asked co-workers to try and export the same psd files using the same method, the exported pngs are the correct 1kb sizes. So the problem is only with my copy of Photoshop.
    Currently I'm running Photoshop 10.0.1 on Windows XP Professional.
    Has anyone else come across this problem, or know how to fix it? I've tried deleting my Preference file, but that didn't correct the issue.

    Please describe the process in more detail (including OS etc.).
    Boilerplate-text:
    Are Photoshop and OS fully updated and have you performed the usual trouble-shooting routines (trashing prefs by keeping command-alt-shift/ctrl-alt-shift pressed while starting Photoshop after making sure all customized presets like Actions, Patterns, Brushes etc. have been saved and making a note of the Preferences you’ve changed, 3rd party plug-ins deactivation, system maintenance, cleaning caches, font validation, etc.)?

  • PNG files not displaying - is this a problem in BC / Flexslider2 issue slider too big

    Hi,
    I have uploaded a site dmrural.leapfrogdesign.com.au/index.html and I noticed my png files are not displaying.  Is there a problem with using png files on BC?
    Also I know this is not BC related but I would really appreciate if if someone could tell me how to reduce the size of my flexslider (i am using bootstrap 2.3.2) - it's my first site in bootstrap.
    Thanks,
    Tammy

    They work for me. For example I see the logo on the homepage
    http://dmrural.leapfrogdesign.com.au/img/logo.png
    As for the slider images size you can use something like this:
    .slides {
        max-width: 50%;

  • Issue displaying PNG file

    I seem to have an issue displaying "some" PNG files. I am using the source code from Brakeen's tile game in his book. I have converted from using ImageIcon to ImageIO as my way of reading in images. Specifically, I have used the code snippet from Abuse about loading images so that they are accelerated. I can get the game to run fine.
    I have started porting the code so that I can write my own game. I took a bmp file that I wanted to use as a spalsh screen and converted it to a PNG file using MS Paint. When I try to display that as my splash page, ImageIO.read throws an IllegalArgumentException. Here are the main code snippets that get an image:
         public URL getResource( String filename ) {
              return getClass().getClassLoader().getResource( filename );
         * Gets an image from the images/ directory.
         public BufferedImage loadImage( String name ) {
              String filename = "images/" + name;
              BufferedImage ret = null;
              try {
    System.out.println( filename );
    System.out.println( this.getResource( filename ) );
                   BufferedImage src = ImageIO.read( this.getResource( filename ) );
                   // Images returned from ImageIO are NOT managed images. Therefore,
                   // we copy it into a managed image.
                   ret = gc.createCompatibleImage( src.getWidth(), src.getHeight(), src.getColorModel().getTransparency() );
                   Graphics2D g2d = (Graphics2D) ret.getGraphics();
                   g2d.setComposite( AlphaComposite.Src );
                   g2d.drawImage( src, 0, 0, null );
                   g2d.dispose();
              } catch( IOException ioe ) {
                   ioe.printStackTrace();
                   // ignore so that this method returns null
              return ret;
    I added in the System.out.println and see that when I request my new PNG file, that the URL returned is null which leads to the issue with ImageIO.read. If I change my splash screen back to the JPG that Brakeen uses, it displays the image fine. I tried converting the JPG to a PNG using MS Paint and get the same issue that I received with my PNG file. I am positive that I have them in the right directory because I simply saved Brakeen's image in the same directory with a PNG extension and changed my source code from .jpg to .png. It appears that the getResource method is returning null for the two PNG files that I created yet returns a proper URL for other PNG files that I got from Brakeen.
    I have searched the forums for the last hour and do not see anything that matches my problem. I even tried moving the images into a res folder that I saw in one post to no avail. I am running Windows XP if that has any bearing on this. I can only think that somehow I have bad stuff in the PNG files. However, when I click my two PNG files, they are properly displayed in Windows.
    Any help would be greatly appreciated.

    Here is some output that I got from my System.out.println as well as the stacktrace from ImageIO.read:
    images/tankbrigade.png <-- from first System.out
    null <-- from second System.out
    java.lang.IllegalArgumentException: input == null!
         at javax.imageio.ImageIO.read(ImageIO.java:1338)
         at com.brackeen.state.ResourceManager.loadImage(ResourceManager.java:94)
         at com.ballantine.game.tankbrigade.SplashGameState.loadResources(SplashGameState.java:66)
         at com.brackeen.state.GameStateManager.loadAllResources(GameStateManager.java:66)
         at com.ballantine.game.tankbrigade.GameManager$1.run(GameManager.java:64)

  • Open png file

    Using Labview with Measurement & Automation (MAX) software
    I am able to grab a 10bit image using a IMAQ 1409 board and save the
    image as a PNG file.
    How can I re-open this file for viewing using a NI or third pary viewer.
    PhotoShop or Activiewer do not open the image correctly.
    Thanks

    LabVIEW can read in PNG files directly.
    Look on the functions palette in the 'Graphice & Sounds' sub palette, then the 'Graphics Formats' sub palette in there. There's a VI for reading the PNG file and another for assembling the info into something that LabVIEW can display.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • CS4 cannot parse .png files

    I just installed Photoshop cs4 on my new laptop, a Lenovo Y510p, and it refuses to open any and all .png files. The files themselves are not corrupt, because they'll open everywhere else, including Adobe Fireworks, but they will not open in photoshop. I checked to make sure the png plugin was present, and it is, and I tried to resave images in fireworks and in paint as png files and they still will not open in PS. I even tried creating a new png file in PS and once I close it photoshop will not open it again. So does anyone know how to fix this?
    I read on other forums that sometimes anti-virus programs can interfere, does anyone know if Windows Defender does? Also, I read there's a posibility that the png plugin is corrupted, or it may not have installed correctly, but I cannot find anywhere to download the plugin to try and correct it if that's the case.

    Never seen that. I usually have to set PS as the default for opening PNGs after a fresh install, but I've never seen PS unable to open PNGs.
    If you need the plug-in, here's one that I KNOW works: http://tinyurl.com/n5ag65r
    That's got the X86 and X64 PNG file format plug-ins in a zip.

  • PNG image returning null

    I can't for the life of me figure out what is wrong with the following code:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class CTFMain extends JPanel
        BufferedImage tileset;
        CTFMain()
            super();
            int width = 400;
         int height = 400;
         setPreferredSize(new Dimension(width, height));
            try
                //tileset = Toolkit.getDefaultToolkit().createImage("images\\EnvironmentTile.png");
                tileset = ImageIO.read(new File("images\\EnvironmentTile.png"));
            catch(IOException e)
        public void tic()
            repaint();
            System.out.println(tileset.toString());
        @Override
        public void paintComponent(Graphics g)
            g.setColor(Color.white);
            g.fillRect(0, 0, getWidth(), getHeight());
            g.setColor(Color.red);
            g.fill3DRect(20, 30, 150, 350, true);
            if(tileset == null)
                System.out.println("it's null");
            else
                g.drawImage(tileset, 0, 0, this);
        public static void main(String[] args)
            JFrame frame = new JFrame("Capture the Flag");
            CTFMain game = new CTFMain();
            frame.add(game);
            frame.pack();
            frame.setResizable(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            while(true)
                game.tic();
                try
                    Thread.sleep(1000/33);
                catch(Exception e)
    }Whenever I run the program, tileset gets assigned a null value, even though the path file is there, so when it calls drawImage, it draws a blank picture. What am I doing wrong?
    Note: The println and fill3DRect statements are there to test if those methods are working, and they are.

    Abion47 wrote:
    Do you need that? <DWS>No, I just made that comment because I like reading back what I wrote. It amuses me.</DWS>
    Yes, I need the information.
    .. Because I don't know how to do that...Then it looks like you are stuffed, unless you can either do some research into the 'Java SDK Jar tool' and/or ask a smart question.

  • Displaying the .png image stored in an byte array

    Hi,
    I have to download an .png image from a server and i have to store it in a byte array and i have to display this byte array in another servlet. I have written the code to get the image from the remote server in a java class. The java class returns the byte array of the image and i have to display that in an servlet.
    If anybody has the code or any refrence to refer please help me..
    Thanks & Regards
    -Sandeep

    I have pasted code for servlet's doGet method which writes image data...
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws
    ServletException, IOException
    HttpSession session = request.getSession(); //taking httpsession
    response.setContentType("image/jpeg");
    ServletOutputStream out = response.getOutputStream(); //taking outputstream of response
    if (rtn.getErrorCode() == 0)
    //this will actually write image file data from where it is being called
    //byte array will contain image data, please load your image into below byte array variable
    byte[] b = new byte[100];
    out.write(b);
    out = null; //making null
    session = null; //making null
    In other servlet, write <img> tag and specify its src attribute to the "name of servlet where u have pasted above code" ..
    Regards,
    Nikhil

  • Problem Displaying an Image in a JScrollPane

    Hi All,
    I've placed a Toolbar at the bottom of a JFrame and above the toolbar I placed a JTabbedPane. In one of the tabs I want to display a full sized image.The size of the image that I want to display using a scroll pane is 595x842 pixels. Now the problem is that when I display the image in the scroll pane the bottom toolbar is overlapped with the scrollpane. I don't want to resize the image as it is spoiling the image quality.I used the below code
    JPanel imagepagepanel=new JPanel()
        protected void paintComponent(Graphics g)
              js=new JScrollPane();
              Point p = js.getViewport().getViewPosition();
              g.drawImage(demoicon.getImage(), p.x, p.y, null);
    mytabbedpane.addTab("View Image",js); //add the scrollpane to the tabI even tried using a label to display the image in the tabbedpane and I've got the same overlapping problem.
    I am able to embed the default browser in my application using JDIC API and the image display is fine in the browser without overlapping the bottom toolbar. But I don't want to use a web browser to display the image.
    It would be of great help if anyone could suggest a solution to the overlapping problem. I want the scroll pane to work similar to a web browser while displaying a large sized image.
    Thanks in advance.

    Override the paintComponent method to just draw the
    image at 0, 0, w, h.
    The rest is not needed, to say the least.Here's an easier way
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.awt.*;
    import java.io.File;
    import java.io.IOException;
    public class ImageInTabbedScrollTest extends JFrame {
        public ImageInTabbedScrollTest() {
            buildGUI();
        private void buildGUI() {
            JPanel mainPanel = (JPanel) getContentPane();
            mainPanel.setLayout(new BorderLayout());
            JTabbedPane tabbedPane = new JTabbedPane();
            try {
                Image image = ImageIO.read(new File("images/terrain.jpg"));
                ImageIcon icon = new ImageIcon(image);
                JLabel label = new JLabel(icon);
                JPanel panel = new JPanel(new GridLayout(0,1,5,5));
                panel.add(label);
                JScrollPane jsp = new JScrollPane(panel);
                tabbedPane.addTab("Image",jsp);
                JPanel anotherPanel = new JPanel();
                JLabel label2 = new JLabel("Second Panel");
                anotherPanel.add(label2);
                 label2.setFont(new Font("San Serif",Font.BOLD, 40));
                tabbedPane.add("Label",anotherPanel);
                mainPanel.add(tabbedPane, BorderLayout.CENTER);
                JToolBar tBar = new JToolBar();
                tBar.add(new Button("OK"));
                tBar.add(new Button("Maybe"));
                tBar.add(new Button("No"));
                mainPanel.add(tBar, BorderLayout.SOUTH);
                  } catch (IOException e) {
                e.printStackTrace();
        public static void main(String[] args) {
            Runnable runnable = new Runnable() {
                public void run() {
                    ImageInTabbedScrollTest testFrame = new ImageInTabbedScrollTest();
                    testFrame.setSize(new Dimension(600,600));
                    testFrame.setLocationRelativeTo(null);
                    testFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
                    testFrame.setVisible(true);
            SwingUtilities.invokeLater(runnable);
    }

  • JAI - problem displaying additional pages from multi-page image

    Hi,
    I have 10 page multipage tiff images. And i would like to show the images one-by-one on a ScrollingImagePanel.
    I have a Main frame with two panels. Panel1 which shows the ScrollingImagePanel.
    And Panel2 has two buttons. LOAD Button show the 1st page on the ScrollingImagePanel.
    And NEXT button is suppose to show the 2nd page and continue until the end of the multipage images.
    I am having problem with the NEXT button. I wrote a program that show the page number and page height
    on the output screen. It shows the page# and different heights. But it would not show the images on the ScrollingImagePanel.
    It just shows the 1st page. I would appreciate if you can help me out with this problom.
    Please find the code which is written in JBuilder.
    // Main class
    package untitled1;
    import java.awt.*;
    import javax.swing.UIManager;
    import java.awt.*;
    import java.io.File;
    import java.io.IOException;
    import java.awt.Frame;
    import java.awt.image.RenderedImage;
    import javax.media.jai.widget.ScrollingImagePanel;
    import javax.media.jai.NullOpImage;
    import javax.media.jai.OpImage;
    import com.sun.media.jai.codec.SeekableStream;
    import com.sun.media.jai.codec.FileSeekableStream;
    import com.sun.media.jai.codec.TIFFDecodeParam;
    import com.sun.media.jai.codec.ImageDecoder;
    import com.sun.media.jai.codec.ImageCodec;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public class Application1 {
    boolean packFrame = false;
    //Construct the application
    public Application1() {
    Frame2 frame = new Frame2();
    frame.setSize(820,700);
    //Validate frames that have preset sizes
    //Pack frames that have useful preferred size info, e.g. from their layout
    if (packFrame) {
    frame.pack();
    else {
    frame.validate();
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height) {
    frameSize.height = screenSize.height;
    if (frameSize.width > screenSize.width) {
    frameSize.width = screenSize.width;
    frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    frame.setVisible(true);
    //Main method
    public static void main(String[] args) {
    new Application1();
    // Frame2 Class
    package untitled1;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.UIManager;
    import java.io.File;
    import java.io.IOException;
    import java.awt.Frame;
    import java.awt.image.RenderedImage;
    import javax.media.jai.widget.ScrollingImagePanel;
    import javax.media.jai.NullOpImage;
    import javax.media.jai.OpImage;
    import com.sun.media.jai.codec.SeekableStream;
    import com.sun.media.jai.codec.FileSeekableStream;
    import com.sun.media.jai.codec.TIFFDecodeParam;
    import com.sun.media.jai.codec.ImageDecoder;
    import com.sun.media.jai.codec.ImageCodec;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.*;
    import java.awt.image.renderable.ParameterBlock;
    import javax.media.jai.*;
    import javax.media.jai.widget.*;
    import com.sun.media.jai.codec.*;
    import java.util.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public class Frame2 extends Frame {
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JButton loadButton = new JButton();
    public static ScrollingImagePanel panel, panels;
    JButton nextButton = new JButton();
    public String filename= "144.tif";
    public File file;
    public SeekableStream s;
    public ImageDecoder dec;
    protected int imageWidth, imageHeight;
    public int nextpage = 1;
    public RenderedOp image2 = null;
    public RenderedImage op = null;
    //Frame Constructor
    public Frame2() {
    try {
    jbInit();
    catch(IOException e) {
    e.printStackTrace();
    private void jbInit() throws IOException {
    this.setLayout(null);
    this.addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    this_windowClosing(e);
    jPanel1.setBackground(Color.white);
    jPanel1.setBorder(BorderFactory.createLineBorder(Color.black));
    jPanel1.setBounds(new Rectangle(1, 7, 816, 648));
    jPanel1.setLayout(null);
    jPanel2.setBackground(Color.lightGray);
    jPanel2.setBorder(BorderFactory.createLineBorder(Color.black));
    jPanel2.setBounds(new Rectangle(1, 657, 816, 42));
    loadButton.setText("Load");
    loadButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    try{                          
    loadButton_actionPerformed(e);
    catch(IOException IOE){
    System.out.println(IOE);
    nextButton.setText("Next");
    nextButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    try {
    nextButton_actionPerformed(e);
    catch(IOException IOE){
    System.out.println(IOE);
    this.setResizable(false);
    this.add(jPanel1, null);
    this.add(jPanel2, null);
    jPanel2.add(loadButton, null);
    jPanel2.add(nextButton, null);
    void this_windowClosing(WindowEvent e) {
    System.exit(0);
    //Load Image Button
    void loadButton_actionPerformed(ActionEvent e) throws IOException { 
    file = new File(filename);
    s = new FileSeekableStream(file);
    dec = ImageCodec.createImageDecoder("tiff", s, null);
    RenderedImage op =
    new NullOpImage(dec.decodeAsRenderedImage(),
    null,
    OpImage.OP_IO_BOUND,
    null);
    Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
    ParameterBlock params = new ParameterBlock();
    params.addSource(op);
    params.add(0.55F); // x scale factor
    params.add(0.335F); // y scale factor
    params.add(0.00F); // x translate
    params.add(0.00F); // y translate
    params.add(interp); // interpolation method
    image2 = JAI.create("scale", params);
    int width = (int)(image2.getWidth() * .73);
    int height = (int)(image2.getHeight() * .73);
    panel = new ScrollingImagePanel(image2, 819, 648);
    jPanel1.add(panel);
    this.setVisible(true);
    //Next Image Button
    void nextButton_actionPerformed(ActionEvent e) throws IOException {
    TIFFDecodeParam param = null;
    file = new File(filename);
    s = new FileSeekableStream(file);
    dec = ImageCodec.createImageDecoder("tiff", s, param);
    nextpage++;
    System.out.println(nextpage);
    RenderedImage op1 =
    new NullOpImage(dec.decodeAsRenderedImage(nextpage),
    null,
    OpImage.OP_IO_BOUND,
    null);
    Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
    ParameterBlock params = new ParameterBlock();
    params.addSource(op1);
    params.add(0.55F); // x scale factor
    params.add(0.335F); // y scale factor
    params.add(0.00F); // x translate
    params.add(0.00F); // y translate
    params.add(interp); // interpolation method
    image2 = JAI.create("scale", params);
    int width = (int)(image2.getWidth() * .73); //1.03);
    int height = (int)(image2.getHeight() * .73); //1.03);
    panels = new ScrollingImagePanel(image2, width, height);
    System.out.println(op1.getHeight());
    jPanel1.add(panels);
    this.setVisible(true);
    thanks in advance

    Take a look at this code.
    //Search the Policynumber
    void searchButton_actionPerformed(ActionEvent e) {
    try{
    nextButton.setEnabled(false);
    previousButton.setEnabled(false);
    String query = "SELECT * FROM PINFO WHERE POLICYNUMBER = '" +
    searchTextfield.getText().toUpperCase() + "'";
    ResultSet rs = Application1.stmt.executeQuery(query);
    while(rs.next()){
    pid = (rs.getInt("PID"));
    policynumber = rs.getString("POLICYNUMBER");
    firstName = rs.getString("FIRSTNAME");
    lastName = rs.getString("LASTNAME");
    jLabel2.setText(policynumber);
    jLabel3.setText(firstName);
    jLabel4.setText(lastName);
    catch(SQLException ex){
    System.err.println("SQLException: " + ex.getMessage());
    try{
    String query = "SELECT * FROM (UNMATCH U LEFT JOIN DOCUMENTTYPE D ON U.DOCUMENTTYPE=D.DOCNUMBER) WHERE PID = '" + pid + "' ORDER BY D.DOCUMENTCODE";
    ResultSet rs1 = Application1.stmt.executeQuery(query);
    clearJList();
    v.removeAllElements();
    jList1.setListData(v);
    v1.clear();
    while(rs1.next()){
    documentcode = rs1.getString("DOCUMENTCODE");
    uindex = rs1.getString("UINDEX");
    v.add(documentcode);
    v1.add(uindex);
    jList1.setListData(v);
    clearTextfield();
    catch(SQLException s){
    System.err.println("SQLException: " + s.getMessage());
    public void clearJList(){
    jList1.setListData(v);
    public void clearTextfield(){
    searchTextfield.setText("");
    // ****** Loads the selected Image
    void jList1_mouseClicked(MouseEvent e){
    try{
    vector.clear();
    nextpage = 1;
    currentpage = 1;
    nextButton.setEnabled(true);
    previousButton.setEnabled(false);
    if (spane != null)
    jPanel1.removeAll();
    seek = null;
    String query1 = "SELECT * FROM UNMATCH WHERE UINDEX = '" + v1.get(jList1.getSelectedIndex()).toString() + "'";
    rs2 = Application1.stmt.executeQuery(query1);
    while (rs2.next()){
    stream = rs2.getBinaryStream("IMAGE");
    seek = new MemoryCacheSeekableStream(stream);
    TIFFDecodeParam param = null;
    dec = ImageCodec.createImageDecoder("tiff", seek, param);
    try{
    totalPages = dec.getNumPages();
    jLabel1.setText("Page 1 of "+totalPages);
    if (nextpage==totalPages)
    nextButton.setEnabled(false);
    op1 =
    new NullOpImage(dec.decodeAsRenderedImage(nextpage-1),
    null,
    OpImage.OP_IO_BOUND,
    null);
    vector.addElement(op1);
    // ParameterBlock params = new ParameterBlock();
    // params.addSource(op1);
    // panel = new DisplayJAI(op1);
    panel = new DisplayJAI((RenderedImage)vector.elementAt(0));
    spane = new JScrollPane(panel);
    jPanel1.add(spane);
    jPanel1.validate();
    this.setVisible(true);
    catch(IOException dfs){
    } // while
    } // try
    catch(SQLException s){
    System.err.println("SQLException: " + s.getMessage());
    // Next Image
    void nextButton_actionPerformed(ActionEvent e) {
    try{
    if (spane != null)
    jPanel1.removeAll();
    ++nextpage;
    if (nextpage==totalPages)
    nextButton.setEnabled(false);
    previousButton.setEnabled(true);
    jLabel1.setText("Page " + nextpage +" of "+totalPages);
    TIFFDecodeParam param = null;
    dec = ImageCodec.createImageDecoder("tiff", seek, param);
    currentpage = nextpage;
    ParameterBlock paramblock = new ParameterBlock();
    paramblock.addSource(op1);
    vector.addElement(new NullOpImage(dec.decodeAsRenderedImage(nextpage-1),
    null,
    OpImage.OP_IO_BOUND,
    null));
    panel = new DisplayJAI((RenderedImage)vector.elementAt(currentpage-1));
    // panel = new DisplayJAI(op1);
    spane = new JScrollPane(panel);
    jPanel1.add(spane);
    setVisible(true);
    catch(IOException o){
    System.out.println(o);
    finally{
    // PreviousButton
    void previousButton_actionPerformed(ActionEvent e) {
    try{
    if (spane != null)
    jPanel1.removeAll();
    --nextpage;
    if (nextpage==1)
    previousButton.setEnabled(false);
    nextButton.setEnabled(true);
    jLabel1.setText("Page " + nextpage +" of "+totalPages);
    TIFFDecodeParam param = null;
    dec = ImageCodec.createImageDecoder("tiff", seek, param);
    currentpage = nextpage;
    vector.addElement(new NullOpImage(dec.decodeAsRenderedImage(nextpage-1),
    null,
    OpImage.OP_IO_BOUND,
    null));
    panel = new DisplayJAI((RenderedImage)vector.elementAt(currentpage-1));
    spane = new JScrollPane(panel);
    jPanel1.add(spane);
    setVisible(true);
    catch(IOException o){
    System.out.println(o);
    // Zoom ComboBox Item Select
    void jComboBox1_itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.DESELECTED)
    if (spane != null)
    jPanel1.removeAll();
    Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BICUBIC);
    ParameterBlock params = new ParameterBlock();
    params.addSource(op1);
    params.add(Float.valueOf(jComboBox1.getSelectedItem().toString()).floatValue()/100.0f);
    params.add(Float.valueOf(jComboBox1.getSelectedItem().toString()).floatValue()/100.0f);
    params.add(0.0F);
    params.add(0.0F);
    params.add(interp);
    // image2 = JAI.create("scale",params);
    vector.add(currentpage-1,JAI.create("scale",params));
    panel = new DisplayJAI((RenderedOp)vector.elementAt(currentpage-1));
    spane = new JScrollPane(panel);
    jPanel1.add(spane);
    jPanel1.validate();
    this.setVisible(true);
    repaint();
    // Rotate ComboBox Item Select
    void jComboBox2_itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.DESELECTED)
    if (spane != null)
    jPanel1.removeAll();
    type =null;
    type = transposeTypes[jComboBox2.getSelectedIndex()];
    ParameterBlock pb = new ParameterBlock();
    pb.addSource((RenderedImage)vector.elementAt(currentpage-1));
    pb.add(type);
    PlanarImage im2 = JAI.create("transpose", pb, renderHints);
    vector.add(currentpage-1,im2);
    panel = new DisplayJAI((RenderedOp)vector.elementAt(currentpage-1));
    spane = new JScrollPane(panel);
    jPanel1.add(spane);
    jPanel1.validate();
    this.setVisible(true);
    void printButton_actionPerformed(ActionEvent e) {
    print();
    protected void print() {
    PrinterJob pj = PrinterJob.getPrinterJob();
    pj.setPrintable(this);
    // PageFormat format = pj.pageDialog(pj.defaultPage());
    // Book bk = new Book();
    // bk.append(this,pj.defaultPage());
    // pj.setPageable(bk);
    if(pj.printDialog()){
    try{
    pj.print();
    catch(Exception e){
    System.out.println(e);
    else{
    System.out.println("Did Not Print Any Pages");
    public int print(Graphics g, PageFormat f, int pageIndex){
    if(pageIndex >= 1){
    return Printable.NO_SUCH_PAGE;
    Graphics2D g2d = (Graphics2D) g;
    g2d.translate(f.getImageableX(), f.getImageableY());
    if(op1 != null){
    double scales = Math.min(f.getImageableWidth()/ op1.getWidth(), f.getImageableHeight()/ op1.getHeight());
    g2d.scale(scales,scales);
    printImage(g2d, op1);
    return Printable.PAGE_EXISTS;
    else{
    return Printable.NO_SUCH_PAGE;
    public void printImage(Graphics2D g2d, RenderedImage image){
    if((image == null)|| (g2d == null)) return;
    int x = printLoc.x;
    int y = printLoc.y;
    AffineTransform at = new AffineTransform();
    at.translate(x,y);
    g2d.drawRenderedImage(image,at);
    public void setPrintLocation(Point d) {
    printLoc = d;
    public Point getPrintLocation() {
    return printLoc;

  • Problem displaying the image

    I am having a trouble with display an image. My image is put in the base directory of my workspace and my IDE is Eclipse. However, I just can't get the image to display...
    It is at the bottom of the code...
    package ca.carleton.comp3004.client.ui;
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.event.ActionEvent;
    import javax.imageio.*;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.border.TitledBorder;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.io.File;
    import java.io.IOException;
    import ca.carleton.comp3004.client.model.Model;
    import ca.carleton.comp3004.util.AppUtils;
    import ca.carleton.comp3004.util.UiUtils;
    public class GamePanel extends JPanel
         private JPanel bottomStuff;
         private JScrollPane cardPane;
         private JButton requestCards;
         private JPanel centerStuff;
         private JPanel[] playerStuff;
         private JLabel[] playerName;
         private JLabel[] playerNumCards;
         private JLabel[] playerScore;
         private JPanel topStuff;
         private JLabel unoCode;
         private JLabel timeLabel;
         private JButton leave;
         private Image board = null;
         //Icon BoardImage = new ImageIcon("C:\Users\tzaid\Desktop\steve stuff\Johnny_Workspace\GameBoard.png");
         //private ActionListener buttonlistener;
         private Model model;
         private class CardRequestListener implements ActionListener {
            public void actionPerformed(ActionEvent theEvent) {
                  AppUtils.invoke(new Runnable()
                     public void run()
                          model.requestCards();
         private class CardButtontListener implements ActionListener {
            public void actionPerformed(ActionEvent theEvent) {
                 final int cardIndex = Integer.parseInt(theEvent.getActionCommand());
                 AppUtils.invoke(new Runnable()
                    public void run()
                         model.playCard(cardIndex); //****note: extract cardNum
         private class LeaveListener implements ActionListener {
            public void actionPerformed(ActionEvent theEvent) {
                 AppUtils.invoke(new Runnable()
                    public void run()
                         model.leave(); //****note: not in protocol yet
         // actions
         CardRequestListener myCardRequestListener = new CardRequestListener();
         CardButtontListener myCardButtonListener = new CardButtontListener();
         LeaveListener myLeaveListener = new LeaveListener();
        public GamePanel(Model model)
             this.model = model;
             createComponents(this);
         * Creates the components.
        private void createComponents(JPanel container)
             container.setLayout(new BorderLayout());
            // chat panel
            CreatePanels();
            container.add(centerStuff, BorderLayout.CENTER);
            container.add(bottomStuff, BorderLayout.SOUTH);
            container.add(topStuff, BorderLayout.NORTH);
          //  Graphics g = new Graphics();
          //  g.drawImage(board, 0, 0, null);
         * Creates the chat panel for chat room functionality.
         * @return A panel containing chat room controls.
         * @see JPanel
        private void CreatePanels()
             topStuff = new JPanel();
             unoCode = new JLabel("UNO Code: ");
             timeLabel = new JLabel("Time: ");
             leave = new JButton("Leave Game");
             leave.addActionListener(myLeaveListener);
             topStuff.setLayout(new BorderLayout());
             topStuff.add(unoCode, BorderLayout.WEST);
             topStuff.add(timeLabel, BorderLayout.EAST);
             topStuff.add(leave, BorderLayout.NORTH);
             topStuff.setBorder(BorderFactory.createLineBorder(Color.black));
             //******note: need to specify size*****
             int size = 5;
             centerStuff = new JPanel();
             playerStuff = new JPanel[size];
             playerName = new JLabel[size];
             playerNumCards = new JLabel[size];
             playerScore = new JLabel[size];
             centerStuff.setLayout(new FlowLayout(FlowLayout.CENTER, 40, 40));  //need to change later so is around table
             for(int i = 0; i<size; i++){
                  playerStuff[i] = new JPanel();
                  playerStuff.setLayout(new BorderLayout());
              playerName[i] = new JLabel("no name" ); //****get player name here
              playerNumCards[i] = new JLabel("0");
              playerScore[i] = new JLabel("0");
              playerStuff[i].add(playerName[i], BorderLayout.NORTH);
              playerStuff[i].add(playerNumCards[i], BorderLayout.CENTER);
              playerStuff[i].add(playerScore[i], BorderLayout.SOUTH);
              playerStuff[i].setBorder(BorderFactory.createLineBorder(Color.black));
              centerStuff.add(playerStuff[i]);
         bottomStuff = new JPanel();
         cardPane = new JScrollPane();
         requestCards = new JButton("Request Cards");
         requestCards.addActionListener(myCardRequestListener);
         bottomStuff.setLayout(new BorderLayout());
         bottomStuff.add(requestCards, BorderLayout.WEST);
         bottomStuff.add(cardPane, BorderLayout.CENTER);
         bottomStuff.setBorder(BorderFactory.createLineBorder(Color.black));
    public GamePanel()
         setPreferredSize(new Dimension(790,572));
         setMaximumSize(getPreferredSize());
         setMinimumSize(getPreferredSize());
         setSize(getPreferredSize());
         try
    board= ImageIO.read(new File("GameBoard.png"));
    getGraphics().drawImage(board, 0, 0, null);
         catch (IOException e)
         e.printStackTrace();
    /* private JPanel createMessageListPanel()
    JPanel messageListPanel = new JPanel(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(messageList = createMessageList(),
    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setAutoscrolls(true);
    messageListPanel.add(scrollPane);
    messageListPanel.setBorder(new TitledBorder("Messages"));
    return messageListPanel;
    * Creates message list.
    * @return A text area to store messages in.

    Look like a bad video card. Are you eligible for Apple's Repair extension programs?

Maybe you are looking for

  • This Disk Could Not Be Mounted

    Hello, i've looked throughout the message boards but I wasn't able to find anything that would help with my problem. I have a Lacie hardrive plugged in to my Macbook Pro. It's a 1.5TB hardrive with 2 partitions, and the other day it crashed. Nothing

  • Required information on Batch status updatings.

    Hi, I want to change batch status after creating the outbound delivery through inbound idoc, i was able to create delivery , but after creation, i should update the batch status using function module BAPI_BATCH_SAVE_REPLICA, but i was unable to execu

  • Why am I no longer able to scroll mac mail

    Running Mavericks on new computer with Apple wireless mouse and today am unable to scroll through my mailboxes or list of message. Is the a mac mail issue, or perhaps an issue with my wireless mouse?

  • UDP ip address

    I have two ethernet PCI cards in my PC.  One of them is gigabit (Intel PRO/1000 GT) and the other one is 10 BASET.  I found a couple of functions, i.e., UDP Write and UDP Read in my Labview 6.0 which may work for my purposes.  I was able to set a uni

  • Easiest way to access remote files on Macs?

    Hi. I was just wondering if there was a way that I can access files on my remote mac?  It is setup as a file server and has a share point created which is fine on the loca network, but say I am working away and want to access the files. What is the e