Solved

Graphics/Images

Posted on 2004-04-14
8
211 Views
Last Modified: 2010-03-31
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.
0
Comment
Question by:starwarp2k2
  • 3
  • 3
8 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
ImageIcon icon = new ImageIcon(filename);
0
 
LVL 4

Assisted Solution

by:john-at-7fff
john-at-7fff earned 25 total points
Comment Utility
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
 

Author Comment

by:starwarp2k2
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 92

Expert Comment

by:objects
Comment Utility
0
 

Author Comment

by:starwarp2k2
Comment Utility
Hey objects, what is the import for ImageIcon
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
Comment Utility
import javax.swing.ImageIcon;
0
 

Author Comment

by:starwarp2k2
Comment Utility
Sorry, I didn't realize that I hadn't awarded points. Thank you.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now