Graphics/Images

I'm new to game programming in java. I need to know how the basics...where to begin. How do I create an image object, load a picture, move it, etc.

For this, should I use a wrapper class? Graphics engine?
Suggestions on above would be appreciated.
starwarp2k2Asked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
import javax.swing.ImageIcon;
0
 
objectsCommented:
ImageIcon icon = new ImageIcon(filename);
0
 
john-at-7fffConnect With a Mentor Commented:
Your best bet is to search for tutorials on Swing (http://java.sun.com/docs/books/tutorial/uiswing/), or perhaps buy the book Swing by Robinson and Vorobiev.

In the meantime, here's some code that should get you started . . .

import java.awt.Image;
import java.awt.Insets;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class ShowImage extends JFrame {

      private Image image = null;
      private Insets insets = null;
      
      public ShowImage(URL u) {
            super(u.toString());
            JLabel label = new JLabel(new ImageIcon(u));
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            getContentPane().add(label);
            pack();
            setVisible(true);
      }

      public static void main(String[] args) throws MalformedURLException, IOException {
            new ShowImage(new URL("http://us.news1.yimg.com/us.yimg.com/p/ap/20040414/thumb.pmm10704141855.bush_sharon_mideast_israel_pmm107.jpg"));
      }
}
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
starwarp2k2Author Commented:
I was leaning more towards full screen type games, not limited by java's frames, labels, etc.
I would appreciate it if you could help me there.
0
 
starwarp2k2Author Commented:
Hey objects, what is the import for ImageIcon
0
 
starwarp2k2Author Commented:
Sorry, I didn't realize that I hadn't awarded points. Thank you.
0
All Courses

From novice to tech pro — start learning today.