Results 1 to 7 of 7
- 07-10-2010, 12:36 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 5
- Rep Power
- 0
My program complied nicely but there is error when running
I am using netbean 6.8 and has not problem compiling...somehow, once start, it gives me this error..
Not able to submit breakpoint MethodBreakpoint [Calculator].jblnit '()Lvoid;', reason: Method 'jblnit' with signature '()Lvoid;' does not exist in class Calculator.
below are my code..
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.ChoiceGroup;
public class Calculator extends MIDlet implements CommandListener{
private StringItem st, output;
private Command exit = new Command("Exit", Command.EXIT,0);
private Command menu = new Command("Menu", Command.SCREEN,1);
private int answer=0, x1, x2;
private TextField input1, input2;
private String ope[] = new String[]{"+", "-", "*", "/"};
private ChoiceGroup ch = new ChoiceGroup("Select operation:",ChoiceGroup.EXCLUSIVE,ope,null);
public void startApp() {
Form mycalculator = new Form("Welcome to 'My Calculator'");
Alert alertmsg = new Alert("WELCOME", "ENJOY USNG THIS CALCULATOR",null,AlertType.CONFIRMATION);
st = new StringItem(null,"Welcome ! This calculator allows you to do addition(+),substraction(-), multiplication(*) and division(/)");
input1 = new TextField("Enter your first number :","",15,TextField.NUMERIC);
input2 = new TextField("Enter your second number :","",15,TextField.NUMERIC);
mycalculator.append(st);
Display.getDisplay(this).setCurrentItem(st);
mycalculator.append(input1);
mycalculator.append(ch);
mycalculator.append(input2);
mycalculator.append(output);
alertmsg.setTimeout(Alert.FOREVER);
mycalculator.addCommand(exit);
mycalculator.addCommand(menu);
mycalculator.setCommandListener(this);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d){
if(c == menu){
x1=Integer.parseInt(input1.getString());
x2=Integer.parseInt(input2.getString());
int operation = ch.getSelectedIndex();
switch(operation){
case 0: answer = x1 + x2;
output.setText("Answer = "+answer);
break;
case 1: answer = x1 - x2;
output.setText("Answer = "+answer);
break;
case 2: answer = x1 * x2;
output.setText("Answer = "+answer);
break;
case 3: answer = x1 / x2;
output.setText("Answer = "+answer);
break;
}
}
}
}Last edited by ryanlcc; 07-10-2010 at 01:19 PM.
- 07-10-2010, 01:11 PM #2
Where is this method defined? The JVM can't find it to call it.Method 'jblnit'
- 07-10-2010, 01:15 PM #3
Member
- Join Date
- Jul 2010
- Posts
- 5
- Rep Power
- 0
Very sorry...I am still newbie here..Perhaps, a noob...
is it
public jblnit() {
}
- 07-10-2010, 01:21 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,392
- Blog Entries
- 7
- Rep Power
- 17
Chinese is not your native language is it? Good, because the message above is not in Chinese. What part of it didn't you understand and what caused it that you blindly dumped your code in here? Did it ever occur to you that reading (parts of) a manual might help?
kind regards,
Jos
- 07-10-2010, 01:24 PM #5
You'll have to read the API doc to see how and where that method is used for.is it
public jblnit() {
}
Your code shows the syntax for a constructor not a method.
- 07-10-2010, 05:26 PM #6
Member
- Join Date
- Jul 2010
- Posts
- 5
- Rep Power
- 0
i have corrected my code but still giving the same problem...
with the error message
Attaching to localhost:56070
Not able to submit breakpoint FieldBreakpoint MyCalculator.cg, reason: The target VM does not support field access breakpoints.
Not able to submit breakpoint FieldBreakpoint MyCalculator.ope, reason: The target VM does not support field access breakpoints.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.CommandListener;
/**
* @author RyanLCC
*/
public class Midlet_1 extends MIDlet implements CommandListener{
private Display d;
private Form mycalculator;
private StringItem st, output;
private Command exit = new Command("Exit", Command.EXIT,0);
private Command menu = new Command("Menu", Command.SCREEN,1);
private int answer=0, x1, x2;
private TextField input1, input2;
private String ope[] = new String[]{"+", "-", "*", "/"};
private ChoiceGroup ch = new ChoiceGroup("Select operation:",ChoiceGroup.EXCLUSIVE,ope,null);
public Midlet_1(){
mycalculator = new Form("Welcome to 'My Calculator'");
Alert alertmsg = new Alert("WELCOME", "ENJOY USNG THIS CALCULATOR",null,AlertType.CONFIRMATION);
st = new StringItem(null,"Welcome ! This calculator allows you to do addition(+),substraction(-), multiplication(*) and division(/)");
input1 = new TextField("Enter your first number :","",15,TextField.NUMERIC);
input2 = new TextField("Enter your second number :","",15,TextField.NUMERIC);
mycalculator.append(st);
mycalculator.append(input1);
mycalculator.append(ch);
mycalculator.append(input2);
mycalculator.append(output);
alertmsg.setTimeout(Alert.FOREVER);
mycalculator.addCommand(exit);
mycalculator.addCommand(menu);
mycalculator.setCommandListener(this);
}
public void startApp() {
d= Display.getDisplay(this);
d.setCurrent(mycalculator);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d){
if(c == menu){
x1=Integer.parseInt(input1.getString());
x2=Integer.parseInt(input2.getString());
int operation = ch.getSelectedIndex();
switch(operation){
case 0: answer = x1 + x2;
output.setText("Answer = "+answer);
break;
case 1: answer = x1 - x2;
output.setText("Answer = "+answer);
break;
case 2: answer = x1 * x2;
output.setText("Answer = "+answer);
break;
case 3: answer = x1 / x2;
output.setText("Answer = "+answer);
break;
}
}
}
}
- 07-10-2010, 05:35 PM #7
Similar Threads
-
my program is running bit slow!!
By Arn00p in forum AWT / SwingReplies: 18Last Post: 05-05-2010, 04:14 PM -
Program running indefinitely
By bayan in forum New To JavaReplies: 2Last Post: 04-27-2010, 09:22 AM -
Running a Java Program
By Valkyrie in forum New To JavaReplies: 13Last Post: 11-05-2009, 03:43 AM -
Error running java program using URL
By gio123bg in forum New To JavaReplies: 6Last Post: 06-30-2009, 06:26 PM -
error running java program
By bdasilva in forum New To JavaReplies: 1Last Post: 06-29-2009, 01:46 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks