Results 1 to 2 of 2
  1. #1
    amith is offline Member
    Join Date
    May 2008
    Posts
    24
    Rep Power
    0

    Default other than paint repaint

    any method is there to drawimage through this method instead of using paint repaint or paintcomponent methods like this
    void load()
    {
    Graphics g;
    try{
    g=getGraphics();
    g.drawImage(img,220,220,this);
    }
    catch(exception e)
    {}

  2. #2
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Java Code:
    public void paint(Graphics g){
             Graphics2D g2=(Graphics2D)g;//casting to 2D
             g2.drawImage(new ImageIcon(/path/to/image).getImage(),220,220,this);
    }

Similar Threads

  1. passing parameters to paint mtd
    By themburu in forum Java Applets
    Replies: 3
    Last Post: 07-14-2008, 08:15 PM
  2. How to create Animation: Paint and thread
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-21-2008, 08:42 PM
  3. How to make a MouseClick paint an object
    By Devilsfutbol17 in forum New To Java
    Replies: 6
    Last Post: 06-05-2008, 12:54 PM
  4. radio buttons and paint
    By gtraylo in forum Java Applets
    Replies: 1
    Last Post: 04-19-2008, 12:43 PM
  5. paint() and paintComponent()
    By goldhouse in forum Java 2D
    Replies: 1
    Last Post: 07-17-2007, 03:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •