Creating a triangle using polygon class problem, URGENT??

Hi i am creating a triangle using polygon class which will eventually be used in a game where by a user clicks on the screen and triangles appear.
class MainWindow extends Frame
     private Polygon[] m_polyTriangleArr;
                   MainWindow()
                          m_nTrianglesToDraw = 0;
         m_nTrianglesDrawn = 0;
                         m_polyTriangleArr = new Polygon[15];
                         addMouseListener(new MouseCatcher() );
        setVisible(true);
                     class MouseCatcher extends MouseAdapter
                         public void mousePressed(MouseEvent evt)
              Point ptMouse = new Point();
              ptMouse = evt.getPoint();
            if(m_nTrianglesDrawn < m_nTrianglesToDraw)
                            int npoints = 3;
                    m_polyTriangleArr[m_nTrianglesDrawn]
                  = new Polygon( ptMouse[].x, ptMouse[].y, npoints);
}When i compile my code i get the following error message:
Class Expected
')' expectedThe two error messages are refering to the section new Polygon(....)
line. Please help

Cannot find symbol constructor Polygon(int, int, int)
Can some one tell me where this needs to go and what i should generally
look like pleaseI don't think it is a good idea to try and add the constructor that the compiler
can't find. Instead you should use the constructor that already exists
in the Polygon class: ie the one that looks like Polygon(int[], int[], int).
But this requires you to pass two int arrays and not two ints as you
are doing at the moment. As you have seen, evt.getPoint() only supplies
you with a single pair of ints: the x- and y-coordinates of where the mouse
button was pressed.
And this is the root of the problem. To draw a triangle you need three
points. From these three points you can build up two arrays: one containing
the x-coordinates and one containing the y-coordinates. It is these two
arrays that will be used as the first two arguments to the Polygon constructor.
So your task is to figure out how you can respond to mouse presses
correctly, and only try and add a new triangle when you have all three of its
vertices.
[Edit] This assumes that you expect the user to specify all three vertices of the
triangle. If this isn't the case, say what you do expect.

