Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
Author

How to Add Images to Panels

barron logan
Greenhorn

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)
{
totalPictures++;
picture[i] = getImage
(getCodeBase(), imageText);
}
else
break;
}


GridLayout grid = new GridLayout
(1,2,10,10);

setLayout(grid);
/**how do you add the images to the
*panels???
*/

add(Panel1);
add(Panel2);



advTHANKSance
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
barron logan
Greenhorn

Joined: Jun 30, 2004
Posts: 6
thanx for the recomendations Joe Ess. Those are some pretty great tutorials...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Add Images to Panels