Solved

Graphics/Images

Posted on 2004-04-14
8
218 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
ID: 10827815
ImageIcon icon = new ImageIcon(filename);
0
 
LVL 4

Assisted Solution

by:john-at-7fff
john-at-7fff earned 25 total points
ID: 10827929
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
ID: 10828179
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 92

Expert Comment

by:objects
ID: 10828189
0
 

Author Comment

by:starwarp2k2
ID: 10828190
Hey objects, what is the import for ImageIcon
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 10828219
import javax.swing.ImageIcon;
0
 

Author Comment

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java stored proc example 9 44
servlet example 11 49
eclipse buid path vs tomcat lib path 10 34
JavaFX TableView not displaying correctly 3 54
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

791 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