We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone, I write a program that has one main window which displayed letters on it, if the letters form a word a 2nd frame will be opened displaying an image. The problem that I face is when i close the 2nd frame and i want to return back to the main one it seems freeze. I can't do any thing there while the program is still working "I can know that from the console" . What I need is to clear the 1st window and continue displaying letters.
This is the setup for the main window
void setup()
{
//size(screen.width,screen.height);
size(640,480);
noStroke();
fill(0);
frameRate(30);
noLoop();
hint(ENABLE_NATIVE_FONTS);
font = createFont("Arial", 30);
scale_factor = height/table_size;
// we create an instance of the TuioProcessing client
// since we add "this" class as an argument the TuioProcessing class expects
// an implementation of the TUIO callback methods (see below)
tuioClient = new TuioProcessing(this);
wordImag = loadImage("catImage.jpg");
wordImag2 = loadImage("actImage2.png");
wordImag3 = loadImage("batImage.png");
wordImag4 = loadImage("tabImage.png");
wordImag5 = loadImage("fatImage.jpg");
minim = new Minim(this) ;
au_player1 = minim.loadFile("Alert.wav") ;
}
This is the 2nd frame code
public class secondApplet extends PApplet {
public void setup() {
size(400, 400, P3D);
frameRate(30);
noLoop();
}
public void draw() {
fill(0);
if (word==1)
{
image(wordImag, 0, 0);
noLoop();
}
else
if (word ==2)
{
image(wordImag2, 0, 0);
noLoop();
}
else
if (word ==3)
{
image(wordImag3, 0, 0);
noLoop();
}
else
if (word ==4)
{
image(wordImag4, 0, 0);
noLoop();
}
else
if (word == 5)
{
image(wordImag5, 0, 0);
noLoop();
}
}
}
public class PFrame extends JFrame {
public PFrame() {
setBounds(0, 0, 350, 380);
s = new secondApplet();
//s.setLocation(0,0);
add(s);
s.init();
show();
//noLoop();
stop();
}
}
Answers
You have noLoop(); and no draw() method in the main applet. A sketch must have its own draw method and be looping if it is to respond to events.
http://forum.processing.org/two/discussion/7036/multiple-screens
I have a draw method but i didn't post it. Thanks GoToLoop for sharing the like but i don't like to use the G4 library. Here is the whole code of my application
the program works fine but the problem is the window if the 2nd window opened to view a picture the first window looks freeze so i can't continue the game unless i restart the program. PLEASE advise me on that I've been stuck on this problem for more that 2 weeks. Thanks in advance
... but I don't like to use the G4 library.
G4? Is it G4P anyways? Nevertheless, that link is about instantiating multiple sketches w/o any library import! >:/
There's no
import
present in my sketch example there! [-(