GUI Builder как вставить данные в TextArea
- Войдите на сайт для отправки комментариев
Пт, 29/08/2014 - 23:57
Здравствуйте! Хочу написать программу часы+таймер (аналог розетки с таймером) на Processing (будет стоять на RaspberryPI) +Arduino+реле -получится многофункциональная штука для умного дома (надеюсь).
Готовых решений програмки на нашел( Поскольку нуб, начну с простого. Хочу использовать GUI Builder. Есть простые часы. Собственно вопрос: как вставить данные в TextArea
https://drive.google.com/file/d/0B5R4bw54L0jMR2R4UEZoWjZGV0k/edit?usp=sharing
скретч Processing
// Need G4P library
import g4p_controls.*;
DigitalClock digitalClock;
public void setup(){
size(480, 320, JAVA2D);
createGUI();
customGUI();
// Place your setup code here
digitalClock = new DigitalClock(40, width/2, height/2+15);
}
public void draw(){
background(230);
digitalClock.getTime();
digitalClock.display();
}
class DigitalClock extends Clock {
int fontSize;
float x, y;
DigitalClock(int _fontSize, float _x, float _y) {
fontSize = _fontSize;
x = _x;
y = _y;
}
void getTime() {
super.getTime();
}
void display() {
textSize(fontSize);
textAlign(CENTER);
text (h + ":" + nf(m, 2) + ":" + nf(s, 2), x, y);
}
}
class Clock {
int h, m, s;
Clock() {
}
void getTime() {
h = hour();
m = minute();
s = second();
}
}
// Use this method to add additional statements
// to customise the GUI controls
public void customGUI(){
}
GUI (oт билдера)
* use lines between the matching comment tags. e.g.
void myBtnEvents(GButton button) { //_CODE_:button1:12356:
// It is safe to enter your event code here
} //_CODE_:button1:12356:
* Do not rename this tab!
* =========================================================
*/
public void textarea1_change1(GTextArea source, GEvent event) { //_CODE_:textarea1:690112:
println("textarea1 - GTextArea >> GEvent." + event + " @ " + millis());
} //_CODE_:textarea1:690112:
// Create all the GUI controls.
// autogenerated do not edit
public void createGUI(){
G4P.messagesEnabled(false);
G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
G4P.setCursor(ARROW);
if(frame != null)
frame.setTitle("Sketch Window");
textarea1 = new GTextArea(this, 47, 21, 320, 80, G4P.SCROLLBARS_NONE);
textarea1.setOpaque(true);
textarea1.addEventHandler(this, "textarea1_change1");
}
// Variable declarations
// autogenerated do not edit
GTextArea textarea1;
Заранее спасибо) А если кто нибудь поможет реализовать програмку целиком (только Processing, с малинкой я сам)), то готов потратить некоторую сумму денег...
Один этап осилил) Другая програмка работает. TextArea и все что с ним связано вставляется в основной скретч
// Need G4P library import g4p_controls.*; public void setup(){ size(480, 320, JAVA2D); createGUI(); customGUI(); // Place your setup code here //size(240, 240); PFont font; font = loadFont("Tahoma-44.vlw"); textFont(font, 30); } public void draw(){ background(30); int d = day(); // Values from 1 - 31 int mo = month(); // Values from 1 - 12 int y = year(); // 2003, 2004, 2005, etc. int s = second(); // Values from 0 - 59 int m = minute(); // Values from 0 - 59 int h = hour(); // Values from 0 - 23 String so = String.valueOf(d); text(so, 10, 30); // vysota, dlina so = String.valueOf(mo); text(so, 50, 30); so = String.valueOf(y); text(so, 80, 30); String h1 = String.valueOf(h); //text(h1, 10, 70); // vysota, dlina String m1 = String.valueOf(m); //text(m1, 50, 70); String s1 = String.valueOf(s); // text(s1, 100, 70); label1.setText(""); label1.setText(h1+" : " +m1+" : "+s1); textarea1.setText(""); textarea1.setText(h1+" : " +m1+" : "+s1);