createImage sometime returns null and sometime returns non-null.

Discussion in 'Java' started by vizlab, Nov 30, 2004.

  1. vizlab

    vizlab Guest

    Hi:
    I am debugging an Java standalone application and some servlets in
    eclipse3.0.
    I am using tomcat5.5 and jre1.5.0.
    There is a file, called FlowChart.java, which will be used in the
    Java standalone application and also used (called) by a servlet.


    public class FlowChart extends JComponent implements
    Serializable,MouseMotionListener,Printable {
    ...
    Image backDrop=createImage(800,600);
    ...
    }

    When I debug the Java standalone application in eclipse, the
    createImage() returns a non-null pointer. But when I debug the
    servlets in eclipse, createImage() returns a null pointer.

    Why???

    One reason I guess is that eclipse uses its own libraries and
    compiler to debug the standalone application, while the servlets are
    debugged by using external jre1.5.0. There is some difference between
    the jre1.5.0 and the eclipse's coming-with libraries. Is it true?

    I have stucked on this problem for a long time.

    Highly appreciate anyone giving me a way out!

    Best
     
    vizlab, Nov 30, 2004
    #1
    1. Advertising

  2. On 29 Nov 2004 20:05:24 -0800, vizlab wrote:

    > I am debugging an Java standalone application and some servlets in
    > eclipse3.0.


    There seems to be some guy on c.l.j.gui. that has the
    *exact* same problem. He's already got an answer.
    <http://groups.google.com/groups?threadm=1h364f0ltzd9r$>
    Why don't you tune into that thread instead?

    And please refrain from multi-posting in future.
    <http://www.physci.org/codes/javafaq.jsp#xpost>

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
     
    Andrew Thompson, Nov 30, 2004
    #2
    1. Advertising

  3. vizlab

    tom.lake

    Joined:
    Sep 5, 2006
    Messages:
    1
    Components sometimes not displayable in constructor

    Thanks to Andrew Thompson for references to updated documentation for JDK1.5...

    A complicating factor is that components often don't appear to be displayable during
    their constructor EVEN IF YOU HAVE FINISHED THE CONSTRUCTOR OF THE
    UNDERLYING IMPLEMENTATION COMPONENT.

    That is if you are using a class X which extends Frame in an application X.createImage
    will return null during X's constructor even after the call of super(windowTitle).

    So do the work which involves createImage in a separate initialisation step after the constructor - as far as I can see.
     
    tom.lake, Sep 5, 2006
    #3
  4. vizlab

    Michael Bar-Sinai

    Joined:
    Oct 17, 2007
    Messages:
    1
    Location:
    London
    Possible Reasons

    Hi Vizlab.
    First of all, qouting from the Java API of Component.createImage():
    Your server is probably running headless - which is probably the default configuration (server guys usually snub swingers anyway ;-) ).
    This can also happen on a swing application, if the component you're trying to use is not connected to a native screen resource (meanning - somewhere up in the containment hirarchy there is a heavyweight component).
    You can call isDisplayable() prior to creating an image to test that.
    See also here for and excellent java-on-server read: http://today.java.net/pub/a/today/2006/04/20/bringing-swing-to-the-web.html
     
    Michael Bar-Sinai, Oct 17, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. YesBalala
    Replies:
    1
    Views:
    530
    YesBalala
    Feb 13, 2004
  2. Rob Love
    Replies:
    1
    Views:
    3,329
    dhek bhun kho
    Jul 2, 2003
  3. patrick

    createImage problem

    patrick, Dec 4, 2003, in forum: Java
    Replies:
    8
    Views:
    567
    patrick
    Dec 4, 2003
  4. Mike
    Replies:
    0
    Views:
    404
  5. Thomas Fritsch
    Replies:
    2
    Views:
    1,044
    Andrey Kuznetsov
    Jul 27, 2006
Loading...

Share This Page