Is there no solution to this problem or is it something happening on my installation only. I had no replies on my earlier post and I need to solve this problem. I am running Windows7 64 bit and my processing version is 1.5 I installed a jre and jdk.
Will anybody let me know how to fix and at least let me know if this is an exception or if it is quite common.
Quote
I have a problem with export application. I can succesfully export a sketch as application but as soon as as I try to add "import processing.serial.*" I get an error when I try to export. The error says "could not copy source file:". If I take the same sketch then and just comment out "import processing.serial.*" it exports just fine.
I managed to get the code not to crash with any key press except for cancel escape and the small cross on the input dialog.
Will anybody please help on that? Is there a unicode character corresponding to these keys so I can filter it or can I disable them or is there a way to display a userinput dialog without a cancel button?
Thanks
Bertus
import javax.swing.JOptionPane;//For user input dialogs
boolean isInteger;
String y = "0";
class Button {
int x, y; // The x- and y-coordinates
int size; // Dimension (width and height)
color baseGray; // Default gray value
color overGray; // Value when mouse is over the button
color pressGray; // Value when mouse is over and pressed
boolean over = false; // True when the mouse is over
boolean pressed = false; // True when the mouse is over and pressed
Button(int xp, int yp, int s, color b, color o, color p) {
x = xp;
y = yp;
size = s;
baseGray = b;
overGray = o;
pressGray = p;
}
// Updates the over field every frame
void update() {
if ((mouseX >= x) && (mouseX <= x+size) &&
(mouseY >= y) && (mouseY <= y+size)) {
over = true;
} else {
over = false;
}
}
boolean press() {
if (over == true) {
pressed = true;
return true;
} else {
return false;
}
}
void release() {
pressed = false; // Set to false when the mouse is released
}
void display() {
if (pressed == true) {
fill(pressGray);
} else if (over == true) {
fill(overGray);
} else {
fill(baseGray);
}
stroke(255);
rect(x, y, size, size);
}}
Button button1, button2, button3;
int mode = 0;
void setup() {
frameRate (2);
size(100, 100);
smooth();
color gray = color(204);
color white = color(255);
color black = color(0);
button1 = new Button(10, 80, 10, gray, white, black);
}
void draw(){
frameRate (2);
background(204);
manageButtons();
noStroke();
fill(0);
isInteger = true;
int y1 = 100;
if (mode == 1) {
y = JOptionPane.showInputDialog(null,
"Enter new setpoint (0 to 120):",
"Setpoint adjustment",
JOptionPane.PLAIN_MESSAGE);}
if (y == null) {
isInteger = false;
} int length = y.length();
if (length == 0) {
isInteger = false;
}
int i = 0;
if (length == 1) {
if (y.charAt(0) == '-') {
isInteger = false;
}
i = 0;
}
for (; i < length; i++) {
char c = y.charAt(i);
if (c <= '/' || c >= ':') {
isInteger = false;
}
}
mode = 0;
if(isInteger == true){
y1 = Integer.parseInt(y);}
else{println(" Not integer");}
println(y1);
}
void manageButtons() {
button1.update();
button1.display();
}
void mousePressed() {
if (button1.press() == true) { mode = 1; }
}
void mouseReleased() {
button1.release();
}
Hi all
Can anybody please help with this code?
Why can't the code in line 96 "println(y1);" not see the code in line 95 and how can I solve that?
Thanks
Bertus
import javax.swing.JOptionPane;//For user input dialogs
boolean isInteger;
String y = "0";
class Button {
int x, y; // The x- and y-coordinates
int size; // Dimension (width and height)
color baseGray; // Default gray value
color overGray; // Value when mouse is over the button
color pressGray; // Value when mouse is over and pressed
boolean over = false; // True when the mouse is over
boolean pressed = false; // True when the mouse is over and pressed
Button(int xp, int yp, int s, color b, color o, color p) {
x = xp;
y = yp;
size = s;
baseGray = b;
overGray = o;
pressGray = p;
}
// Updates the over field every frame
void update() {
if ((mouseX >= x) && (mouseX <= x+size) &&
(mouseY >= y) && (mouseY <= y+size)) {
over = true;
} else {
over = false;
}
}
boolean press() {
if (over == true) {
pressed = true;
return true;
} else {
return false;
}
}
void release() {
pressed = false; // Set to false when the mouse is released
}
void display() {
if (pressed == true) {
fill(pressGray);
} else if (over == true) {
fill(overGray);
} else {
fill(baseGray);
}
stroke(255);
rect(x, y, size, size);
}}
Button button1, button2, button3;
int mode = 0;
void setup() {
frameRate (2);
size(100, 100);
smooth();
color gray = color(204);
color white = color(255);
color black = color(0);
button1 = new Button(10, 80, 10, gray, white, black);
}
void draw(){
frameRate (2);
background(204);
manageButtons();
noStroke();
fill(0);
isInteger = true;
if (mode == 1) {
y = JOptionPane.showInputDialog(null,
"Enter new setpoint (0 to 120):",
"Setpoint adjustment",
JOptionPane.PLAIN_MESSAGE);}
if (y == null) {
isInteger = false;
} int length = y.length();
if (length == 0) {
isInteger = false;
}
int i = 0;
if (length == 1) {
if (y.charAt(0) == '-') {
isInteger = false;
}
i = 0;
}
for (; i < length; i++) {
char c = y.charAt(i);
if (c <= '/' || c >= ':') {
isInteger = false;
}
}
mode = 0;
if(isInteger == true){
int y1 = Integer.parseInt(y);}
println(y1); //This line
Hi all.
Trying to get a userinput dialog to work in processing. Everything work but when the user leaves the field blank or enter another value except an integer which I then convert with parse my code freezes and I get an error on my parse statement. Also I would like to restrict input to only numbers between 0 and 120 The error I'm getting is "NumberFormatException: For input string:"
Thanks
Bertus
I bought a 2560 mega board for a big project. I installed StandardFirmata on the board because I want to do all controlling from my laptop. The problem I have is that analog pins 6 to15 don't return any values. I have ten analog sensors on pin 0 to 9 and pins 0 to 5 return a value for me but pins 6 to 15 don't. All my digital pins work as well as I have tested them as outputs and they turn a led on and off. the problem is just on the analog pins. I don't understand this because if the software thought that it was a board with less analog pins then there would have been less digital pins as well and I would have had a problem with them as well. I spend two days now looking for the reason but I am beaten. Can anybody help please?