Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-05-2008, 01:23 AM   PM User | #1
itgetsharder10
New to the CF scene

 
Join Date: May 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
itgetsharder10 is an unknown quantity at this point
jewl help

m trying to create an applet using jewl. i keep getting the error message: cannot find symbol-mothod setupGUI(jewl.frame). a frame is a container but i dont know how to solve this as im obviously doing something wrong. any help would be appreciated, thank you.

Code:
import jewl.*;
 
 
/**
 *  A simple calculator. It illustrates the use of textfields, fonts
 *  and buttons.
 */
public class Calculator extends Applet {
    Frame frame;
    Font font;
    IntegerField value;
    
    public void setupGUI(Container c){
    Font font = new Font("Monospaced",Font.BOLD,14);
    IntegerField value = new IntegerField (getPanel(), 10, 10, -20, 25);
    value.setFont(font);
    value.setAlignment(TextControl.RIGHT);
    //
    //  Create the buttons (using a loop to avoid repetition)
    //
    String buttons = "789+456-123*C0=/";
    for (int i = 0; i < buttons.length(); i++) {
      int x = (i % 4) * 60 + 10;
      int y = (i / 4) * 50 + 45;
      Button b = new Button (getPanel(), x, y, 50, 40,
                             "" + buttons.charAt(i),
                             buttons.charAt(i));
      b.setFont(font);
    }
}
   
    
  public static void main (String args[]) {
    Frame frame = new Frame (260, 275, "JEWL Calculator", 'Q');
    Applet d = new Calculator();
    d.setupGUI(frame);
    while(frame.isValid()) {
        char c = Window.nextCommand();
        d.handleCommand(c);
    }
    }
    
    public void createGUI() {
        setupGUI(getPanel());
    }
    //
    //  Create the frame and value field
    //
    
    //
    //  Variables to record the state of the calculation
    //
    public void handleCommand(char command){
    char    operator = '=';
    long    left     = 0;
    long    right    = 0;
    //
    //  The event loop
    //
 
    while (frame.isValid()) {
 
      //
      //  Digit key: update displayed value
      //
      if (command >= '0' && command <= '9') {
        right = right * 10 + command - '0';
        value.setLong(right);
      }
      //
      //  Clear key: reset state of calculation and displayed value
      //
      else if (command == 'C') {
        left = right = 0;
        operator = '=';
        value.setLong(0);
      }
      //
      //  Operator key: apply previous operator to left and right values.
      //  The left value and previous operator will have been set the last
      //  time an operator key was pressed. The result of the previous
      //  operation is stored in left, and the operator character is
      //  saved for next time.
      //
      else if (command != 'Q') {
        right = value.getLong();
        left = (operator == '+' ? left + right :
                operator == '-' ? left - right :
                operator == '*' ? left * right :
                operator == '/' ? left / right : right);
        operator = command;
        right = 0;
        value.setLong(left);
      }
    }
  }
}
itgetsharder10 is offline   Reply With Quote
Old 05-08-2008, 04:55 PM   PM User | #2
amitthechosen1
New Coder

 
Join Date: Aug 2007
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
amitthechosen1 is an unknown quantity at this point
hi
The error is due to the declaration:-
Code:
Frame frame = new Frame (260, 275, "JEWL Calculator", 'Q');
Applet d = new Calculator();
d.setupGUI(frame);
the object "frame" here does not belong to java.awt package but to "jewl" package.
d.setupGUI(frame) :- This is being looked up in the class jewl.Applet, but the only methods present in jewl.Applet are :-
private jewl.AppletPanel panel;
public jewl Applet;
public final AppletPanel getPanel();
public abstract void createGUI();
public abstract void handleCommand(char arg);
pubic void init();

Hence, the method that you are trying to call (d.setupGUI) is not at all there, and your code is trying to use it.
Also
Quote:
a frame is a container
But both the container and frame have been overridden in the jewl's jar file. You may check the contents of the jar file to verify the same.
amitthechosen1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:10 PM.


Advertisement
Log in to turn off these ads.