Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 13th, 2005, 10:49 PM
SnookerLoopy SnookerLoopy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 3 SnookerLoopy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 22 sec
Reputation Power: 0
Basic image handling help needed!

-----------------------------------------------------------
import java.io.*;
import java.awt.*;
import java.awt.image.*;


public class DisplayImage extends Canvas {

Image image;
Toolkit toolkit = Toolkit.getDefaultToolkit();

public DisplayImage() {
}

public void loadImage() {
image = toolkit.getImage("test.jpg");
}

public void paint(Graphics g) {
g.drawImage(image, 0, 0, this);
}

public static void main(String[] args){
DisplayImage displayimage = new DisplayImage();

displayimage.loadImage();
// here is where I want to call 'paint'
//method, but don't know how
}

}

-----------------------------------------------------------

Hello everyone,

I was wondering if anyone could help me with the code above. I want the program to just basically load up an image and then display it, with typing in 'java DisplayImage imagename.jpg' from the command prompt.

If I just call displayimage.paint(), it won't work because it needs to have Graphics g passed into it, and if I call displayimage.paint(image), it won't work because image is an Image object, not a Graphics object - yet a Graphics object can't be directly created or something. AAAaaaargh!

help!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Basic image handling help needed!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT