Convert qmailadmin to java

There is open source program qmailadmin to create virtual domain,users, there quota for network. this program is written in CGI, How can i convert to JAVA,
Which java API is suitable for this type of programs.
Can anybody help me in this.

Is there any software free to download and just paste
the C++ code and convert it to java code??No, such a beast doesn't exist and if someone claims it does exist
I've got a nice test-suite ready to show that it doesn't work correctly.
kind regards,
Jos

Similar Messages

  • Cannot convert type class java.lang.String to class oracle.jbo.domain.Clob

    Cannot convert type class java.lang.String to class oracle.jbo.domain.ClobDomain.
    Using ADF Business Components I have a JSFF page fragment with an ADF form based on a table with has a column of type CLOB. The data is retrieved from the database and displayed correctly but when any field is changed and submitted the above error occurs. I have just used the drag and drop technique to create the ADF form with a submit button, am I missing a step?
    I am using the production release of Jdeveloper11G

    Reproduced and filed bug# 7487124
    The workaround is to add a custom converter class to your ViewController project like this
    package oow2008.view;
    import javax.faces.application.FacesMessage;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import javax.faces.convert.ConverterException;
    import oracle.jbo.domain.ClobDomain;
    import oracle.jbo.domain.DataCreationException;
    public class ClobConverter implements Converter {
         public Object getAsObject(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   String string) {
           try {
             return string != null ? new ClobDomain(string) : null;
           } catch (DataCreationException dce) {
             dce.setAppendCodes(false);
             FacesMessage fm =
               new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                "Invalid Clob Value",
                                dce.getMessage());
             throw new ConverterException(fm);
         public String getAsString(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   Object object) {
           return object != null ?
                  object.toString() :
                  null;
    }then to register the converter in faces-config.xml like this
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee">
      <application>
        <default-render-kit-id>oracle.adf.rich</default-render-kit-id>
      </application>
      <converter>
        <converter-id>clobConverter</converter-id>
        <converter-class>oow2008.view.ClobConverter</converter-class>
      </converter>
    </faces-config>then reference this converter in the field for the ClobDomain value like this
              <af:inputText value="#{bindings.Description.inputValue}"
                            label="#{bindings.Description.hints.label}"
                            required="#{bindings.Description.hints.mandatory}"
                            columns="40"
                            maximumLength="#{bindings.Description.hints.precision}"
                            shortDesc="#{bindings.Description.hints.tooltip}"
                            wrap="soft" rows="10">
                <f:validator binding="#{bindings.Description.validator}"/>
                <f:converter converterId="clobConverter"/>
              </af:inputText>

  • Error: could not be converted to [class java.lang.Class].

    I am newbie to JDeveloper (10.1.2) on winxp and i was trying to setup the example from the following url http://radio.weblogs.com/0129487/2003/09/19.html
    It is a how to on "Executing Toplink Queries using JavaBean DataControl "
    Any help would be greatly appreciated.
    Near the bottom on step "In StrutsPageFlow diagram, select allEmpsDA Data Action, right mouse and chooe Run" i get a the following runtime errors:
    Validation Error
    You must correct the following error(s) before proceeding:
    JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.toplink.exceptions.ConversionException, msg= Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees
    JBO-29000: Unexpected exception caught: oracle.toplink.exceptions.ConversionException, msg= Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees
    Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees

    This error is happening on a read.
    Here is the mapping descriptor:
    <database-mapping>
    <attribute-name>SuppItemCollection</attribute-name>
    <read-only>false</read-only>
    <reference-class>package.SuppItem</reference-class>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.NoIndirectionPolicy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <container-policy>
    <mapping-container-policy>
    <container-class>java.util.Vector</container-class>
    <type>oracle.toplink.internal.queryframework.ListContainerPolicy</type>
    </mapping-container-policy>
    </container-policy>
    <source-key-fields>
    <field>SUPP.REQ_NUM</field>
    </source-key-fields>
    <target-foreign-key-fields>
    <field>SUPP_ITEM.REQ_NUM</field>
    </target-foreign-key-fields>
    <type>oracle.toplink.mappings.OneToManyMapping</type>
    </database-mapping>
    Object model has a Supp class that has a collection of SuppItem(s). I was allowing the Mapping Workbench to create the Java Source. I'm not to fond of that, but I thought it would be easiest to get things going.
    The datamodel is similiar to the class model.
    Thanks for the help,
    Mike

  • Converted WSDL into .java-files - and now?

    I should implement a client for an existing web service. All I have is a .wsdl-file of the web service to call.
    Therefore I used the eclipse's functionality to convert .wsdl into .java files, which generated some files for me, for example:
    - interface XXX extending java.rmi.Remote
    - interface XXXService extends javax.xml.rpc.Service
    - class XXXProxy implements XXX
    - class XXXServiceLocator extends org.apache.axis.client.Service
    - class XXXSoapBindingStub extends org.apache.axis.client.Stub implements XXX
    - class XXXRfcException extends org.apache.axis.AxisFault implements java.io.Serializable
    - class XXXRfcExceptions implements java.io.Serializable
    My question... what to do now? How can I get the service and call its functionality?
    Your help is really, REALLY appreciated...

    Hi,
    Write client application like below.
    public class Client{
    public static void main(String [] args) throws Exception {
    // Make a service
    XXXService service = new XXXServiceLocator();
    // Now use the service to get a stub which implements the SDI.
    AddressBook port = service.getAddressBook();
    // Make the actual call
    Address address = new Address(...);
    port.addEntry("Russell Butek", address);
    Thanks&Regards,
    M.Kumaraswamy.

  • Can't convert int to java.lang.Integer.

    Hi everyone.
    I'm working on an auction site at the moment and have problems gaining a bidID number. This is part of my code and my error.
    AuctionFacade aHse = (AuctionFacade) application.getAttribute("AuctionFacade");
    String strTraderName = (String)session.getAttribute("traderName");
    String strPassword = (String)session.getAttribute("password");
    String strIDNum = request.getParameter("auctionID");
    Integer intID = Integer.valueOf(strIDNum);
    Integer [] bids = aHse.getAllBids(intID);
    float fltYourBid = aHse.getBidPrice(bids.length);
    ^
    Can't convert int to java.lang.Integer.
    can anyone help please?

    So, does "aHse.getBidPrice" expect an int or an Integer as its parameter? And does it return an int, or an Integer, or what? The answer to those questions may lead to your solution -- look at what you are actually using as the parameter, for example.

  • Can't convert FileReader to java.io.Reader

    Hi
    I have a code segment that generates error during compilation of the source file: "Incompatible type for constructor. Can't convert FileReader to java.io.Reader.
         buffVideo = new BufferedReader (file)
         ^
    The code segment is:
    FileReader file;
    BufferedReader buffVideo;
    StreamTokenizer tokenVideo;
    String s;
    try {
         file = new FileReader (fileVideo);
         buffVideo = new BufferedReader (file);
         tokenVideo = new StreamTokenizer (buffVideo);
    import java.io.* is at the top of the .java file. It is a part of a definition of a new class. fileVideo is a String variable containing file name of a text file.
    Exactly the same .java source file compiles on a Windows 98 based machine, but not on a Windows 2000 Professional. I use version 1.1.6 as it is required by my current course.
    Can anybody suggest any resoultion for this problem, please?
    Thanks in advance

    Branko,
    Wow, my ID still works. Amazing, I haven't visited for years.
    Ged Byrne writes:
    Branko,
    This is a realy puzzler. My only guess is that you have a namespace
    conflict. The error message states:
    Can't convert File Reader to java.io.Reader
    It seems that there is another class called FileReader that is clashing
    with the on in java.io.
    Have you inadvertantly named something FileReader yourself?
    Perhaps your classpath is including something that contains a FileReader.
    Try declaring file as java.io.FileReader rather than just FileReader.
    I'm clutching at straws.
    Ged.

  • Can't convert int to java.lang.Object

    When I deploy my customer Bean, the following error occures, I think the main problem is Can't convert int to java.lang.Object, does anyone facing the same problem with me?
    <pre>C:\j2sdkee1.3\repository\home\gnrtrTMP\CustomerApp\CustomerBean_RemoteHomeImpl.j
    ava:27: Incompatible type for declaration. Can't convert int to java.lang.Object
    java.lang.Object primaryKey = ejb.ejbCreate(param0, param1, para
    m2);
    ^
    C:\j2sdkee1.3\repository\home\gnrtrTMP\CustomerApp\CustomerBean_RemoteHomeImpl.j
    ava:57: Incompatible type for =. Can't convert int to java.lang.Object.
    primaryKeys = ejb.ejbFindByPrimaryKey( param0);
    ^</pre>
    I really need your help!!!

    you can only convert one object type to another. Integer is an object int isnt. You might want to convert int to Integer and then go ahead.
    see if it works.

  • Cant convert boolean to java.lang.Boolean - HUH?

    I'm fairly new to Java, but I'm pretty sure this should work.
    Can someone tell me why I'm getting these compiler errors:
    wehServlet.java:72: Incompatible type for if. Can't convert java.lang.Boolean to boolean.
    if (checkoutSpecificFile(req,res,busId,tempDir)) {
    ^
    wehServlet.java:123: Incompatible type for return. Can't convert boolean to java.lang.Boolean.
    return true;
    Here's the basic code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    public class wehServlet extends HttpServlet {
    private void someThing (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    if(tryThis()) {
    <do something>
    } else {
    <do something else>
    private Boolean tryThis() {
    return false;
    Why can't I do this?
    How do I fix it?
    I tried
    if(tryThis().booleanValue())....
    and I get this compile error:
    Incompatible type for return. Can't convert boolean to java.lang.Boolean
    Now what do I do?

    There's a lot of confusion caused by these "Wrapper" objects, not just Boolean but Integer, Long etc.
    The basic ("primitive") types are lower case names, boolean, int, long etc..
    The related items with capital letters are "wrapper" objects. The are used in a context where you basically want to store a single value but must do so as an Object, for example in aggregate objects like Map or List.
    You should avoid these unless there's a specific reason to use them.
    You can convert between boolean and Boolean, int and Integer etc. but it has to be done explicitly. As far as Java is concerned they're entirely different kind of thing. To java the Boolean class is just another kind of Object, it has no special syntactic significance.
    boolean b;
    Boolean bo;
    b = bo.booleanValue();  // covert from Boolean object to boolean primitive
    bo = new Boolean(b); // convert primitive to Object
    if(bo.booleanValue()) {  // test Boolean objed

  • Converting unsigned to java signed byte value

    Hey ,
    i need to use a raw address in a client i am writing but, of course, the address contains a byte outside of the java signed byte range. if any one could tell me what an unsigned byte of 224 in signed java is i would be very grateful, if you could also show how you did this it would be appreciated. thank you =)

    Re: Converting unsigned to java signed byte value
    i need to use a raw address in a client i am writing
    but, of course, the address contains a byte outside
    of the java signed byte range.
    if any one could tell
    me what an unsigned byte of 224 is in signed java
    I would be very grateful, if you could also show how
    you did this it would be appreciated. thank you =)You misunderstand signed/unsigned.
    A byte has 8 bits. It can represent 256 different values.
    Viewed as an unsigned scalar the range is [0;255].
    Viewed as a signed two's-complement scalar the range is [-128;127].
    Values [0;127] are obviously the same byte values in the two views.
    What the other half of the possible byte values represent depends on what view you adopt.
    You don't need to convert anything.
    public final class Byte224 {
        static byte[] byteArray = {
            (byte)224, (byte)'\n'
        public static final void main(final String[] arg) {
            System.out.println("0x"+Integer.toHexString(byteArray[0]&0xff));
            System.out.println(Integer.toString(byteArray[0]&0xff));
    }

  • Converting XML to Java in STB

    I am trying to convert xml to java. Looking for simple and light way to covert xml to java in STB.

    Heh - all the tags in your question got stripped out by the forum-to-email bridge :-)
    Anyway, basically you just parse the XML data. You can use some
    kind of library if you like, but it turns out that parsing an XML response
    that's consistently formatted the same way isn't all that hard to do directly.
    In the HD cookbook project, we have a sample xlet that does just this, reading
    weather data from some public web service out there (I forget which - maybe
    Yahoo's?) The xlet could be converted to work on MHP or OCAP without
    much work. This demo is in xlets/demos/weatherWidget, and the project
    is at http://hdcookbook.com, click on the sumo wrestler. It's in the source-code repository,
    but over on the right one of the links will let you browse individual files, which should
    get you pretty quickly to the XML parser in this demo.
    By the way, if you have a choice between JSON and XML in this environment, I'd
    personally go with JSON. It's simpler to parse and faster - indeed, see
    com.hdcookbook.grin.util.JsonIO in the cookbook repository. Of course, if you're
    interacting with a server under your control and you want maximum performance, you
    can use a more efficient binary format, too.
    Cheers,
    Bill

  • Converting String to java.sql.Time

    i have got a string like String time = "12:08 P.M.";
    I want to convert it to java.sql.Time .
    Please anyone suggest me the solution.

    CROSSPOST: http://forum.java.sun.com/thread.jspa?threadID=5162798&messageID=9621227
    A crosspost with only 2 postings. Is that a new record? Or does it just tie the record :-)

  • Problem converting a (working) Java program into an applet

    When I'm trying to access an Image through a call to :
    mediaTracker = new MediaTracker(this);
    backGroundImage = getImage(getDocumentBase(), "background.gif");
    mediaTracker.addImage(backGroundImage, 0);
    I'm getting a nullPointerException as a result of the call to getDocumentBase() :
    C:\Chantier\Java\BallsApplet
    AppletViewer testBallsApplet.htmljava.lang.NullPointerException
    at java.applet.Applet.getDocumentBase(Applet.java:125)
    at Balls.<init>(Balls.java:84)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    at java.lang.Class.newInstance0(Class.java:296)
    at java.lang.Class.newInstance(Class.java:249)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:477)
    at sun.applet.AppletPanel.run(AppletPanel.java:290)
    at java.lang.Thread.run(Thread.java:536)
    It seems very weird to me... :-/
    (all the .gif files are in the same directory than the .class files)
    The problem appears with AppletViewer trying to open an HTML file
    containing :
    <HTML>
    <APPLET CODE="Balls.class" WIDTH=300 HEIGHT=211>
    </APPLET>
    </HTML>
    (I tried unsuccessfully the CODEBASE and ARCHIVE attributes, with and without putting the .gif and .class into a .jar file)
    I can't find the solution by myself, so, I'd be very glad if someone could help
    me with this... Thank you very much in advance ! :-)
    You'll find below the source of a small game that I wrote and debugged (without
    problem) and that I'm now (unsuccessfully) trying to convert into an Applet :
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.net.URL;
    public class Balls extends java.applet.Applet implements Runnable, KeyListener
    private Image offScreenImage;
    private Image backGroundImage;
    private Image[] gifImages = new Image[6];
    private Image PressStart ;
    private Sprite pressStartSprite = null ;
    private Image YouLose ;
    private Sprite YouLoseSprite = null ;
    private Image NextStage ;
    private Sprite NextStageSprite = null ;
    private Image GamePaused ;
    private Sprite GamePausedSprite = null ;
    //offscreen graphics context
    private Graphics offScreenGraphicsCtx;
    private Thread animationThread;
    private MediaTracker mediaTracker;
    private SpriteManager spriteManager;
    //Animation display rate, 12fps
    private int animationDelay = 83;
    private Random rand = new Random(System.currentTimeMillis());
    private int message = 0 ; // 0 = no message (normal playing phase)
    // 1 = press space to start
    // 2 = press space for next level
    // 3 = game PAUSED, press space to unpause
    // 4 = You LOSE
    public static void main(String[] args)
    try
    new Balls() ;
    catch (java.net.MalformedURLException e)
    System.out.println(e);
    }//end main
    public void start()
    //Create and start animation thread
    animationThread = new Thread(this);
    animationThread.start();
    public void init()
    try
    new Balls() ;
    catch (java.net.MalformedURLException e)
    System.out.println(e);
    public Balls() throws java.net.MalformedURLException
    {//constructor
    // Load and track the images
    mediaTracker = new MediaTracker(this);
    backGroundImage = getImage(getDocumentBase(), "background.gif");
    mediaTracker.addImage(backGroundImage, 0);
    PressStart = getImage(getDocumentBase(), "press_start.gif");
    mediaTracker.addImage(PressStart, 0);
    NextStage = getImage(getDocumentBase(), "stage_complete.gif");
    mediaTracker.addImage(NextStage, 0);
    GamePaused = getImage(getDocumentBase(), "game_paused.gif");
    mediaTracker.addImage(GamePaused, 0);
    YouLose = getImage(getDocumentBase(), "you_lose.gif");
    mediaTracker.addImage(YouLose, 0);
    //Get and track 6 images to use
    // for sprites
    gifImages[0] = getImage(getDocumentBase(), "blueball.gif");
    mediaTracker.addImage(gifImages[0], 0);
    gifImages[1] = getImage(getDocumentBase(), "redball.gif");
    mediaTracker.addImage(gifImages[1], 0);
    gifImages[2] = getImage(getDocumentBase(), "greenball.gif");
    mediaTracker.addImage(gifImages[2], 0);
    gifImages[3] = getImage(getDocumentBase(), "yellowball.gif");
    mediaTracker.addImage(gifImages[3], 0);
    gifImages[4] = getImage(getDocumentBase(), "purpleball.gif");
    mediaTracker.addImage(gifImages[4], 0);
    gifImages[5] = getImage(getDocumentBase(), "orangeball.gif");
    mediaTracker.addImage(gifImages[5], 0);
    //Block and wait for all images to
    // be loaded
    try {
    mediaTracker.waitForID(0);
    }catch (InterruptedException e) {
    System.out.println(e);
    }//end catch
    //Base the Frame size on the size
    // of the background image.
    //These getter methods return -1 if
    // the size is not yet known.
    //Insets will be used later to
    // limit the graphics area to the
    // client area of the Frame.
    int width = backGroundImage.getWidth(this);
    int height = backGroundImage.getHeight(this);
    //While not likely, it may be
    // possible that the size isn't
    // known yet. Do the following
    // just in case.
    //Wait until size is known
    while(width == -1 || height == -1)
    System.out.println("Waiting for image");
    width = backGroundImage.getWidth(this);
    height = backGroundImage.getHeight(this);
    }//end while loop
    //Display the frame
    setSize(width,height);
    setVisible(true);
    //setTitle("Balls");
    //Anonymous inner class window
    // listener to terminate the
    // program.
    this.addWindowListener
    (new WindowAdapter()
    {public void windowClosing(WindowEvent e){System.exit(0);}});
    // Add a key listener for keyboard management
    this.addKeyListener(this);
    }//end constructor
    public void run()
    Point center_place = new Point(
    backGroundImage.getWidth(this)/2-PressStart.getWidth(this)/2,
    backGroundImage.getHeight(this)/2-PressStart.getHeight(this)/2) ;
    pressStartSprite = new Sprite(this, PressStart, center_place, new Point(0, 0),true);
    center_place = new Point(
    backGroundImage.getWidth(this)/2-NextStage.getWidth(this)/2,
    backGroundImage.getHeight(this)/2-NextStage.getHeight(this)/2) ;
    NextStageSprite = new Sprite(this, NextStage, center_place, new Point(0, 0),true);
    center_place = new Point(
    backGroundImage.getWidth(this)/2-GamePaused.getWidth(this)/2,
    backGroundImage.getHeight(this)/2-GamePaused.getHeight(this)/2) ;
    GamePausedSprite = new Sprite(this, GamePaused, center_place, new Point(0, 0),true);
    center_place = new Point(
    backGroundImage.getWidth(this)/2-YouLose.getWidth(this)/2,
    backGroundImage.getHeight(this)/2-YouLose.getHeight(this)/2) ;
    YouLoseSprite = new Sprite(this, YouLose, center_place, new Point(0, 0),true);
    BackgroundImage bgimage = new BackgroundImage(this, backGroundImage) ;
    for (;;) // infinite loop
    long time = System.currentTimeMillis();
    message = 1 ; // "press start to begin"
    while (message != 0)
    repaint() ;
    try
    time += animationDelay;
    Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
    catch (InterruptedException e)
    System.out.println(e);
    }//end catch
    boolean you_lose = false ;
    for (int max_speed = 7 ; !you_lose && max_speed < 15 ; max_speed++)
    for (int difficulty = 2 ; !you_lose && difficulty < 14 ; difficulty++)
    boolean unfinished_stage = true ;
    spriteManager = new SpriteManager(bgimage);
    spriteManager.setParameters(difficulty, max_speed) ;
    //Create 15 sprites from 6 gif
    // files.
    for (int cnt = 0; cnt < 15; cnt++)
    if (cnt == 0)
    Point position = new Point(
    backGroundImage.getWidth(this)/2-gifImages[0].getWidth(this)/2,
    backGroundImage.getHeight(this)/2-gifImages[0].getHeight(this)/2) ;
    spriteManager.addSprite(makeSprite(position, 0, false));
    else
    Point position = spriteManager.
    getEmptyPosition(new Dimension(gifImages[0].getWidth(this),
    gifImages[0].getHeight(this)));
    if (cnt < difficulty)
    spriteManager.addSprite(makeSprite(position, 1, true));
    else
    spriteManager.addSprite(makeSprite(position, 2, true));
    }//end for loop
    time = System.currentTimeMillis();
    while (!spriteManager.getFinishedStage() && !spriteManager.getGameOver())
    // Loop, sleep, and update sprite
    // positions once each 83
    // milliseconds
    spriteManager.update();
    repaint();
    try
    time += animationDelay;
    Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
    catch (InterruptedException e)
    System.out.println(e);
    }//end catch
    }//end while loop
    if (spriteManager.getGameOver())
    message = 4 ;
    while (message != 0)
    spriteManager.update();
    repaint();
    try
    time += animationDelay;
    Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
    catch (InterruptedException e)
    System.out.println(e);
    }//end catch
    you_lose = true ;
    if (spriteManager.getFinishedStage())
    message = 2 ;
    while (message != 0)
    spriteManager.update();
    repaint();
    try
    time += animationDelay;
    Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
    catch (InterruptedException e)
    System.out.println(e);
    }//end catch
    } // end for difficulty loop
    } // end for max_speed
    } // end infinite loop
    }//end run method
    private Sprite makeSprite(Point position, int imageIndex, boolean wind)
    return new Sprite(
    this,
    gifImages[imageIndex],
    position,
    new Point(rand.nextInt() % 5,
    rand.nextInt() % 5),
    wind);
    }//end makeSprite()
    //Overridden graphics update method
    // on the Frame
    public void update(Graphics g)
    //Create the offscreen graphics
    // context
    if (offScreenGraphicsCtx == null)
    offScreenImage = createImage(getSize().width,
    getSize().height);
    offScreenGraphicsCtx = offScreenImage.getGraphics();
    }//end if
    if (message == 0)
    // Draw the sprites offscreen
    spriteManager.drawScene(offScreenGraphicsCtx);
    else if (message == 1)
    pressStartSprite.drawSpriteImage(offScreenGraphicsCtx);
    else if (message == 2)
    NextStageSprite.drawSpriteImage(offScreenGraphicsCtx);
    else if (message == 3)
    GamePausedSprite.drawSpriteImage(offScreenGraphicsCtx);
    else if (message == 4)
    YouLoseSprite.drawSpriteImage(offScreenGraphicsCtx);
    // Draw the scene onto the screen
    if(offScreenImage != null)
    g.drawImage(offScreenImage, 0, 0, this);
    }//end if
    }//end overridden update method
    //Overridden paint method on the
    // Frame
    public void paint(Graphics g)
    //Nothing required here. All
    // drawing is done in the update
    // method above.
    }//end overridden paint method
    // Methods to handle Keyboard event
    public void keyPressed(KeyEvent evt)
    int key = evt.getKeyCode(); // Keyboard code for the pressed key.
    if (key == KeyEvent.VK_SPACE)
    if (message != 0)
    message = 0 ;
    else
    message = 3 ;
    if (key == KeyEvent.VK_LEFT)
    if (spriteManager != null)
    spriteManager.goLeft() ;
    else if (key == KeyEvent.VK_RIGHT)
    if (spriteManager != null)
    spriteManager.goRight() ;
    else if (key == KeyEvent.VK_UP)
    if (spriteManager != null)
    spriteManager.goUp() ;
    else if (key == KeyEvent.VK_DOWN)
    if (spriteManager != null)
    spriteManager.goDown() ;
    if (spriteManager != null)
    spriteManager.setMessage(message) ;
    public void keyReleased(KeyEvent evt)
    public void keyTyped(KeyEvent e)
    char key = e.getKeyChar() ;
    //~ if (key == 's')
    //~ stop = true ;
    //~ else if (key == 'c')
    //~ stop = false ;
    //~ spriteManager.setStop(stop) ;
    }//end class Balls
    //===================================//
    class BackgroundImage
    private Image image;
    private Component component;
    private Dimension size;
    public BackgroundImage(
    Component component,
    Image image)
    this.component = component;
    size = component.getSize();
    this.image = image;
    }//end construtor
    public Dimension getSize(){
    return size;
    }//end getSize()
    public Image getImage(){
    return image;
    }//end getImage()
    public void setImage(Image image){
    this.image = image;
    }//end setImage()
    public void drawBackgroundImage(Graphics g)
    g.drawImage(image, 0, 0, component);
    }//end drawBackgroundImage()
    }//end class BackgroundImage
    //===========================
    class SpriteManager extends Vector
    private BackgroundImage backgroundImage;
    private boolean finished_stage = false ;
    private boolean game_over = false ;
    private int difficulty ;
    private int max_speed ;
    public boolean getFinishedStage()
    finished_stage = true ;
    for (int cnt = difficulty ; cnt < size(); cnt++)
    Sprite sprite = (Sprite)elementAt(cnt);
    if (!sprite.getEaten())
    finished_stage = false ;
    return finished_stage ;
    public boolean getGameOver() {return game_over ;}
    public void setParameters(int diff, int speed)
    difficulty = diff ;
    max_speed = speed ;
    finished_stage = false ;
    game_over = false ;
    Sprite sprite;
    for (int cnt = 0;cnt < size(); cnt++)
    sprite = (Sprite)elementAt(cnt);
    sprite.setSpeed(max_speed) ;
    public SpriteManager(BackgroundImage backgroundImage)
    this.backgroundImage = backgroundImage ;
    }//end constructor
    public Point getEmptyPosition(Dimension spriteSize)
    Rectangle trialSpaceOccupied = new Rectangle(0, 0,
    spriteSize.width,
    spriteSize.height);
    Random rand = new Random(System.currentTimeMillis());
    boolean empty = false;
    int numTries = 0;
    // Search for an empty position
    while (!empty && numTries++ < 100)
    // Get a trial position
    trialSpaceOccupied.x =
    Math.abs(rand.nextInt() %
    backgroundImage.
    getSize().width);
    trialSpaceOccupied.y =
    Math.abs(rand.nextInt() %
    backgroundImage.
    getSize().height);
    // Iterate through existing
    // sprites, checking if position
    // is empty
    boolean collision = false;
    for(int cnt = 0;cnt < size(); cnt++)
    Rectangle testSpaceOccupied = ((Sprite)elementAt(cnt)).getSpaceOccupied();
    if (trialSpaceOccupied.intersects(testSpaceOccupied))
    collision = true;
    }//end if
    }//end for loop
    empty = !collision;
    }//end while loop
    return new Point(trialSpaceOccupied.x, trialSpaceOccupied.y);
    }//end getEmptyPosition()
    public void update()
    Sprite sprite;
    // treat special case of sprite #0 (the player)
    sprite = (Sprite)elementAt(0);
    sprite.updatePosition() ;
    int hitIndex = testForCollision(sprite);
    if (hitIndex != -1)
    if (hitIndex < difficulty)
    { // if player collides with an hunter (red ball), he loose
    sprite.setEaten() ;
    game_over = true ;
    else
    // if player collides with an hunted (green ball), he eats the green
    ((Sprite)elementAt(hitIndex)).setEaten() ;
    //Iterate through sprite list
    for (int cnt = 1;cnt < size(); cnt++)
    sprite = (Sprite)elementAt(cnt);
    //Update a sprite's position
    sprite.updatePosition();
    //Test for collision. Positive
    // result indicates a collision
    hitIndex = testForCollision(sprite);
    if (hitIndex >= 0)
    //a collision has occurred
    bounceOffSprite(cnt,hitIndex);
    }//end if
    }//end for loop
    }//end update
    public void setMessage(int message)
    Sprite sprite;
    //Iterate through sprite list
    for (int cnt = 0;cnt < size(); cnt++)
    sprite = (Sprite)elementAt(cnt);
    //Update a sprite's stop status
    sprite.setMessage(message);
    }//end for loop
    }//end update
    public void goLeft()
    Sprite sprite = (Sprite)elementAt(0);
    sprite.goLeft() ;
    public void goRight()
    Sprite sprite = (Sprite)elementAt(0);
    sprite.goRight() ;
    public void goUp()
    Sprite sprite = (Sprite)elementAt(0);
    sprite.goUp() ;
    public void goDown()
    Sprite sprite = (Sprite)elementAt(0);
    sprite.goDown() ;
    private int testForCollision(Sprite testSprite)
    //Check for collision with other
    // sprites
    Sprite sprite;
    for (int cnt = 0;cnt < size(); cnt++)
    sprite = (Sprite)elementAt(cnt);
    if (sprite == testSprite)
    //don't check self
    continue;
    //Invoke testCollision method
    // of Sprite class to perform
    // the actual test.
    if (testSprite.testCollision(sprite))
    //Return index of colliding
    // sprite
    return cnt;
    }//end for loop
    return -1;//No collision detected
    }//end testForCollision()
    private void bounceOffSprite(int oneHitIndex, int otherHitIndex)
    //Swap motion vectors for
    // bounce algorithm
    Sprite oneSprite = (Sprite)elementAt(oneHitIndex);
    Sprite otherSprite = (Sprite)elementAt(otherHitIndex);
    Point swap = oneSprite.getMotionVector();
    oneSprite.setMotionVector(otherSprite.getMotionVector());
    otherSprite.setMotionVector(swap);
    }//end bounceOffSprite()
    public void drawScene(Graphics g)
    //Draw the background and erase
    // sprites from graphics area
    //Disable the following statement
    // for an interesting effect.
    backgroundImage.drawBackgroundImage(g);
    //Iterate through sprites, drawing
    // each sprite
    for (int cnt = 0;cnt < size(); cnt++)
    ((Sprite)elementAt(cnt)).drawSpriteImage(g);
    }//end drawScene()
    public void addSprite(Sprite sprite)
    addElement(sprite);
    }//end addSprite()
    }//end class SpriteManager
    //===================================//
    class Sprite
    private Component component;
    private Image image;
    private Rectangle spaceOccupied;
    private Point motionVector;
    private Rectangle bounds;
    private Random rand;
    private int message = 0 ; // number of message currently displayed (0 means "no message" = normal game)
    private int max_speed = 7 ;
    private boolean eaten = false ; // when a green sprite is eaten, it is no longer displayed on screen
    private boolean wind = true ;
    private boolean go_left = false ;
    private boolean go_right = false ;
    private boolean go_up = false ;
    private boolean go_down = false ;
    public Sprite(Component component,
    Image image,
    Point position,
    Point motionVector,
    boolean Wind
    //Seed a random number generator
    // for this sprite with the sprite
    // position.
    rand = new Random(position.x);
    this.component = component;
    this.image = image;
    setSpaceOccupied(new Rectangle(
    position.x,
    position.y,
    image.getWidth(component),
    image.getHeight(component)));
    this.motionVector = motionVector;
    this.wind = Wind ;
    //Compute edges of usable graphics
    // area in the Frame.
    int topBanner = ((Container)component).getInsets().top;
    int bottomBorder = ((Container)component).getInsets().bottom;
    int leftBorder = ((Container)component).getInsets().left;
    int rightBorder = ((Container)component).getInsets().right;
    bounds = new Rectangle( 0 + leftBorder, 0 + topBanner
    , component.getSize().width - (leftBorder + rightBorder)
    , component.getSize().height - (topBanner + bottomBorder));
    }//end constructor
    public void setMessage(int message_number)
    message = message_number ;
    public void setSpeed(int speed)
    max_speed = speed ;
    public void goLeft()
    go_left = true ;
    public void goRight()
    go_right = true ;
    public void goUp()
    go_up = true ;
    public void goDown()
    go_down = true ;
    public void setEaten()
    eaten = true ;
    setSpaceOccupied(new Rectangle(4000,4000,0,0)) ;
    public boolean getEaten()
    return eaten ;
    public Rectangle getSpaceOccupied()
    return spaceOccupied;
    }//end getSpaceOccupied()
    void setSpaceOccupied(Rectangle spaceOccupied)
    this.spaceOccupied = spaceOccupied;
    }//setSpaceOccupied()
    public void setSpaceOccupied(
    Point position){
    spaceOccupied.setLocation(
    position.x, position.y);
    }//setSpaceOccupied()
    public Point getMotionVector(){
    return motionVector;
    }//end getMotionVector()
    public void setMotionVector(
    Point motionVector){
    this.motionVector = motionVector;
    }//end setMotionVector()
    public void setBounds(Rectangle bounds)
    this.bounds = bounds;
    }//end setBounds()
    public void updatePosition()
    Point position = new Point(spaceOccupied.x, spaceOccupied.y);
    if (message != 0)
    return ;
    //Insert random behavior. During
    // each update, a sprite has about
    // one chance in 10 of making a
    // random change to its
    // motionVector. When a change
    // occurs, the motionVector
    // coordinate values are forced to
    // fall between -7 and 7. This
    // puts a cap on the maximum speed
    // for a sprite.
    if (!wind)
    if (go_left)
    motionVector.x -= 2 ;
    if (motionVector.x < -15)
    motionVector.x = -14 ;
    go_left = false ;
    if (go_right)
    motionVector.x += 2 ;
    if (motionVector.x > 15)
    motionVector.x = 14 ;
    go_right = false ;
    if (go_up)
    motionVector.y -= 2 ;
    if (motionVector.y < -15)
    motionVector.y = -14 ;
    go_up = false ;
    if (go_down)
    motionVector.y += 2 ;
    if (motionVector.y > 15)
    motionVector.y = 14 ;
    go_down = false ;
    else if(rand.nextInt() % 7 == 0)
    Point randomOffset =
    new Point(rand.nextInt() % 3,
    rand.nextInt() % 3);
    motionVector.x += randomOffset.x;
    if(motionVector.x >= max_speed)
    motionVector.x -= max_speed;
    if(motionVector.x <= -max_speed)
    motionVector.x += max_speed ;
    motionVector.y += randomOffset.y;
    if(motionVector.y >= max_speed)
    motionVector.y -= max_speed;
    if(motionVector.y <= -max_speed)
    motionVector.y += max_speed;
    }//end if
    //Move the sprite on the screen
    position.translate(motionVector.x, motionVector.y);
    //Bounce off the walls
    boolean bounceRequired = false;
    Point tempMotionVector = new Point(
    motionVector.x,
    motionVector.y);
    //Handle walls in x-dimension
    if (position.x < bounds.x)
    bounceRequired = true;
    position.x = bounds.x;
    //reverse direction in x
    tempMotionVector.x = -tempMotionVector.x;
    else if ((position.x + spaceOccupied.width) > (bounds.x + bounds.width))
    bounceRequired = true;
    position.x = bounds.x +
    bounds.width -
    spaceOccupied.width;
    //reverse direction in x
    tempMotionVector.x =
    -tempMotionVector.x;
    }//end else if
    //Handle walls in y-dimension
    if (position.y < bounds.y)
    bounceRequired = true;
    position.y = bounds.y;
    tempMotionVector.y = -tempMotionVector.y;
    else if ((position.y + spaceOccupied.height)
    > (bounds.y + bounds.height))
    bounceRequired = true;
    position.y = bounds.y +
    bounds.height -
    spaceOccupied.height;
    tempMotionVector.y =
    -tempMotionVector.y;
    }//end else if
    if(bounceRequired)
    //save new motionVector
    setMotionVector(
    tempMotionVector);
    //update spaceOccupied
    setSpaceOccupied(position);
    }//end updatePosition()
    public void drawSpriteImage(Graphics g)
    if (!eaten)
    g.drawImage(image,
    spaceOccupied.x,
    spaceOccupied.y,
    component);
    }//end drawSpriteImage()
    public boolean testCollision(Sprite testSprite)
    //Check for collision with
    // another sprite
    if (testSprite != this)
    return spaceOccupied.intersects(
    testSprite.getSpaceOccupied());
    }//end if
    return false;
    }//end testCollision
    }//end Sprite class
    //===================================//
    Thanks for your help...

    Sorry,
    Can you tell me how do you solve it because I have got the same problem.
    Can you indicate me the topic where did you find solution.
    Thank in advance.

  • How do I convert my GUI java app to be an applet or display it on a webpage

    I have created a loan calculator program in netbeans, I got the application to run fine but now I want to add it into a html page.
    I'm just looking for a place to start, I just don't know where to go from here, I want to know if I can actually convert my app with a few changes to an applet or if any one can point me to a forum of similar interest or tutorials that explain what I'm looking for.
    I don't even know what i'm looking for except i want this program to run on a webpage.
    Or is there a way to run my .jar file on a webpage??
    My teacher has not taught us anything on this matter except the below code suggestions on converting and my program is more extensive than her examples for converting. This is what she briefly described on this subject.
    1.To convert an application to an applet the main differences are: import java.awt.Graphics; import javax.swing.JApplet; import javax.swing.JOptionPane;
         Extend JApplet Replace main with public void init() method
    Output with public void paint( Graphics g ) method
    2. Remove calls to setSize, setTitle, pack, and any window listener calls, e.g., setDefaultCloseOperation. Compile the program---if something doesn't compile just comment it out for now.
    3. Create a simple web page with the following body.
    <applet CODE="__________.class" WIDTH="300" HEIGHT="300"
    archive="http://www.cs.duke.edu/courses/fall01/cps108/resources/joggle.jar">
    Your browser does not support applets </applet>
    I understand those steps for a simple program like hello world but not my current app
    Heres my code on the 2 extend off my first GUI of the Loan Application
    public class AnalysisGUI extends GUI {
        /** Creates new form AnalysisGUI */
        public AnalysisGUI(java.awt.Frame parent, boolean modal) {
            super(parent, modal);
            initComponents();
        }//end constructor
        private DecimalFormat currency = new DecimalFormat("0.00");
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            analysisjButton = new javax.swing.JButton();
            jScrollPane1 = new javax.swing.JScrollPane();
            writejTextArea = new javax.swing.JTextArea();
            clearTextAreajButton = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            analysisjButton.setText("Analysis");
            analysisjButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    analysisjButtonActionPerformed(evt);
            writejTextArea.setColumns(20);
            writejTextArea.setRows(5);
            jScrollPane1.setViewportView(writejTextArea);
            clearTextAreajButton.setText("Clear Analysis Output");
            clearTextAreajButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    clearTextAreajButtonActionPerformed(evt);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(analysisjButton)
                        .addComponent(clearTextAreajButton))
                    .addGap(18, 18, 18)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 433, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(86, 86, 86))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap(306, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(analysisjButton)
                            .addGap(84, 84, 84)
                            .addComponent(clearTextAreajButton)
                            .addGap(113, 113, 113))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(22, 22, 22))))
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-700)/2, (screenSize.height-627)/2, 700, 627);
        }// </editor-fold>
        private void analysisjButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
            // TODO add your handling code here:   
            //importing values for FOR loop of 13 pyaments a years
            ir13 = super.rate;
            balance13 = super.balance;
            time13 = super.time;
            payment13 = MortgageCalculator.CalculatePayment(ir13, balance13, time13, PayperYear13);           
            interest13 = round((balance13 * (ir13/PayperYear13)));                   
            principle13 = round(payment13 - interest13);
            //set up for 12 pyaments a year
            balance = super.balance;          
            ir = super.rate;
            time = super.time;         
            payment = super.payment;
            interest = round((balance * (ir/PayperYear12)));
            principle = round(payment - interest);
            //set up for 24 payments a year   
            balance24 = super.balance;          
            ir24 = super.rate;
            time24 = super.time;         
            payment24 = super.payment/2;
            interest24 = round((balance24 * (ir/PayperYear24)));
            principle24 = round(payment24 - interest24);
            //set up for 26 payemnts a years
            ir26 = super.rate;
            balance26 = super.balance;
            time26 = super.time;
            payment26 = MortgageCalculator.CalculatePayment(ir26, balance26, time26, PayperYear26);           
            interest26 = round((balance26 * (ir26/PayperYear26)));                   
            principle26 = round(payment26 - interest26);
         double totalPrinciple = 0;              //set to zero
         double totalInterest = 0;          //set to zero       
         for( int n = 0; n < time; n++)     //check Year of Loan
                totalPrinciple = 0;          //reset to zero for totaling Year n totals
                totalInterest = 0;          //reset to zero for totaling Year n totals
                writejTextArea.append("-----Based on 12 Payments Per Year-----\n");
                writejTextArea.append("          "+"          "+"Principle" + "    " +
                    "Interest"+ "    "+
                    "Balance"+"\n");            
                //loops through the monthly payments
                for(int i = 1; i <= PayperYear12; i++ )
                //Calculate applied amounts for chart to be printed
                interest = round((balance * ir)/PayperYear12);
                principle = round(payment - interest);
                balance = round(balance - principle);
                //total year end amounts
                totalPrinciple = totalPrinciple + principle;
                totalInterest = totalInterest + interest;
                writejTextArea.append("Payment " + i + " $" + currency.format(principle) + "     " +
                    currency.format(interest) + "      $" +
                    currency.format(balance)+"\n");     
                }//end for 12 payments per year
                //print 12 payments Totals          
                int yr = n + 1;
                writejTextArea.append("\n---Year " + yr + " Totals Based on 12 Payments Per Year---");
                writejTextArea.append("\nYear Total Principle: $" + currency.format(totalPrinciple));
                writejTextArea.append("\nYear Total Interest: $" + currency.format(totalInterest));
                writejTextArea.append("\nRemaining Balance: $" + currency.format(balance)+"\n");
                writejTextArea.append("\n-------------------------------------------------------\n");     
                //Start 13 PAYMENTS A YEAR TABLE
                double totalPrinciple13 = 0;          //reset to zero for totaling Year n totals
                double totalInterest13 = 0;          //reset to zero for totaling Year n totals
                writejTextArea.append("-----Based on 13 Payments Per Year-----\n");   
                writejTextArea.append("          "+"          "+"Principle" + "    " +
                    "Interest"+ "    "+
                    "Balance"+"\n");            
                //loops through the monthly 13 payments           
                for(int j = 1; j <= PayperYear13; j++ )
                //Calculate applied amounts for chart to be printed
                interest13 = round((balance13 * ir13)/PayperYear13);
                principle13 = round(payment13 - interest13);
                balance13 = round(balance13 - principle13);
                //total year end amounts
                totalPrinciple13 = totalPrinciple13 + principle13;
                totalInterest13 = totalInterest13 + interest13;
                //System.out.printf("\n%-10s %-10s %-10s %-10s %-10s", n + 1 , i + 1,Principle, Interest, Balance);
                //System.out.printf("\n%-10s %-10s %-10.2f %-10.2f %-10.2f", n + 1 , i + 1,round(principle), round(interest), balance);
                writejTextArea.append("Payment " + j + " $" + currency.format(principle13) + "     " +
                    currency.format(interest13) + "      $" +
                    currency.format(balance13)+"\n");         
                }//end for 13 payments per year
                //Print totals for 13 payments a year          
                yr = n + 1;
                writejTextArea.append("\n---Year " + yr + " Totals Based on 13 Payments Per Year---");
                writejTextArea.append("\nYear Total Principle: $" + currency.format(totalPrinciple13));
                writejTextArea.append("\nYear Total Interest: $" + currency.format(totalInterest13));
                writejTextArea.append("\nRemaining Balance: $" + currency.format(balance13)+"\n");
                writejTextArea.append("\n-------------------------------------------------------\n");             
                //Start 24 PAYMENTS A YEAR TABLE
                double totalPrinciple24 = 0;          //reset to zero for totaling Year n totals
                double totalInterest24 = 0;          //reset to zero for totaling Year n totals
                writejTextArea.append("-----Based on 24 Payments Per Year-----\n");
                writejTextArea.append("          "+"          "+"Principle" + "    " +
                    "Interest"+ "    "+
                    "Balance"+"\n");            
                //loops through the monthly payments
                for(int i = 1; i <= PayperYear24; i++ )
                //Calculate applied amounts for chart to be printed
                interest24 = round((balance24 * ir24)/PayperYear24);
                principle24 = round(payment24 - interest24);
                balance24 = round(balance24 - principle24);
                //total year end amounts
                totalPrinciple = totalPrinciple + principle24;
                totalInterest = totalInterest + interest24;
                writejTextArea.append("Payment " + i + " $" + currency.format(principle24) + "     " +
                    currency.format(interest24) + "      $" +
                    currency.format(balance24)+"\n"); 
                }//end for 24 payments per year
                //print 24 payments Totals
                yr = n +1;
                writejTextArea.append("\n---Year " + yr + " Totals Based on 24 Payments Per Year---");
                writejTextArea.append("\nYear Total Principle: $" + currency.format(totalPrinciple24));
                writejTextArea.append("\nYear Total Interest: $" + currency.format(totalInterest24));
                writejTextArea.append("\nRemaining Balance: $" + currency.format(balance24)+"\n");
                writejTextArea.append("\n-------------------------------------------------------\n");                        
                //Start 26 PAYMENTS A YEAR TABLE
                double totalPrinciple26 = 0;//reset to zero for totaling Year n totals
                double totalInterest26 = 0;     //reset to zero for totaling Year n totals
                writejTextArea.append("------Based on 26 Payments Per Year-----\n");
                writejTextArea.append("          "+"          "+"Principle" + "    " +
                    "Interest"+ "    "+
                    "Balance"+"\n");            
                //loops through the monthly payments 26 times
                for(int i = 1; i <= PayperYear26; i++ )
                //Calculate applied amounts for chart to be printed
                interest26 = round((balance26 * ir24)/PayperYear26);
                principle26 = round(payment26 - interest26);
                balance26 = round(balance26 - principle26);
                totalPrinciple = totalPrinciple + principle26;
                totalInterest = totalInterest + interest26;
                writejTextArea.append("Payment " + i + "  $" + currency.format(principle26) + "     " +
                    currency.format(interest26) + "      $" +
                    currency.format(balance26)+"\n");
                }//end for 26 payments per year           
                yr = n + 1;
                //prints 26 payments yearly totals
                writejTextArea.append("\n---Year " + yr + " Totals Based on 26 Payments Per Year---");
                writejTextArea.append("\nYear Total Principle: $" + currency.format(totalPrinciple26));
                writejTextArea.append("\nYear Total Interest: $" + currency.format(totalInterest26));
                writejTextArea.append("\nRemaining Balance: $" + currency.format(balance26)+"\n");
                writejTextArea.append("\n-------------------------------------------------------\n");                
            }//end for years of the loan
        private void clearTextAreajButtonActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            //clear analysis field
            writejTextArea.setText("");
        public static double round(double r)//round to cents method
              return Math.ceil(r*100)/100;
         }//end round  
        /**HI micha what a long progam
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    AnalysisGUI dialog = new AnalysisGUI(new javax.swing.JFrame(), true);
                    dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                        public void windowClosing(java.awt.event.WindowEvent e) {
                            System.exit(0);
                    dialog.setVisible(true);
            });//end announymous
        }//end main mehtod
        //12 year declared varialbes
        //private double balance;   
        private double principle;
        private double ir;
        private double interest;
        private double PayperYear12 = 12;
        //Variables for 13 payments a years
        private int PayperYear13 = 13;
        private double balance13;
        private double principle13;
        private double ir13;
        private double interest13;
        private double payment13;
        private double time13;
        //Varialbes for 24 payments a year
        private int PayperYear24 = 24;
        private double balance24;
        private double principle24;
        private double ir24;
        private double interest24;
        private double payment24;
        private double time24;
        //Varialbes for 24 payments a year
        private int PayperYear26 = 26;
        private double balance26;
        private double principle26;
        private double ir26;
        private double interest26;
        private double payment26;
        private double time26;
        // Variables declaration - do not modify
        private javax.swing.JButton analysisjButton;
        private javax.swing.JButton clearTextAreajButton;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea writejTextArea;

    Your original program extends "GUI" which appears to extend JFrame (correct me if I'm wrong). If so, the first thing you should do would be to re-write this so that it extends JPanel which shouldn't be that hard to do (at least it's not hard to do if you know a little Swing -- but I worry about someone coming into this from the netbeans-generated code world). Purists will tell you to not even extend this, to have your main GUI class hold an instance of JPanel instead, and this would work fine too, as long as one way or another, the main GUI program can produce your application displayed on a JPanel on demand.
    If you've done this correctly, then using your JPanel in a JFrame is trivial: in a main method create a JFrame, and then simply add your JPanel to the JFrame's contentPane and display it. Likewise using your JPanel in a JApplet is just as trivial as you'd do essentially the same thing: add your JPanel to the JApplet's contentPane, but this time do it in the JApplet's init method.

  • Problem in converting char * to java objects

    Hi All,
    When I am trying to compile the following JNI code, I am getting the under-mentioned errors.
    <code>
    JNIEXPORT jboolean JNICALL Java_XXXAPI_nativeCheckSomeAccess
    (JNIEnv *jnv, jobject jobj, jstring fresource, jstring uname){
         jboolean accessible;
         int     ierror;
         // convert jstring to char pointers
         const char resname = (jnv)->GetStringUTFChars(jnv, fresource, 0);
         const char u = (jnv)->GetStringUTFChars(jnv, uname, 0);
         // pass parameters and check access
         int canAccess = checkSomeAccess(resname, user, &ierror);
         if(!ierror && canAccess == 1)
              accessible = true;
         else
              accessible = false;
         // release variables from JNI environment
         (*jnv)->ReleaseStringUTFChars(jnv, fresource, resname);
         (*jnv)->ReleaseStringUTFChars(jnv, uname, u);
         return accessible;
    the checkSomeAccess in "someCfile.h" actually looks like this:
    int checkSomeAccess(char resname, char u, <enumeration> *ptr_to_enum_containing_integers);
    </code>
    When compiled the code... I am getting the following errors:
    some_jni.c: In function `Java_XXXAPI_nativeCheckSomeAccess':
    some_jni.c:65: warning: passing arg 1 of `checkSomeAccess' discards qualifiers from pointer target type
    some_jni.c:65: warning: passing arg 2 of `checkSomeAccess' discards qualifiers from pointer target type
    some_jni.c:65: warning: passing arg 3 of `checkSomeAccess' from incompatible pointer type
    some_jni.c:67: `true' undeclared (first use in this function)
    some_jni.c:69: `false' undeclared (first use in this function)
    Please tell me, what is the problem here.
    thank you,
    Ran.

    Hi All,
    How to convert an enum in C to Java-JNI ? I have the following enum defined in C.
    typedef enum{
        ERR_NOERROR=0,
        ERR_INTERNAL,
        ERR_NOOBJECT,
        ERR_INVALIDOBJ,
    }error_t;I am using this enum in my C function (in the header file) as:
    int isSuccess(char* some_name, error_t *error);Now, while writing the JNI implementation for this, I have actually passed an integer which is giving compile time warning:
    int result;
    char *sn = (char*)(*env)->GetStringUTFChars(env, jstring_val, 0);
    int errorCode;
    result = isSuccess(sn, &errorCode);I would like to know, how to represent the enum type in JNI. It would be grateful If you provide an example code snippet.
    thanks in advance,
    Ran.

  • Trying to convert String to java.sql.Date

    I need to convert a String (in the format "yyyy-mm-dd") to java.sql.Date
    It was suggested I use the following,
    SimpleDateFormat formater = new SimpleDateFormat("yyyy-mm-dd");
    Date result = formater.parse(dbirth.getText());
    However, It seem to produce a java.util.Date
    Error: found java.util.Date
    Required : java.sql.Date
    Can anyone help?
    Thanks, Marika

    I need to convert a String (in the format
    "yyyy-mm-dd") to java.sql.Date
    It was suggested I use the following,
    SimpleDateFormat formater = new
    SimpleDateFormat("yyyy-mm-dd");
    Date result = formater.parse(dbirth.getText());
    However, It seem to produce a java.util.Date
    Error: found java.util.Date
    Required : java.sql.Date
    Can anyone help?
    Thanks, Marika SimpleDateFormat formater = new SimpleDateFormat("yyyy-mm-dd");
    java.util.Date parsedDate = formater.parse(dbirth.getText());
    java.sql.Date result = new java.sql.Date(parsedDate.getTime());

Maybe you are looking for

  • Unable to capture analog video.

    Hi, I am running Premier Pro CS3 on a Windows XP machine. This is a new machine to me provided by my work. I am trying to capture analog video from a VHS deck that has both S-video and composite outs. The IT folks installed an ATI TV Wonder HD 650 PC

  • Mutipart/form data in request

    Hi to All, I need to get the form bean object values in filter class from the request for doing some validation. For get request there is no problem to get the data from the request. But for the 'multipart/form-data' after reading the data in filter

  • Retrieving data from different node in SQL

    Hi friends, First of all:         BANNER 1     Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 2     PL/SQL Release 11.2.0.3.0 - Production 3     CORE     11.2.0.3.0     Production 4     TNS for Linux: Version 11.2.0.3.0

  • Spool sending as an Email

    Dear Experts. I have build 2 reports which both are running as a job. - the first one  creates a List with the Information and save it as a spool - the second runs directly after the first and sent the spool has been created as an email. Now I'd like

  • How to handle The Date error???

    Actually I am using three dropdown list as day,month and year day contains 31 items and same values i.e., 1,2,3...31 and month contains jan,feb,....dec year 1981,1982,.....2007 and I am concateded these three to form date as d:=:day||'-'||:month||'-'