Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with images
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jonny Tight Lips




PostPosted: Thu Sep 08, 2005 6:22 pm   Post subject: Help with images

Well I have tryed and tryed but I just can't seem to get the image to show up. So far this is what I've got:

code:

import java.awt.*;
import javax.swing.*;
 
 public class Image {
        public static void main(String[] args) {
            new Image();
        }
        Image() {
            JFrame frame = new JFrame();
   
            frame.getContentPane().add(new MyComponent());

            frame.setSize(300, 300);
            frame.setVisible(true);
        }
   
        class MyComponent extends JComponent {
            public void paint(Graphics g) {
                                Image image =     Toolkit.getDefaultToolkit().getImage("homer.gif");
                             g.drawImage(image, 0, 0, this);
            }
        }
    }


Yes this is probably horably wrong but thats as far as I can get. So any help you can give me would be nice. I just can seam to get this. Thx
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Thu Sep 08, 2005 6:28 pm   Post subject: (No subject)

one big mistake you made is call your class Image... change it to Test or something then try again.
Jonny Tight Lips




PostPosted: Fri Sep 09, 2005 3:32 pm   Post subject: (No subject)

Thx I finaly got it. Time to move on to movement.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: