Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Image help

gustavosserragustavosserra Member Posts: 201
Ive made a little applet that puts a image on the screen. But nothing happens. Ive used the following code

class Dosomething extends java.applet.Applet
{
Image img = getImage(getDocumentBase(),"anyimage.jpg");

public void paint(Graphics screen){
screen.drawImage(img);
}
}

What is the problem???
GS

Comments

  • QueezyTheGreatQueezyTheGreat Member Posts: 70
    : Ive made a little applet that puts a image on the screen. But nothing happens. Ive used the following code
    :
    : class Dosomething extends java.applet.Applet
    : {
    : Image img = getImage(getDocumentBase(),"anyimage.jpg");
    :
    : public void paint(Graphics screen){
    : screen.drawImage(img);
    : }
    : }
    :
    : What is the problem???
    : GS

    Well there could be two things palying here first of all the drawImage
    method needs more parameters, it woulden`t even compile,one of the
    drawImage method signature is (Image img, int x, int y, ImageObserver
    observer). What you have to know is which image to draw and the exact
    location on the screen where you want draw (X,Y), the last parameter
    you don`t have to know you can simply put this, that because Applets
    implement the ImageObserver interface. The other thing could be that you
    have provided an invalid path. The drawImage method does not report
    errors, so if the path is missing the image won`t be desplayed.

    Hope that helps.



    -------==[QTZ]==------
    -==[QueezyTheGreat]==-

  • gustavosserragustavosserra Member Posts: 201
    Thanks a lot!!! :))
    Ill try this as soon as I can. If I have more problems Ill report it.
    Thanks again!
  • Andre YoungAndre Young USAMember Posts: 0

    ____ | http://forcoder.org | free ebooks and video tutorials about ( JavaScript R Perl Assembly Python Delphi Scratch C C++ MATLAB Objective-C Visual Basic Ruby Visual Basic .NET Swift C# PHP Java Go PL/SQL Clojure COBOL FoxPro Lua Apex Hack Kotlin ABAP SAS LabVIEW Julia F# Bash Awk Scheme Ada Erlang Crystal Prolog Scala Fortran ML Lisp D Dart Rust Logo VBScript Transact-SQL Alice ) _____________

Sign In or Register to comment.