Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2004, 01:19 AM   PM User | #1
weblearner
New to the CF scene

 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
weblearner is an unknown quantity at this point
java help

im really stuck its a game i have to make nothing too hard if yu know what u are doin but im a lil stuck on a specific bit.

CODE
package mypackage6;
import java.applet.Applet;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Panel;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.Button;
import java.awt.BorderLayout;

public class puzzleapplet extends Applet
{


private Image[] imageArray; // the array of images
private int numImages; // number of images in the array
private int imageIndex; // holds the index of the image to be displayed

private Panel[] panelArray; // the array of panels
private int numPanels; // number of panles in the array


Panel boardPanel; // panel to hold the cells (i.e. the board)
private GridLayout gridLayout1;

public void init() {
try {
jbInit();
numImages = 6;
numPanels = 7;
imageIndex = 0;
loadImages();
} catch(Exception e) {
e.printStackTrace();
}
} // end init()

public puzzleapplet()
{
}

private void loadImages(){

imageArray = new Image[numImages];

for(int i = 0; i < numImages; i++) {
imageArray[i] = getImage(getCodeBase(), "images/" + "puzzle" + (i+1) + ".jpg");
}
} // end loadImages()

private void loadPanels(){

panelArray = new Panel[numPanels];

} // end loadImages()

public void paint(Graphics g) {

g.drawImage(imageArray[imageIndex], 0, 50, this);
g.drawImage(imageArray[imageIndex], 200, 50, this);

} // end paint()


public void start()
{
}

public void stop()
{
}

public void destroy()
{
}

private void jbInit() throws Exception {


boardPanel = new Panel(); // creates a new panel
gridLayout1 = new GridLayout(); // and an instance of GridLayout
gridLayout1.setColumns(7); // with 7 columns

this.setSize(new Dimension(534, 300));
boardPanel.setLayout(gridLayout1); // and set the layout of boardPanel to be GridLayout
this.add(boardPanel, BorderLayout.CENTER);






}

}


that is the code i have so far i want to be abel to put one of the images onto a panel but how?
weblearner is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:40 PM.


Advertisement
Log in to turn off these ads.