Can anyone point the errors made on my code?

I want to write a java Applet that implements a Graphical User Interface(GUI) from the the AWT package(not SWING package) to display a Pie Chart. The program should read a string from the user, then determine and display a Pie Chart that represents the percentage of vowels(a,e,i,o,u), consonants and others lettres in that string.
This is just the interface design. I get an error where i set up the border for the TextArea, and I can only get the button and the TextArea to display is I add the "South" and "North" respectively, while the recganglt won't even show up. Why? Anyone?
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
public class PieChart extends Applet implements ActionListener
     private PieCanvas canvas;
     Button pro;
     Panel buttonPanel;
     Color back, colorV, colorC, colorO;
     String c1, c2, c3;
     public void init()
          String in =getParameter("background");
          c1 =getParameter("vowelColor");
          c2 =getParameter("consonantColor");
          c3 =getParameter("otherColor");
          back =Color.black;
          colorV = Color.red;
          colorC = Color.yellow;
          colorO = Color.green;
          if(in!=null)
          back =Color.decode(in);
          setLayout(new BorderLayout());
          setBackground(back);
          canvas =new PieCanvas();
          buttonPanel =new Panel();
          setLayout(new BorderLayout());
          pro =new Button("Process");
          buttonPanel.add(pro);
          pro.addActionListener(this);
          JTextArea textArea =new JTextArea("This is an editable JTextArea " + "that has been initialized with the setText method. " +
               "A text area is a \"plain\" text component, " +
               "which means that although it can display text " + "in any font, all of the text is in the same font.", 5, 40);
textArea.setFont(new Font("Serif", Font.ITALIC, 16));
          textArea.setLineWrap(true);
          textArea.setWrapStyleWord(true);
          JScrollPane areaScrollPane =new JScrollPane(textArea);
          areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
          areaScrollPane.setPreferredSize(new Dimension(10, 50));
          areaScrollPane.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
          add("North", textArea);
          add("Center", canvas);
          add("South", buttonPanel);
     /*public void actionPerformed(ActionEvent event)
          if(event.getSource()==pro)
               canvas.repaint();
               canvas.shape="rect";
               canvas.shapename="A Rectangle...";
               canvas.shapecolor=c1;
class PieCanvas extends Canvas
     public String shape="";
     public String shapename="";
     public String shapecolor="";
     public final int MAX_WIDTH = 300;
     public void paint(Graphics g)
          g.drawRoundRect(70,10,70,50,20,7);
          /*int x, y;
          if(shape.equals("rect"))
               if(shapecolor!=null)
                    g.setColor(Color.decode(shapecolor));
               else
               g.setColor(Color.blue);
               g.drawRect(MAX_WIDTH/4, MAX_WIDTH/4, MAX_WIDTH/2, MAX_WIDTH/4);
               g.setColor(Color.white);
               g.drawString(shapename, MAX_WIDTH/4, MAX_WIDTH/8);*/
}

Okay, let's go through Error Identification for Dummies.
1. Compile the program. Does this produce error messages? If so, what are they?
2. Run the program. Does this throw exceptions? If so, what are they? Post the stack trace.
3. If it runs without exception, does it do what you want it to do? If not, what did you want and what did it do? Be precise.

