Hey, i've done a lot of stuff with java in the pass but i'm new in building programs for BlackBerry.
Basically i've been only practicing on the last few days, just to learn and then start my actual program.
The thing is, i got stuck in one problem and i can't solve it, in any way
Here's my code until now(i'll explain what it does after the code):
Quote:
package com.rim.samples.device.spellcheckdemo;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
class Work extends UiApplication {
public static void main(String[]args) {
Work n = new Work();
n.enterEventDispatcher();
}
Work() {
pushScreen(new WorkScreen());
}
}
class WorkScreen extends MainScreen {
EditField name;
public WorkScreen() {
super();
LabelField title = new LabelField("Program Alpha", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new RichTextField("Hello"));
name = new EditField("Name: ", "");
name.setChangeListener(new EditListener());
add(name);
ButtonField go = new ButtonField("Go!");
go.setChangeListener(new ButtonListener());
RadioButtonGroup rgrp = new RadioButtonGroup();
RadioButtonField radio = new RadioButtonField("Good?", rgrp, true);
RadioButtonField radio2 = new RadioButtonField("Bad?", rgrp, false);
RadioButtonField radio3 = new RadioButtonField("DM", rgrp, false);
add(radio);
add(radio2);
add(radio3);
add(go);
}
public boolean OnClose() {
Dialog.alert("OH NOES");
System.exit(0);
return true;
}
}
final class EditListener implements FieldChangeListener {
Field now;
public void fieldChanged(Field field, int context) {
Field now = field;
}
}
final class ButtonListener implements FieldChangeListener {
Field name;
public ButtonListener() {
}
public void UpdateName(Field n) {
name = n;
}
public void fieldChanged(Field field, int context) {
ButtonField btn = (ButtonField) field;
Status.show("Your name: "+name);
}
}
|
Sorry if the HTML format destroyed the code :(
but anyways...
like i said, this is a program that would just help me to understand the new stuff, and remember the old java stuff
when you execute it, it rolls like a normal program in this format:
"Hello.
Name:
[o] Good?
[ ] Bad?
[ ] DM
GO!
Name is an EditField where the person can write their name right after the "Name: "
Good bad and DM are a group of radiobuttons inside rgrp
Go! is a normal button.
Until now i got that when you click "Go!" it will appear a message saying "Your name: null".
That because i never found a way that i could check the EditField, since it's in another class...i tryed all the ways i could think in my head, creating a listener for the editfield, to keep track of the actual real EditField, but in the end i could never send it to the Button class, so that the name would appear witht he "Your name: ". this is my first question, if anyone has any idea of how can i make that...
and since i'm here, i'm gonna just ask this other question, that it kinda has to do with the other one
i wanted also to check which of the radiobuttons is true...and make if statements with that inside the Buttonlistener.
If anyone could help me i would appreciate it!