We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › how to link class to variables textbox
Page Index Toggle Pages: 1
how to link class to variables textbox? (Read 162 times)
how to link class to variables textbox?
Dec 9th, 2008, 1:37pm
 
I would like to display the text that i've made on the following sentence

_TextBoxes[0] = new TextBox("Test", 200, 200); // First textbox placed on X,Y(200,200) with the text "Test"

in the class textbox into void display. How can I do this?
Thank you for helping!
------------------------------------------------------------
Screen screen1, screen2;
 Image[] _Images;
 ImageButton[] _ImageButtons;
 TextBox[] _TextBoxes;
 TextBoxButton[] _TextBoxButtons;
 String _Sound;

Screen current_screen;
 
void setup()
{
 size(800,600);
 smooth();
 background(255);
 /* ------------------------------Edit from here---------------------*/
 
 // Images for screen 1
 _Images = new Image[2]; // 2: How many Images are used in this screen
 _Images[0] = new Image("image1.jpg", 0, 0); // First image for screen 1 is image1.jpg placed on 0 pixels X and 0 pixels Y
 _Images[1] = new Image("image2.jpg", 100, 100);
 // ImageButtons for screen 1
 _ImageButtons = new ImageButton[1]; // 1: How many ImageButtons are used in this screen
 _ImageButtons[0] = new ImageButton("image1.jpg", 0, 0, screen2); // First image links to screen 2 (doesn't work YET)
 // Textboxes for screen 1
 _TextBoxes = new TextBox[1];
 _TextBoxes[0] = new TextBox("Test", 200, 200); // First textbox placed on X,Y(200,200) with the text "Test"
 // TextboxButtons for screen 1
 _TextBoxButtons = new TextBoxButton[1];
 _TextBoxButtons[0] = new TextBoxButton("TestLink", 300, 300, screen2);
 // Set sound for screen 1
 _Sound = "sound.mp3";
 
 // Finally Set Screen 1
 screen1 = new Screen(_Images, _ImageButtons, _TextBoxes, _TextBoxButtons, _Sound);
 
 /* ----------------------------Do not edit from here--------------*/
 
 current_screen = screen1;
}
void draw()
{
 DisplayScreen();
}

class Screen
{
 Image[] Images;

 Screen(Image[] _Images, ImageButton[] _ImageButtons, TextBox[] _TextBoxes, TextBoxButton[] _TextBoxButtons, String _Sound)
 {
    Images = _Images;
 }
 void set()
 {
   
 }
 void display()
 {
    for(int i=0; i < Images.length; i++){
      Images[i].display();
    }
 }
}
class Image
{
 int x, y;
 String file;
 Image(String ifile, int ix, int iy) {
   x = ix;
   y = iy;
   file = ifile;
 }
 void display() {
   PImage loadimage = loadImage("Images/" + file);
   image(loadimage, x, y);
 }
 
}
class ImageButton
{
 int x, y;
 String file;

 Screen screen;
 
 ImageButton(String _file, int _x, int _y, Screen _screen) {
   x = _x;
   y = _y;
   file = _file;
   screen = _screen;
 }
 void display() {
   PImage loadimage = loadImage("Images/" + file);
   image(loadimage, x, y);
 }
 // void to link Button to Screen
}
class TextBox
{
 int x, y;
 String text;
 
 TextBox(String _text, int _x, int _y) {
   x = _x;
   y = _y;
   text = _text;
 }
 void display() {
   // code to display textbox
 }
}
class TextBoxButton
{
 int x, y;
 String text;
 Screen screen;
 
 TextBoxButton(String _text, int _x, int _y, Screen _screen) {
   x = _x;
   y = _y;
   text = _text;
   screen = _screen;
 }
 void display() {
   // code to display textbox
 }
 // void to link Button to Screen
}
void DisplayScreen(){
 current_screen.display();
}






-----------------------------------------------------------
Page Index Toggle Pages: 1