Similar Messages

  • Can anyone spot the error in this script for iTunes?

    This AppleScript is designed to copy the Name and Artist of an iTunes track, then populate the Album Artist field with both, separated with an oblique. But when I run the script in iTunes, it only pastes the Artist name in to the Album Artist field and not the whole string.
    tell application "iTunes"
    if selection is not {} then -- if tracks are selected...
    set sel to selection
    set numTracks to (length of sel)
    set s to "s"
    if numTracks is 1 then set s to ""
    display dialog "Adds the name of the track and the name of the artist to the Album Artist field." & return & return & (numTracks & " track" & s & " selected.") buttons {"Cancel", "Continue"} default button 2 with title "Create Album Artist" giving up after 30
    if gave up of result is true then return
    repeat with t from 1 to numTracks
    tell contents of item t of sel
    set {album artist} to ({get artist} & " / " & {get name})
    end tell
    end repeat
    else
    display dialog "No tracks have been selected." buttons {"Cancel"} default button 1 with icon 0 giving up after 30
    end if -- no selection
    end tell

    Hello
    Try -
    tell item t of sel
    set album artist to (get artist) & " / " & (get name)
    end tell
    instead of -
    tell contents of item t of sel
    set {album artist} to ({get artist} & " / " & {get name})
    end tell
    In your original code, the left and right value of assignment are both list, i.e. -
    left value = {album artist}
    right value = {get artist, "/", get name}
    Consequently 'album artist' is assigned to the 1st item of the list at right, which is the result of 'get artist'.
    In order to avoid this, don't use list assingment, which is not necessary at all here.
    Also, I think you may just tell item t of sel, not contents of item t of sel.
    Hope this may help,
    H

  • Can't find the error on this small code :S

    Hi , i've just compiled this code and i can't find what is wrong! :(
    The compiler is ok, but the output print its not what i was expect.
    If u insert 121 (capicua) the answer is: This number its not a capicua :S
    what is wrong?
    thanks!!
    Note: Don't create another code plz.
    import java.io.*;
    public class Capicua {
         public static void main (String[] args) throws Exception {
              int digit, num;
              int inverted = 0;
                   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                   System.out.print(" Insert number: ");
                   num=Integer.parseInt(br.readLine().trim());
                   while(num > 0) {
                   digit = num % 10;
                   num = num /10;
                   inverted = inverted * 10 + digit;
                   if(num == inverted) {
                        // to be capicua the number inserted must
                        //be equals to the inverted
                        System.out.println("Its Capicua!");      
                   }else{
                        System.out.println("This number is not a Capicua!");
    }

    Please use code tags (see button above posting box) when posting code. It makes it much easier to read.
    So, it appears that capicua means palindrome--the number reads the same backwards and forwards. Is that correct?
    There are ways of doing this without converting the 121 to a number, but I won't explain that unless you want.
    I think your problem is this line:
    if (num == inverted)
    You have changed "num" within your while loop. Therefore, num is no longer the original input 121.
    Try adding println statements like this to watch what happens:
    while(num > 0) {
      digit = num % 10;
      num = num /10;
      inverted = inverted * 10 + digit;
      System.out.println("digit = " + digit);
      System.out.println("num = " + num);
      System.out.println("inverted = " + inverted);
    }

  • How to see the changes made in tx code MN05

    Hi all,
    Do you know how can I see the changes made in tx code MN05?
    I need to know when was The output condition updated? Do you have a change record on this change?
    Thanks and regards

    Hi,
    There is a Transaction code SCU3 to display the change logs
    Goto the Transaction code and enter the  Table for MN05 and execute, it will display all the logs for MN05.
    If you didnt find any change logs here, then you have to activate the Change logs for this table.
    To activate the change logs , goto SE11 and give the table and clcik on the technical settings and you will find the Check box with CHANGE LOGS.
    Check whether it was activated or not, if not activate it.
    Thanks,
    santosh

  • I can't rate or write a review for app on the app store. It allows me to write out the review but does not diplay my review after sending it. Can anyone point me in the right direction to get answer as apply refuse to reply or solve my problem. Thanks

    I can't rate or write a review for app on the app store. It allows me to write out the review but does not diplay my review after sending it. Can anyone point me in the right direction to get answer as apply refuse to reply or solve my problem. Ps thanks apple for ur ignorance

    I have the same problem with another TeamLava app, Fashion Story.

  • Can anyone point me in the right direction for the link to download Acrobat 9 Standard?  I found the link to download 9 Pro but not standard.  Old computer crashed and new computer does not have a CDR/DVD rom drive.

    Can anyone point me in the right direction for the link to download Acrobat 9 Standard.  I found the link to download 9 Pro but not standard.  Old computer crashed and new computer does not have a CDR/DVD rom drive.

    Hi,
    Standard or Pro would be licensed through your serial number, the download link and downloaded file would be the same for both of them.
    Pro or Standard would be determined after you put in your serial number.
    Download Acrobat products | 9, 8
    Thank You
    Arjun

  • I'm trying to delete multiple pix in iPhoto that i stupidly made duplicates of without knowing, I've tried going into the applications folder and using image capture but i think I've missed a step , can anyone send the correct info / steps pls thanks

    I'm trying to delete multiple pix in iPhoto that i stupidly made duplicates of without knowing, I've tried going into the applications folder and using image capture but i think I've missed a step , can anyone send the correct info / steps pls thanks

    again image capture is not involved with deleting photos from iPhoto in any way ever
    the paid version of iPhoto Library Manager is very good for finding duplicates as is Duplicate Annihilator
    And I have no idea who told you this - or what it means - but re-read both of my opening statements
    I was told I could delete multpiles thru image capture by transferring my iPhoto library etc
    LN

  • I recently deleted approximately 80gb of space on my hard drive by dragging items to the trash and then emptying the trash.  However, the space does not show up on my HD as free. Can anyone point me in the right direction?

    I recently deleted approximately 80gb of space on my hard drive by dragging items to the trash and then emptying the trash.  However, the space does not show up on my HD as free. Can anyone point me in the right direction?

    If you are using File Vault, turn it off.  To find out where all the extra space is use any of these products - Disk Inventory X
    OmniDiskSweeper
    WhatSize
    SpaceControl

  • I have an older airport express but don't know where to look to find its model number.  The version number is airport utility 6.3.4 (634.17).  Can anyone point me in the right direction?  Thanks.

    I have an older airport express, but don't know where to look to find its model number. 
    The version number is airport utility 6.3.4 (634.17). 
    Can anyone point me in the right direction?  Thanks.

    Hard to see it's so teeny. I needed a magnifying glass.
    FWIW, you should not mark your reply as Solved because you did not solve your question. Helpful and Solved are used to reward the user who help you or solved your problem.

  • Can anyone spot the syntax error?

    I've been looking at this for about a day now and can't see the error, which is:
    Insert Failed: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
      public String addSaleList(SaleList sL) {
        try {
          //Gets the connection to customer database.
          Class.forName(Driver);
          Connection myCon = DriverManager.getConnection(Url);
          System.out.println(sL.saleListID + " " + sL.saleID + " " + sL.product
                             + " " + sL.number);
          String sqlQry = "INSERT INTO salelist(saleID, product, number)" +
              "VALUES(?,?,?)";
          PreparedStatement myStmt = myCon.prepareStatement(sqlQry);
          myStmt.setInt(1, sL.saleID);
          myStmt.setString(2, sL.product);
          myStmt.setInt(3, sL.number);
          myStmt.executeUpdate();
          return "Sale confirmed";
        catch (Exception e) {
          System.out.println("Insert Failed: " + e);
          return ("Insert Failed: " + e);
      public class SaleList {
        public int saleListID;
        public int saleID;
        public String  product;
        public int  number;
        public SaleList(int saleListID, int saleID, String product, int number) {
          this.saleListID = saleListID;
          this.saleID = saleID;
          this.product = product;
          this.number = number;
      SaleList saleL = new SaleList(0,10,"b",2);
      lblStatus.setText(sM.addSaleList(saleL));

    Hey this is the stack trace:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3150)
         at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execut(JdbcOdbcPreparedStatement.java:214)
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdateJdbcOdbcPreparedStatement.java:136)
         at myproject.SaleModel.addSaleList0 120 a 1
    (SaleModel.java:69)
         at myproject.SalesGUI.actionPerformed(SalesGUI.java:395)
         at java.awt.Button.processActionEvent(Button.java:382)
         at java.awt.Button.processEvent(Button.java:350)
         at java.awt.Component.dispatchEventImpl(Component.java:3615)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

  • Can anyone explain the functionality of FM f4ut_parameter_get_values ?

    Can anyone explain the functionality of FM f4ut_parameter_get_values ?
    This is used in search help to retrive values from screen.This doesnt seem to work for me

    hi,
    check this
    F4UT_PARAMETER_VALUE_GET
    Short Text
    Standard search help exit for determining contents of a srch help par.
    FunctionalityBy calling this module in a search help exit, you can find out the current contents of a search help parameter . To do this, you must pass the name of the parameter in PARAMETER.
    You must distinguish between the parameter contents that are used in the selection process of the input help process and the parameter contents that are determined by the selection process and the user selection.
    Parameter contents that are used in the selection process are default values of search help parameters, values that are included in the input help process by attaching the search help to the screen from field contents of the screen or its module pool, and possibly complex restrictions made by the user in the dialog box for restricting value. Such parameter contents can also be included in the input help process by the search help exit itself.
    The contents of the specified parameter used in the selection process are stored as complex restrictions in SELOPT_TAB after the call. If exactly one value is defined by these complex restrictions (for example if the restrictions have exactly one row and if SIGN = 'I' and OPTION = 'EQ' for this row), this unique value can be found in VALUE.
    Parameter contents that are determined by selection process and user selection are the parameter contents that are shown in the dialog box for displaying the hit list or returned on the screen. They are managed by the F4 processor in RECORD_TAB.
    This module enables you to transfer the information about the specified parameters from RECORD_TAB to RESULTS_TAB in edited form.
    Pass the name of the field of RESULTS_TAB that should contain the contents of the parameter to the function module in parameter FIELDNAME. If the row type of RESULTS_TAB is elementary, pass the value '*' in FIELDNAME. The rest of RESULTS_TAB is not changed. The values are copied row by row. By removing rows at the end or by adding intiial rows you can make sure that RESULTS_TAB has exactly as many rows as RECOD_TAB.
    Example
    You can find an example of the second kind of use of the module in the search help exit SAPBC_GLOBAL_F4_SFLIGHT of search help SFLIGHT.
    Both types of use can be found in the search help exit SAPBC_GLOBAL_F4_SFLIGHT_MIN_FR of search help SFLIGHT_MIN_FREE .
    Notes
    1. Parameters OFF_RESULT and LEN_RESULT should not be used any more since there are basic problems when using UNICODE. The contents of these parameter are still analyzed when parameter FILEDNAME is initial for compatibility reasons.
    2. Only the dialog box for restricting values can normally produce complex restrictions for a parameter.
    3. If VALUE has the value SPACE, this means that either there are complex restrictions for the parameter or the unique contents are SPACE. SELOPT_TAB must be evaluated in order to determine which of these is the case.
    4. If the search help does not have any parameter with the given name, the exception PARAMETER_UNKNOWN is triggered.
    5. Only parameter contents for the search help displayed in the hit list or the EXPORT parameters of the search help are first managed in RECORD_TAB. If the specified parameter does not satisfy one of these conditions and if parameter RESULTS_TAB is specified in the call, the exception PARAMETER_UNKNOWN can also be triggered. This is not true, however, if results were already entered for the parameter with function module F4UT_PARAMETER_RESULTS_PUT or if space was reserved for the parameter in RECORD_TAB with function module F4UT_PARAMETER_ALLOCATE. The parameter therefore should only be defined if information about the parameter contents are really required.
    6. The header lines of the specified parameter are also transferred from RECORD_TAB to RESULTS_TAB.
    7. The other parameters of this module must be defined as the parameters of the search help exit having the same name, but they are not changed by this module.
    8. RESULTS_TAB should be a standard table.
    9. The contents of the specified parameter in RECORD_TAB are copied to the specified field of table RESULTS_TAB with a MOVE of the correct type. If this is not possible, the target field is assigned the initial value.
    10. If RESULTS_TAB has no field with the name specified by FIELDNAME, only the number of rows of RESULTS_TAB is adjusted to those of RECORD_TAB as described.
    Parameters
    PARAMETER
    OFF_RESULT
    LEN_RESULT
    FIELDNAME
    VALUE
    SHLP
    CALLCONTROL
    SHLP_TAB
    RECORD_TAB
    SELOPT_TAB
    RESULTS_TAB
    Exceptions
    PARAMETER_UNKNOWN
    Function Group
    SF4U
    if helpful reward some points.
    with regards,
    Suresh Aluri.

  • I stream Internet radio from my iPad air to Bluetooth speaker.  Can anyone suggest the best EQ app to use to enhance the sound.  Thanks

    I stream Internet raidiot from iPad air to Bluetooth speakers.  Can anyone suggest the best EQ app to use to enhance the sound.
    THanks

    Yeah, I know I can restore it, but I might as well go ahead and try. I just finished a backup for icloud and itunes to make sure, I'll go ahead and restore it and set it up as new and see how that works. Seems like I have no other options at this point, I'd still like to know what they did with the Download tab in itunes store, if they removed it or if I'm just overlooking it.

  • Can anyone list problems/errors when uploading data using BDC's and BAPI's?

    Can anyone list the problems/errors when uploading data using BDC's and BAPI's?

    Hi,
    If you are actually creating a BDC to load data pls be more specific.
    Data format incorrect. Tab delimited/ etc
    Dates in wrong formats
    Currency incorrect formats
    Missing screens
    Wrong transaction code
    File not found,
    Missing Mandatory fields,
    Screen resoultion.
    You should always use refresh for your Bdcdata table.
    Loop at internal table.
    refresh Bdcdata.
    regards,
    sowjanya.

  • Table in which RZ20 alerts are stored (Where can I find the error messages)

    Hi All,
    I want to know the table where i can see all the error messages poplulated as alerts in the TCode RZ20.

    hi,
    You can use the FM "BBP_GET_STATE_MONITOR" to get the avrious alert messages.
    BR,
    Disha.
    Do reward points for useful answers

  • Can ANYONE spot the memory leak??

    Hi, I have some code here, and there is a SERIOUS memory leak. Basically, I realized the leak was there when a report tried to execute this 100,000+ times and it bogged the system down to a crawl. Can anyone spot the leak? I will explain the variables below the code:
    char* getDescription(char* chFlag, char* chDEID, char* chKey, int keysize)
    //first, we need to allocate new Byte arrays....
    jbyteArray JchFlag = (*env1)->NewByteArray(env1,1);
    jbyteArray JchDEID = (*env1)->NewByteArray(env1,2);
    jbyteArray JchKey = (*env1)->NewByteArray(env1,40);
    //next, we need to put the correct info in those byte arrays....
    (*env1)->SetByteArrayRegion(env1,JchFlag,0,1,(jbyte*)chFlag); (*env1)->SetByteArrayRegion(env1,JchDEID,0,2,(jbyte*)chDEID); (*env1)->SetByteArrayRegion(env1,JchKey,0,40,(jbyte*)chKey);
    getDescriptionID =(*env1)->GetMethodID(env1,myjclass,"getDescription","([B[B[BI)Ljava/lang/String;");
    result              =(jstring)((*env1)->CallObjectMethod(env1,myjobject,getDescriptionID,JchFlag,JchDEID,JchKey,keysize))  ;   
        returnvalue = NULL;
        if(result == NULL)
           strcpy(holder1, "**********Error Finding Description**********");
        else { //now, we convert the jstring to a char *, so we can return the proper type...                       
                returnvalue=(char*)((*env1)->GetStringUTFChars(env1,result,&isCopy)) ;
                strcpy(holder1,returnvalue);           
                if(isCopy == JNI_TRUE)                    
                    (*env1)->ReleaseStringUTFChars(env1,result,returnvalue);                         
    (*env1)->DeleteLocalRef(env1,result);
    return holder1;
    //return description;
    }//end getDescription function
    -myjclass is global, it gets its value in the initialization.
    -any variables that are not declared in this function are, of course, globally defined.

    Hello Friends,
    I had also tried to use the ReleaseStringUTFChars after making the check of whether it does a copy or not.
    For me in Windows, it works fine most of the time. But when I go on increasing the no. of strings in a Vector of objects to more than 500 or something , then it occasionally fails.
    Just before ReleaseStringUTF, I do have the copied string in char* .
    Soon after Releasing, I do get a junk in the character array.
    I dont know why it happens like this.
    Please advice.
    Everyone suggest ReleaseStringUTF.
    But why it fails in Windows.
    And any one know about how it will behave in Alpha.
    It totally fails in Alpha.
    I could not get the string at all.
    Please help
    LathaDhamo

Maybe you are looking for

  • Can't reliably create a PDF enabled for commenting in Reader

    I've hit a brick wall trying to find out why my Acrobat Pro 7.0.8 is broken. As of yesterday, I cannot reliably create a PDF that is enabled for commenting in Reader. I get an error message: "You do not have permission to write to this file." However

  • Satellite L850-17K: Flashcards working but not all FN keys are available

    Hi everone, 2 days ago I reinstalled Windows 7 (64-bit) on my Satellite L850-17K. I succeeded in reinstalling all drivers, however I have had some problems with my function keys. After a long search on the internet I found the flashcards utility, but

  • RMAN 9i and 10g

    Hi In 10g the I just renamed the database(its not using ASM) and with recovery catalog I got : Why I cannot see the list of incarnation in 9i? Should I run NID on both the envirionments to refeister them with the catalog? Thanks in Advance Regards C:

  • Adding a Z field in the material master at the plant level

    Hi, I want to add a new text field in the material master. The data maintained inthis field should be easliy retrievable using  some STD SAP Report or using Abap query ( SQ01/SQ02) Please advise how do i do it. Regards,

  • Hw 2 display ALV in Table control

    Hi experts, hw we cn display alv output in a tabl cntrl. is dere ny specific fnctn module or v hav 2 use som odr method. hlpful answrs 'll b suitbly rewrded....