This is my skeleton of my very basic computing project, which is to create a spelling test displaying twenty questions:

//
//  spell_test.java
//  spell_test
//
//  Created by chocobo74 on 21/09/2004.
//  Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//  A simple Java applet
//

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class TrivialApplet extends Applet implements ActionListener {

private Button beuts, boots, bootz, bots, next_q;
private Image image1, image2, image3, image4, image5;
private AudioClip sound1, sound2;
private int choice;

public void init () {
Label title1;
title1= new Label ("How do you spell a pair of rather large shoes?");

				add(title1);
				
                image1=getImage (getDocumentBase(), "beuts.jpg");
                beuts = new Button ("beuts");
                add(beuts);
                beuts.addActionListener(this);
                
                image2=getImage (getDocumentBase(), "boots.jpg");
                boots = new Button ("boots");
                add(boots);
                boots.addActionListener(this);
                
                image3=getImage (getDocumentBase(), "bootz.jpg");
                bootz= new Button ("bootz");
                add(bootz);
                bootz .addActionListener(this);
               	
               	image4=getImage (getDocumentBase(), "bots.jpg");
                bots= new Button ("bots");
                add(bots);
                bots.addActionListener(this);
                
                next_q = new Button ("Next Question");
                add(next_q);
                next_q.addActionListener(this);
                
                image5=getImage (getDocumentBase(), "these.jpg");
                
                sound1=getAudioClip(getDocumentBase(),"spam_song.au");
                sound2=getAudioClip(getDocumentBase(),"doh.au");
//these declare the buttons, images and sounds to be used//

                }
                
  public void paint (Graphics g)  {
 
 g.drawImage(image5,0,10,100,150,this);
 
 if (choice == 1){ //this method declares what will happen when the user chooses a button//
 g.drawImage(image1,200,70,100,150,this);
 g.drawString ("Incorrect answer!",250,60);
 sound2.play();
 sound1.stop();
}
 
if (choice == 2){
g.drawImage(image2,200,70,100,150,this);
g.drawString ("Correct answer!",250,60);
sound1.play();
sound2.stop();
 }
 
  if (choice == 3){ 
  g.drawImage(image3,200,70,100,150,this);
  g.drawString ("Incorrect answer! ",250,60);
  sound2.play();
  sound1.stop();
 } 
  
  if (choice == 4){
  g.drawImage(image4,200,70,100,150,this);
   g.drawString ("Incorrect answer!",250,60);
   sound2.play();
   sound1.stop();
  }
  
   if (choice == 5){
  g.drawString("go to next question",250,60);
		}
		}

public void actionPerformed(ActionEvent event) {

                if (event.getSource () == beuts) 
                       choice=1;
                if (event.getSource () == boots)  // if user presses a button,this method declares their choices//
                       choice=2;
                if (event.getSource () == bootz) 
                       choice=3;
                if (event.getSource () == bots) 
                       choice=4;
                if (event.getSource () == next_q) 
                       choice=5;
                
                                      
                                     
    repaint();
                        
                        
   }
   
   }

I've tried using the repaint method to redraw the screen and wish to create a window with four new buttons, images and sounds for the next question. I will also shortly be adding arrays (which i know how to do) but how do i create a new window? Also tried WindowListener closing window method, got an error in Metrowerks Code Warrior 3.2 for Mac OS 9.2.1. Any suggestions?

couldnt you make a new frame and just hide the one that called the new frame ??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.