File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes How to Add Images to Panels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "How to Add Images to Panels" Watch "How to Add Images to Panels" New topic

How to Add Images to Panels

barron logan

Joined: Jun 30, 2004
Posts: 6
hi all,
i've been teaching myself java for the past few months and am currently working on a project. I'm experiencing trouble adding Images to Panels.
Can someone supply a working method(technique) to Adding Images to Panels?
Below is a portion of my code:

import java.awt.*;

public class Sample extends javax.swing.JApplet implements Runnable
Image[] picture = new Image[6];
int totalPictures = 0;
int current = 0;
Panel panel1 = new Panel();
Panel panel2 = new Panel();

public void init()
for (int i = 0; i<6; i++)
String imageText = null;
imageText = getParameter("image"+i);
if (imageText != null)
picture[i] = getImage
(getCodeBase(), imageText);

GridLayout grid = new GridLayout

/**how do you add the images to the


Joe Ess

Joined: Oct 29, 2001
Posts: 9167

Teaching yourself Java, eh? Then you probably know about the Java Tutorial, right? It covers the basics on most everything, including how to use Icons to do perform simple tasks with images and how to use the 2d Graphics API to manipulate and display graphics.

[How To Ask Questions On JavaRanch]
barron logan

Joined: Jun 30, 2004
Posts: 6
thanx for the recomendations Joe Ess. Those are some pretty great tutorials...
I agree. Here's the link:
subject: How to Add Images to Panels
It's not a secret anymore!