Similar Messages

  • Creating a triangle using polygon class problem?

    Hi i am trying to create a triangle with the polygon class. If successful, the user should be able to click on the screen and triangles should appear.
    private Polygon[] m_polyTriangleArr;
    MainWindow()
      m_polyTriangleArr = new Polygon[15];
    class MouseCatcher extends MouseAdapter
          public void mousePressed(MouseEvent evt)
                    Point ptMouse = new Point();
                    ptMouse = evt.getPoint();
                              if(m_nTrianglesDrawn < m_nTrianglesToDraw)
                         int npoints = 3;
                                               m_polyTriangleArr[m_nTrianglesDrawn]
                    = new Polygon( ptMouse.x, ptMouse.y, npoints);
                            m_nTrianglesDrawn++;
                        m_bMouse = true;
                        repaint();
            }Paint section
    public void paint(Graphics gc)
                  if(m_bMouse)
              gc.setColor(Color.green);
              for( int i = 0; i < m_nTrianglesDrawn; i++)
              gc.fillPolygon(m_polyTriangleArr.x, m_polyTriangleArr[i].y, npoints);
    When i try to compile my code i get the following error message:
    Cannot find symbol constructor Polygon(int, int, int)
    --- find symbol variable x
    --- find symbol variable y
    --- find symbol variable npoints.
    Can som1 tell me why i have these error messages when i have already declared a Polygon object array and what i need to change please??

    Check out the API
    http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Polygon.html
    there's no constructor that receives 3 integers
    cheers,
    Manuel Leiria

  • Create web service using java class

    Hi,
    I created the web service using java class then i deployed this web service in to the weblogic admin server.when i tested this process it is working fine.
    when I tested The generated WSDL to this process in browser(IE). it is not working.
    I need to to invoke this webservice from another BPEL but this WSDL is not working.

    Hi,
    when i created the webservice in jdeveloper by default it is connected to integrated weblogic server and generates this wsdl.
    http://localhost:7101/helloApplication-javaexcel-context-root/MyWebService1Soap12HttpPort?WSDL
    then I deployed this webservice in to the Adminserver.it gives the following URL.
    http://192.168.56.1:7001/extracExcelToCSV-extractExcelToCSV-context-root/ExtractExcelToCSVSoap12HttpPort?wsdl
    This URL is not working but when i tested this process it is working fine.
    It is giving below error when i try to invoke from jdeveloper
    Error while reading wsdl file
    caused by:java.net.connectExcepption :Connection timed out:connect

  • Error in creating a process using runtime class - please help

    Hi,
    I am experimenting with the following piece of code. I tried to run it in one windows machine and it works fine. But i tried to run it in a different windows machine i get error in creating a process. The error is attached below the code. I don't understand why i couldn't create a process with the 'exec' command in the second machine. Can anyone please help?
    CODE:
    import java.io.*;
    class test{
    public static void main(String[] args){
    try{
    Runtime r = Runtime.getRuntime();
         Process p = null;
         p= r.exec("dir");
         BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
         System.out.println(br.readLine());
    catch(Exception e){e.printStackTrace();}
    ERROR (when run in the dos prompt):
    java.io.IOException: CreateProcess: dir error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:63)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:550)
    at java.lang.Runtime.exec(Runtime.java:416)
    at java.lang.Runtime.exec(Runtime.java:358)
    at java.lang.Runtime.exec(Runtime.java:322)
    at test.main(test.java:16)
    thanks,
    Divya

    As much as I understand from the readings in the forums, Runtime.exec can only run commands that are in files, not native commands.
    Hmm how do I explain that again?
    Here:
    Assuming a command is an executable program
    Under the Windows operating system, many new programmers stumble upon Runtime.exec() when trying to use it for nonexecutable commands like dir and copy. Subsequently, they run into Runtime.exec()'s third pitfall. Listing 4.4 demonstrates exactly that:
    Listing 4.4 BadExecWinDir.java
    import java.util.*;
    import java.io.*;
    public class BadExecWinDir
    public static void main(String args[])
    try
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("dir");
    InputStream stdin = proc.getInputStream();
    InputStreamReader isr = new InputStreamReader(stdin);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    System.out.println("<OUTPUT>");
    while ( (line = br.readLine()) != null)
    System.out.println(line);
    System.out.println("</OUTPUT>");
    int exitVal = proc.waitFor();
    System.out.println("Process exitValue: " + exitVal);
    } catch (Throwable t)
    t.printStackTrace();
    A run of BadExecWinDir produces:
    E:\classes\com\javaworld\jpitfalls\article2>java BadExecWinDir
    java.io.IOException: CreateProcess: dir error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Unknown Source)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at BadExecWinDir.main(BadExecWinDir.java:12)
    As stated earlier, the error value of 2 means "file not found," which, in this case, means that the executable named dir.exe could not be found. That's because the directory command is part of the Windows command interpreter and not a separate executable. To run the Windows command interpreter, execute either command.com or cmd.exe, depending on the Windows operating system you use. Listing 4.5 runs a copy of the Windows command interpreter and then executes the user-supplied command (e.g., dir).
    Taken from:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Create an event using abap class (transaction swetypv)

    Hi,
    I’m trying to create an event by using an abap class.
    The purpose is to update po reqs using BAPI_REQUISITION_CHANGE upon saving a sales order. The exit is called on saving a sales order MV45AFZZ.
    In MV45AFZZ the method cl_swf_evt_event is called and the object type, event, objkey and obj cat is exported.
    Object Type = ZBUS203200
    Event = Z_TRAD_ORDER_CHANGE_OO
    I created my class ZCL_UPDATE_PUR_REQ (by copying CL_SWF_RUN_WIM_HANDLER
    And using interface name BI_EVENT_HANDLER_STATIC )
    In /nswetypv I assigned Class ZCL_UPDATE_PUR_REQ
    to Object Type ZBUS203200
    And Event Z_TRAD_ORDER_CHANGE_OO.
    All that works fine except for passing in the objectkey.
    In Class ZCL_UPDATE_PUR_REQ
    Method BI_EVENT_HANDLER_STATIC~ON_EVENT
    When I go to create a parameter for object key, I get the message
    ‘Parameters/exceptions of inherited methods or events cannot be changed’.
    Has anyone any suggestions for how I can get the object key into the method call BI_EVENT_HANDLER_STATIC~ON_EVENT?
    Thanks
    Ann

    Hi Johann,
    You don't need a class to do the job if you are on a 6.10 or higher system. Use command CALL TRANSFORMATION to create an XML from an internal table.
    Regards,
    John.

  • Create an event using abap class

    Hi,
    I’m trying to create an event by using an abap class.
    The purpose is to update po reqs using BAPI_REQUISITION_CHANGE upon saving a sales order.  The exit is called on saving a sales order MV45AFZZ.
    In  MV45AFZZ the method cl_swf_evt_event is called and the object type, event, objkey and obj cat is exported.
    Object Type    = ZBUS203200              
    Event          = Z_TRAD_ORDER_CHANGE_OO  
    I created my class ZCL_UPDATE_PUR_REQ (by copying CL_SWF_RUN_WIM_HANDLER    
    And using interface name BI_EVENT_HANDLER_STATIC   )
    In /nswetypv I assigned Class  ZCL_UPDATE_PUR_REQ
    to     Object Type     ZBUS203200                 
    And   Event              Z_TRAD_ORDER_CHANGE_OO.
    All that works fine except for passing in the objectkey.
    In Class ZCL_UPDATE_PUR_REQ 
    Method  BI_EVENT_HANDLER_STATIC~ON_EVENT
    When I go to create a parameter for object key, I get the message
    ‘Parameters/exceptions of inherited methods or events cannot be changed’.
    Has anyone any suggestions for how I can get the object key into the method call BI_EVENT_HANDLER_STATIC~ON_EVENT?
    Thanks
    Ann

    Hi Johann,
    You don't need a class to do the job if you are on a 6.10 or higher system. Use command CALL TRANSFORMATION to create an XML from an internal table.
    Regards,
    John.

  • Create a webservice using java class

    Hi,
    I have a java class (which is used to open a URL). I need to create a webservice out of this so that I can publish this. Which is the best tool to convert java to a webservice and what are the steps.
    Any pointers on this would be of great help.
    Thanks,
    Shreevatsa

    If you are using Java 6 use JAX-WS to expose it as a webservice. See the JavaEE tutorial for more information.

  • [ABAP] Create sales order using FM BAPI_SALESORDER_CREATEFROMDAT2 problem

    Hello All,
    In a report I have to create sales orders, I use function  BAPI_SALESORDER_CREATEFROMDAT2, but I got the message like "ship-to-party xxxx is not assigned to sold-to-party" if I_PARTNERS-PARTN_ROLE = 'WE' and when is 'SH' I get 'please enter ship-to-party or sold-to-party'. Please suggest how to correct this. Thank you
    Bogdan
    Here is the code:
    order header values
    HEADER-DOC_TYPE = 'ZRTA'.
    HEADER-SALES_ORG = '4301'.
    HEADER-DISTR_CHAN = '43'.
    HEADER-DIVISION = '40'.
    HEADER-PURCH_DATE = '20051109'.
    HEADER-PURCH_NO_C = '11111'.
    header-date_type = 'D'.
    *HEADER-REF_DOC = .
    *HEADER-REFDOC_CAT = 'E'.
    *HEADER-***_NUMBER = ZCONSGACTVSV-HUBREFNUM.
    order item level data
    I_ITEM-ITM_NUMBER = '000010'.
    I_ITEM-MATERIAL = '950700129'.
    *I_ITEM-ROUTE = CON-ROUTE.
    *IF NOT ZCONSGAGRMSV-CHARG IS INITIAL.
      I_ITEM-BATCH = ZCONSGAGRMSV-CHARG.
    *ELSE.
      I_ITEM-BATCH = '1'.
    *ENDIF.
    I_SCHEDULE-ITM_NUMBER = '000010'.
    I_SCHEDULE-REQ_QTY = '13'.
    *shipto = 'WE'.
    I_PARTNERS-PARTN_ROLE = 'SH'. " Ship to
    I_PARTNERS-PARTN_NUMB = '2000001'.
    *I_PARTNERS-PARTN_ROLE = 'SH'. " Ship to
    *I_PARTNERS-PARTN_NUMB = '2000001'.
    I_PARTNERS-name =
    APPEND: I_ITEM,
            I_SCHEDULE,
            I_PARTNERS.
    CLEAR: I_ITEM,
           I_SCHEDULE,
           I_PARTNERS.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
         EXPORTING
    SALESDOCUMENTIN =
                 ORDER_HEADER_IN = HEADER
    ORDER_HEADER_INX =
    SENDER =
    BINARY_RELATIONSHIPTYPE =
    INT_NUMBER_ASSIGNMENT =
    BEHAVE_WHEN_ERROR =
    LOGIC_SWITCH =
    TESTRUN =
    CONVERT = ' '
         IMPORTING
                 SALESDOCUMENT = ORDER
         TABLES
                 RETURN = RETURN
                 ORDER_ITEMS_IN = I_ITEM
    ORDER_ITEMS_INX =
                 ORDER_PARTNERS = I_PARTNERS
                 ORDER_SCHEDULES_IN = I_SCHEDULE
    ORDER_SCHEDULES_INX =
    ORDER_CONDITIONS_IN =
    ORDER_CFGS_REF =
    ORDER_CFGS_INST =
    ORDER_CFGS_PART_OF =
    ORDER_CFGS_VALUE =
    ORDER_CFGS_BLOB =
    ORDER_CFGS_VK =
    ORDER_CFGS_REFINST =
    ORDER_CCARD =
    ORDER_TEXT =
    ORDER_KEYS =
    EXTENSIONIN =
    PARTNERADDRESSES =

    Hi Bogdan,
       The documentation says
    Document Partner
    Description
    This table parameter is used to enter partners such as sold-to party, or ship-to party, both at header and item level.
    The minimum requirement is that the sold-to party is entered at header level. Additional partner functions can then be automatically determined.
    You can also enter different addresses in the structure.
    Check if it is useful to you in some way.
    Regards,
    Ravi

  • Problem with constructors and using public classes

    Hi, I'm totally new to Java and I'm having a lot of problems with my program :(
    I have to create constructor which creates bool's array of adequate size to create a sieve of Eratosthenes (for 2 ->n).
    Then it has to create public method boolean prime(m) which returs true if the given number is prime and false if it's not prime.
    And then I have to create class with main function which chooses from the given arguments the maximum and creates for it the sieve
    (using the class which was created before) and returns if the arguments are prime or not.
    This is what I've written but of course it's messy and it doesn't work. Can anyone help with that?
    //part with a constructor
    public class ESieve {
      ESieve(int n) {
    boolean[] isPrime = new boolean[n+1];
    for (int i=2; i<=n; i++)
    isPrime=true;
    for(int i=2;i*i<n;i++){
    if(isPrime[i]){
    for(int j=i;i*j<=n;j++){
    isPrime[i*j]=false;}}}
    public static boolean Prime(int m)
    for(int i=0; i<=m; i++)
    if (isPrime[i]<2) return false;
    try
    m=Integer.parseInt(args[i]);
    catch (NumberFormatException ex)
    System.out.println(args[i] + " is not an integer");
    continue;
    if (isPrime[i]=true)
    System.out.println (isPrime[i] + " is prime");
    else
    System.out.println (isPrime[i] + " is not prime");
    //main
    public class ESieveTest{
    public static void main (String args[])
    public static int max(int[] args) {
    int maximum = args[0];
    for (int i=1; i<args.length; i++) {
    if (args[i] > maximum) {
    maximum = args[i];
    return maximum;
    new ESieve(maximum);
    for(int i=0; i<args.length; i++)
    Prime(i);}

    I've made changes and now my code looks like this:
    public class ESieve {
      ESieve(int n) {
       sieve(n);
    public static boolean sieve(int n)
         boolean[] s = new boolean[n+1];
         for (int i=2; i<=n; i++)
    s=true;
    for(int i=2;i*i<n;i++){
    if(s[i]){
    for(int j=i;i*j<=n;j++){
    s[i*j]=false;}}}
    return s[n];}
    public static boolean prime(int m)
    if (m<2) return false;
    boolean x = sieve(m);
    if (x=true)
    System.out.println (m + " is prime");
    else
    System.out.println (m + " is not prime");
    return x;}
    //main
    public class ESieveTest{
    public static int max(int[] args) {
    int maximum = args[0];
    for (int i=1; i<args.length; i++) {
    if (args[i] > maximum) {
    maximum = args[i];
    return maximum;
    public static void main (String[] args)
    int n; int i, j;
    for(i=0;i<=args.length;i++)
    n=Integer.parseInt(args[i]);
    int maximum=max(args[]);
    ESieve S = new ESieve(maximum);
    for(i=0; i<args.length; i++)
    S.prime(i);}
    It shows an error for main:
    {quote} ESieveTest.java:21: '.class' expected
    int maximum=max(args[]); {quote}
    Any suggestions how to fix it?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem in database fields creation using default class of B1DE Wizard

    Hi Experts
    In an AddOn I am creating database fields in default class "Project_DB'. It does not give any message weather it creates fields or not. My code for database creation is given below
    Namespace FormARE
        Public Class FormARE_Db
            Inherits B1Db
            Public Sub New()
                MyBase.New
                B1Connections.theAppl.StatusBar.SetText("Please wait. AddOn is updating database", BoMessageTime.bmt_Long, BoStatusBarMessageType.smt_None)
                Columns = New B1DbColumn() {New B1DbColumn("OCRD", "BondNo", "Bond No.", BoFieldTypes.db_Alpha, BoFldSubTypes.st_None, 20, New B1WizardBase.B1DbValidValue(-1) {}, -1), New B1DbColumn("OCRD", "BFrDate", "Bond From Date", BoFieldTypes.db_Date, BoFldSubTypes.st_None, 10, New B1WizardBase.B1DbValidValue(-1) {}, -1), New B1DbColumn("OCRD", "BTDate", "Bond To Date", BoFieldTypes.db_Date, BoFldSubTypes.st_None, 10, New B1WizardBase.B1DbValidValue(-1) {}, -1), New B1DbColumn("OINV", "Cntner_no", "Container No.", BoFieldTypes.db_Alpha, BoFldSubTypes.st_None, 20, New B1WizardBase.B1DbValidValue(-1) {}, -1), New B1DbColumn("OINV", "Cntnr_Seal", "Container Seal No.", BoFieldTypes.db_Alpha, BoFldSubTypes.st_None, 20, New B1WizardBase.B1DbValidValue(-1) {}, -1), New B1DbColumn("OINV", "Cust_Seal", "Custom Seal No.", BoFieldTypes.db_Alpha, BoFldSubTypes.st_None, 20, New B1WizardBase.B1DbValidValue(-1) {}, -1), New B1DbColumn("OINV", "ctryOrgn", "Country of Origin", BoFieldTypes.db_Alpha, BoFldSubTypes.st_None, 20, New B1WizardBase.B1DbValidValue(-1) {}, -1)}
                GC.Collect()
                B1Connections.theAppl.StatusBar.SetText("Successfully updated database", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success)
            End Sub
        End Class
    End Namespace
    It does not give first message. and second message come properly and immediately when I start the AddOn. I checked it makes all fields accuratly. But when I open the related form it gives error message "Data Source not found". I checked fields name are same as used in form and database .What can the reason? Should I use a simple function for creation of database fields which will run when a button is pressed? Is it fine to using default class for database fields creation?
    Thanks
    Best Regards
    Jitender

    I solved the problem.
    Procedure I followed :
    UNINSTALL ORACLE WRAEHOUSE BUILDER SOFTAWARE.
    'GLOBAL_NAMES = FALSE' in init.ora file.
    RESTARTED MY MACHINE.
    INSTALL THE ORACLE WRAEHOUSE BUILDER SOFTAWARE.

  • Problem in Creating the Product Using COM_PRODUCT_MAINTAIN_MULT_API

    Dear CRMExperts,
             I am working in SAP CRM 5.0 version.I want to create the Product Using the Function Module "COM_PRODUCT_MAINTAIN_MULT_API".For this i have gone through the SAP Note 810153.I copied the Report Program from that note and i developed the Report Program.but i am facing some problem.
    The structures zinstall_info2_maint_t and zinstall_info2_maintain does not exist in SAP CRM 5.0 Version.So i am getting Short Dump.
    If anyone come across the same problem.Please help me to solve this issue.Please help me it is very Urgent.
    Thanks & Regards,
    Ashok.

    Hi,
    Note 1074357 - Implementing rollback in FM COM_PROD_MATERIAL_MAINTAIN_API
    Does this help you?
    regards,
    Murali

  • Class casting problem when using two class loaders

    Hi, I have a problem with class casting using two different ClassLoader...
    I created an instance of Test class, which is a subclass of AbstractTest and stored it for later use to ArrayList<AsbtractTest>. The instance was created with a custom class loader which extends URLClassLoader. Later when I got the stored instance from the ArrayList<AbstractTest> in default ClassLoader context and cast it to Test, it failed saying "java.lang.ClassCastException: com.test.Test cannot be cast to com.test.Test".
    Does anybody have an idea why this happens?

    Yes - a class is identified by it's package, it's name and it's class loader so the same class code loaded with two different class loaders are two different classes.
    An approach to dealing with your problem is to have the class implement an interface that is loaded by the parent class (assuming, of course, that the two class loaders have the same parent) then you can cast to the interface.

  • I've recently started to use Numbers but when I try to sync to iCloud it asks me to create a new iCloud account. Problem is I already have one and that's the one I want to use. Looks like I have the same situation on my iphone. Any guidance? Thanks.

    I've recently started to use Numbers on my macbook pro but when I try to sync to iCloud it asks me to create a new iCloud account. Problem is I already have one and that's the one I want to use.
    Looks like I have the same situation on my iphone.
    The only option I'm being given is to create an lCloud account.
    Any guidance? Thanks.

    The last thing you want is a second iCloud account. Try logging out and back in in System Preferences. If that doesn't work, I'd get AppleCare on the line.
    Jerry

  • [urgent ]runtime error  occured while creating the material using mm01

    hai
    am configure the ale program now . the problem is occured during the creating the material using mm01.
    am using client 000 (sending system). and i want to send the material to the client 400(receiving system)
    while am  save the created material using t-code mm01 in client 000 . it depicts the error as
    syntax error in program SAPLC140. 
    plz resolve this problem.
    regards
    surender

    Hi,
        In MM01 transaction code u have a problem..normally u will go to mm01 screen to create the material..i thought the same error will occur...so call basis to rectify this problem..
    Thank u,
    Manjula Devi.D

  • Is anyone else having email problems such as apps exiting in the middle of an email? It may be a wireless issue. I use First Class for work and yahoo email for personal. I will be in the middle of typing a long email and the app just quits, all data lost.

    Is anyone else having email problems such as apps exiting in the middle of an email? It may be a wireless issue. I use First Class for work and yahoo email for personal. I will be in the middle of typing a long email and the app just quits, all data lost.

    Have you tried restarting or resetting your iPad?
    Restart: Press On/Off button until the Slide to Power Off slider appears, select Slide to Power Off and, after the iPad shuts down, then press the On/Off button until the Apple logo appears.
    Reset: Press the Home and On/Off buttons at the same time and hold them until the Apple logo appears (about 10 seconds). Ignore the "Slide to power off"

Maybe you are looking for