RE:making  java applet of a java code

Hi all,
I have built a GUI using netbeans.I use this application to connect to server to upload files as well as to update database.Now I want to make this application web enabled.I want to make it applet.But I do not how to do this.
Can please anyone help me regarding this?I would really appreciate that.
Thanks

The best way to get the app. on-screen would be to use web start. If it is coming from the same server, it can probably be 'sandboxed'.
Web start apps. can be launched* from a link on a web page, and there is no need to convert applications to applets, as Java Web Start can launch either.
* E.G. of JWS launch of (combined) application/applet
<http://www.physci.org/jws/#jtest>
(Check some of the other links on my 'JWS examples' page for more of a look at JWS in operation)

Similar Messages

  • �� I have a java applet program (yanhua.java) need help!!!

    �� I have a java applet program (yanhua.java) that use mouse click a area show a fireworks, the applet program that a java fan mail me. Now i find some bug in the program, can you help me? thank in advance!
    The backdrop of the question: The yanhua.java applet program works well. But one day, i install j2re 1.4.1 plugin for my microsfot Internet Explorer, i run the yanhua.java applet program again, it show difficult(i move my mouse in the area, slowness), the fireworks is not fluent. Then i try my best to find the cause , i get some information, the following: yanhua.java run in j2re 1.4.1 plugin,it will deplete 100% cpu; else yanhua.java does not run in j2re 1.4.1 plugin, it will deplete 90%--95% cpu too; but my computer c3 1G cpu and 256MB memory, without running other program at that time. So i can have the assurance to say that the yanhua.java have some bug or error. can you help me to find all bug in yanhua.java? thank you very much!!!
    i want to solve the question: finding all bug in yanhua.java
    NOTE:
    1��fireworks show specially good effect(a yanhua.java applet) you can look at:
    http://www.3ren.net/down/java/yanhua.html
    2��all program you can get from http://www.3ren.net/down/java/yanhua.rar
    /*************************yanhua.java******************************
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.awt.*;
    import java.awt.image.MemoryImageSource;
    import java.util.Random;
    public class yanhua extends Applet
    implements Runnable
    private int m_nAppX;
    private int m_nAppY;
    private int m_centerX;
    private int m_centerY;
    private int m_mouseX;
    private int m_mouseY;
    private int m_sleepTime;
    private boolean isError;
    private boolean m_isPaintFinished;
    boolean isRunning;
    boolean isInitialized;
    Thread runner;
    int pix0[];
    MemoryImageSource offImage;
    Image dbImg;
    int pixls;
    int pixls2;
    Random rand;
    int bits;
    double bit_px[];
    double bit_py[];
    double bit_vx[];
    double bit_vy[];
    int bit_sx[];
    int bit_sy[];
    int bit_l[];
    int bit_f[];
    int bit_p[];
    int bit_c[];
    int bit_max;
    int bit_sound;
    int ru;
    int rv;
    AudioClip sound1;
    AudioClip sound2;
    public yanhua()
    m_mouseX = 0;
    m_mouseY = 0;
    m_sleepTime = 5;
    isError = false;
    isInitialized = false;
    rand = new Random();
    bits = 10000;
    bit_px = new double[bits];
    bit_py = new double[bits];
    bit_vx = new double[bits];
    bit_vy = new double[bits];
    bit_sx = new int[bits];
    bit_sy = new int[bits];
    bit_l = new int[bits];
    bit_f = new int[bits];
    bit_p = new int[bits];
    bit_c = new int[bits];
    ru = 50;
    rv = 50;
    public void init()
    String s = getParameter("para_bits");
    if(s != null)
    bits = Integer.parseInt(s);
    s = getParameter("para_max");
    if(s != null)
    bit_max = Integer.parseInt(s);
    s = getParameter("para_blendx");
    if(s != null)
    ru = Integer.parseInt(s);
    s = getParameter("para_blendy");
    if(s != null)
    rv = Integer.parseInt(s);
    s = getParameter("para_sound");
    if(s != null)
    bit_sound = Integer.parseInt(s);
    m_nAppX = this.getSize().width;
    m_nAppY = this.getSize().height;
    m_centerX = m_nAppX / 2;
    m_centerY = m_nAppY / 2;
    m_mouseX = m_centerX;
    m_mouseY = m_centerY;
    resize(m_nAppX, m_nAppY);
    pixls = m_nAppX * m_nAppY;
    pixls2 = pixls - m_nAppX * 2;
    pix0 = new int[pixls];
    offImage = new MemoryImageSource(m_nAppX, m_nAppY, pix0, 0, m_nAppX);
    offImage.setAnimated(true);
    dbImg = createImage(offImage);
    for(int i = 0; i < pixls; i++)
    pix0[i] = 0xff000000;
    sound1 = getAudioClip(getDocumentBase(), "firework.au");
    sound2 = getAudioClip(getDocumentBase(), "syu.au");
    for(int j = 0; j < bits; j++)
    bit_f[j] = 0;
    isInitialized = true;
    start();
    public void run()
    while(!isInitialized)
    try
    Thread.sleep(200L);
    catch(InterruptedException interruptedexception) { }
    do
    for(int j = 0; j < pixls2; j++)
    int k = pix0[j];
    int l = pix0[j + 1];
    int i1 = pix0[j + m_nAppX];
    int j1 = pix0[j + m_nAppX + 1];
    int i = (k & 0xff0000) >> 16;
    int k1 = ((((l & 0xff0000) >> 16) - i) * ru >> 8) + i;
    i = (k & 0xff00) >> 8;
    int l1 = ((((l & 0xff00) >> 8) - i) * ru >> 8) + i;
    i = k & 0xff;
    int i2 = (((l & 0xff) - i) * ru >> 8) + i;
    i = (i1 & 0xff0000) >> 16;
    int j2 = ((((j1 & 0xff0000) >> 16) - i) * ru >> 8) + i;
    i = (i1 & 0xff00) >> 8;
    int k2 = ((((j1 & 0xff00) >> 8) - i) * ru >> 8) + i;
    i = i1 & 0xff;
    int l2 = (((j1 & 0xff) - i) * ru >> 8) + i;
    int i3 = ((j2 - k1) * rv >> 8) + k1;
    int j3 = ((k2 - l1) * rv >> 8) + l1;
    int k3 = ((l2 - i2) * rv >> 8) + i2;
    pix0[j] = i3 << 16 | j3 << 8 | k3 | 0xff000000;
    rend();
    offImage.newPixels(0, 0, m_nAppX, m_nAppY);
    try
    Thread.sleep(m_sleepTime);
    catch(InterruptedException interruptedexception1) { }
    } while(true);
    public void update(Graphics g)
    paint(g);
    public void paint(Graphics g)
    g.drawImage(dbImg, 0, 0, this);
    public void start()
    if(isError)
    return;
    isRunning = true;
    if(runner == null)
    runner = new Thread(this);
    runner.start();
    public void stop()
    if(runner != null)
    runner.stop();
    runner = null;
    public boolean mouseMove(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    return true;
    public boolean mouseDown(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    int k = (int)(rand.nextDouble() * 256D);
    int l = (int)(rand.nextDouble() * 256D);
    int i1 = (int)(rand.nextDouble() * 256D);
    int j1 = k << 16 | l << 8 | i1 | 0xff000000;
    int k1 = 0;
    for(int l1 = 0; l1 < bits; l1++)
    if(bit_f[l1] != 0)
    continue;
    bit_px[l1] = m_mouseX;
    bit_py[l1] = m_mouseY;
    double d = rand.nextDouble() * 6.2800000000000002D;
    double d1 = rand.nextDouble();
    bit_vx[l1] = Math.sin(d) * d1;
    bit_vy[l1] = Math.cos(d) * d1;
    bit_l[l1] = (int)(rand.nextDouble() * 100D) + 100;
    bit_p[l1] = (int)(rand.nextDouble() * 3D);
    bit_c[l1] = j1;
    bit_sx[l1] = m_mouseX;
    bit_sy[l1] = m_nAppY - 5;
    bit_f[l1] = 2;
    if(++k1 == bit_max)
    break;
    if(bit_sound > 1)
    sound2.play();
    return true;
    public boolean mouseExit(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    return true;
    void rend()
    boolean flag = false;
    boolean flag1 = false;
    boolean flag2 = false;
    for(int k = 0; k < bits; k++)
    switch(bit_f[k])
    default:
    break;
    case 1: // '\001'
    bit_vy[k] += rand.nextDouble() / 50D;
    bit_px[k] += bit_vx[k];
    bit_py[k] += bit_vy[k];
    bit_l[k]--;
    if(bit_l[k] == 0 || bit_px[k] < 0.0D || bit_py[k] < 0.0D || bit_px[k] > (double)m_nAppX || bit_py[k] > (double)(m_nAppY - 3))
    bit_c[k] = 0xff000000;
    bit_f[k] = 0;
    } else
    if(bit_p[k] == 0)
    if((int)(rand.nextDouble() * 2D) == 0)
    bit_set((int)bit_px[k], (int)bit_py[k], -1);
    } else
    bit_set((int)bit_px[k], (int)bit_py[k], bit_c[k]);
    break;
    case 2: // '\002'
    bit_sy[k] -= 5;
    if((double)bit_sy[k] <= bit_py[k])
    bit_f[k] = 1;
    flag2 = true;
    if((int)(rand.nextDouble() * 20D) == 0)
    int i = (int)(rand.nextDouble() * 2D);
    int j = (int)(rand.nextDouble() * 5D);
    bit_set(bit_sx[k] + i, bit_sy[k] + j, -1);
    break;
    if(flag2 && bit_sound > 0)
    sound1.play();
    void bit_set(int i, int j, int k)
    int l = i + j * m_nAppX;
    pix0[l] = k;
    /*********************************end*******************************

    no one help me???????????

  • Safari won't load Java applet? (latest Java 7 update 51)

    Hello,
    I am trying to use the following website:
    http://kidsnvue.com
    It is a portal that allows me to watch my child at daycare over the internet with a password.  The trouble is that the video works with Java 7. 
    So every since I downloaded Java 7 update 51 (the latest update) then no matter how I configure my security settings I get the message "Application Blocked.  Your security settings have blocked an untrusted application from running". 
    Even if I go into the security settings and try every different option like "Run in Unsafe Mode".  I still get blocked from running this website....  This wasn't a problem with the previous versions of Java 7... 
    However Mavericks won't even let me run a previous version of Java.   When I try to do that I get the message that my Java is not up to date and it tells me to update it before loading anything in Java... 
    Any advice on how I can get this website to run in Safari (or even in another browser)? 
    Thanks!

    Hi Richie
    the logs are pretty specific about what's happened...
    Symbol not found: _ZNK3KJS9ObjectImp11hasPropertyEPNS9ExecStateEj
    Referenced from: /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.frame work/Versions/A/WebCore
    Expected in: /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/JavaScriptCor e.framework/Versions/A/JavaScriptCore
    which is a long-winded way of saying that Javascript core is missing or corrupted. Likely due to a software update failing part way through.
    Do you have any other browsers available on the iBook? if so it might be possible to attempt running an OS update which would replace the file.
    The 'official' line is an archive & install, but armed with a 3rd party app it is possible to extract the file from your install disks and replace it manually - of course this does involve some messing in the System folder, but isn't all that difficult in my opinion.
    You probably can't copy the file from another mac, unless you have access to another one running 10.4
    Let us know how you'd like to proceed - I'm happy to give detailed instructions on replacing the file; it's not an uncommon problem that you have. I've posted several times before on this, so I'll try to find an earlier thread - at least that will give you an idea of what's involved.
    Andy

  • How to run a Java applet on a website.

    Hi,
    I am trying to run the code below [DrawLines.java|http://www.dgp.toronto.edu/~mjmcguff/learn/java/01-drawingLines/]
    import java.applet.*;
    import java.awt.*;
    public class DrawingLines extends Applet {
       int width, height;
       public void init() {
          width = getSize().width;
          height = getSize().height;
          setBackground( Color.black );
       public void paint( Graphics g ) {
          g.setColor( Color.green );
          for ( int i = 0; i < 10; ++i ) {
             g.drawLine( width, height, i * width / 10, 0 );
    on my website . I compiled it using JDK1.6.0_21 on Windows 7 and generated DrawingLines.class (My site is hosted on a linux server, is this an issue since it was compiled on Windows?)
    I created a html file:
    <applet width=300 height=300 code="/shanegibney/classes/DrawingLines.class"> </applet>Then I created a new folder called 'classes' in my public directory.
    I get the following error:
    java.lang.NoClassDefFoundError: /shanegibney/classes/DrawingLines (wrong name: DrawingLines)
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClassCond(Unknown Source)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.NoClassDefFoundError: /shanegibney/classes/DrawingLines (wrong name: DrawingLines)I'm sure adding a java applet is very common. Does anyone have any ideas why this isn't working? It can be seen here .
    Any help would be greatly appreciated,
    Thanks,
    Shane
    Edited by: ofey on Jul 9, 2010 4:21 PM

    I believe it's interpreting some of the code attribute as a path. Try this:
    <applet width=300 height=300 codebase="/shanegibney/classes/" code="DrawingLines"> </applet>

  • Problem Running a java applet from an HTML page

    I can run my applet at the command prompt with:
    appletviewer coffee.html
    But when I try and open the Coffee.html by opening
    the page in Internet Explorer I get the following message:
    Can't find Database driver class: java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
    Code: createcoffees.java
    import java.applet.*;
    import java.sql.*;
    public class CreateCoffees extends Applet{
         public void init() {
              Statement stmt;
              Connection con;
              try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              } catch(java.lang.ClassNotFoundException e) {
                   System.err.print("ClassNotFoundException: ");
                   System.err.println(e.getMessage());
              try {con = DriverManager.getConnection("jdbc:odbc:hq","afm", "afm");
                   stmt = con.createStatement();                                   
                          stmt.executeQuery("SELECT * FROM RM");
                   stmt.close();
                   con.close();
              } catch(SQLException ex) {
                   System.err.println("SQLException: " + ex.getMessage());
    }

    Is your jdbc-odbc driver properly loaded? Its very clear that its a class not found exception which is thrown by this:
    try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());

  • Java Applet Constantly Asks for Authentication

    With have a ADF application on Weblogic 10 that has occasional access to a Java applet. The Java applet is loaded whenever it's needed and not loaded whenever it isn't in a facet. The applet is currently in the public_html/applet folder.
    When we set the SSL configuration to requiring a client certificate, when the Java applet loads, it'll constantly ask for a client certificate even though the user already presented the client when hitting the website:
    Request Authentication Identification required. Please select certificate to be used for authentication.
    This is annoying to users and the Java Applet doesn't need authentication. Is there any way we can disable the authentication or remove the prompt?
    Here's the embedded applet code:
    <applet height="1" width="1" code="applet.Applet.class"archive="/app/applet/SApplet.jar" /><param name="permissions" value="all-permissions"/></applet>
    Things I've already tried:
    1) Setting the Applet up on HTTP instead of HTTPS; I get a warning about mixed content and still get the authentication pop-up.
    2) Created a minimal applet that only types out "HELLO WORLD" in the console, still get the authentication pop-up
    Here's the console window:
    Java Plug-in 1.6.0_35
    Using JRE version 1.6.0_35-b10 Java HotSpot(TM) Client VM
    User home directory = C:\Users\mfan
    security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
    security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws
    security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws
    security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy
    security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy
    security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
    security: property package.definition value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
    security: property package.definition new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws
    security: property package.definition value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws
    security: property package.definition new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy
    security: property package.definition value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy
    security: property package.definition new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
    security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
    security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
    security: property package.definition value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
    security: property package.definition new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
    basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1df073d
    basic: Plugin2ClassLoader.addURL parent called for https://192.168.130.99/app/applet/HelloWorld.jar
    network: Cache entry not found [url: https://192.168.130.99/app/applet/HelloWorld.jar, version: null]
    network: Connecting https://192.168.130.99/app/applet/HelloWorld.jar with proxy=DIRECT
    network: Connecting http://192.168.130.99:443/ with proxy=DIRECT
    security: Loading Root CA certificates from C:\Program Files (x86)\Java\jre6\lib\security\cacerts
    security: Loaded Root CA certificates from C:\Program Files (x86)\Java\jre6\lib\security\cacerts
    security: Loading SSL Root CA certificates from C:\Users\mfan\AppData\LocalLow\Sun\Java\Deployment\security\trusted.jssecacerts
    security: Loaded SSL Root CA certificates from C:\Users\mfan\AppData\LocalLow\Sun\Java\Deployment\security\trusted.jssecacerts
    security: Loading SSL Root CA certificates from C:\Program Files (x86)\Java\jre6\lib\security\cacerts
    security: Loaded SSL Root CA certificates from C:\Program Files (x86)\Java\jre6\lib\security\cacerts
    security: Loading Deployment SSL certificates from C:\Users\mfan\AppData\LocalLow\Sun\Java\Deployment\security\trusted.jssecerts
    security: Loaded Deployment SSL certificates from C:\Users\mfan\AppData\LocalLow\Sun\Java\Deployment\security\trusted.jssecerts
    security: Loading certificates from Deployment session certificate store
    security: Loaded certificates from Deployment session certificate store
    security: Loading certificates from Internet Explorer ROOT certificate store
    security: Loaded certificates from Internet Explorer ROOT certificate store
    security: Checking if certificate is in Deployment denied certificate store
    security: Checking if certificate is in Deployment session certificate store
    security: Checking if SSL certificate is in Deployment permanent certificate store
    security: KeyUsage does not allow digital signatures
    (and here's where the prompt comes up).

    Actually, setting the archive to http://URL works fine. No more request authentications come up.

  • Help plotting points in a java Applet using Bresens Algorithm

    Hi,
    I am trying to compile my code and it doesn't like POINT. I am guesing I am using the wrong thing.
    Point.point(Math.round(x), Math.round(y)); and I tried just Point.
    How do I plot points so that it forms a line. What internal function do I use?
    Here is my code.
    import java.applet.*;
    import java.awt.*;
    import java.lang.Math;
    import java.awt.Point;
    import java.awt.Graphics;
    public class DDASimple extends Applet
         int   dx, dy, steps, k, absolutex, absolutey;
         float xinc, yinc, x, y;
       public void init()
    public void paint(Graphics g)
    DDASMPL(50,50,100,150);
    public void DDASMPL(int x1, int y1, int x2, int y2)
      repaint();
      dx = (x2-x1);
      dy = (y2-y1);
    //absolutex =
      if( Math.abs(dx) > Math.abs(dy))
         steps = Math.abs(dx);
      else
         steps = Math.abs(dy);
         xinc = dx / steps;
         yinc = dy / steps;
         x = x1;
         y = y1;
    Point.point(x1, y1);
          for (k = 1; k < steps; k++)
              x = x+ xinc;
              y = y + yinc;
    Point.point(Math.round(x), Math.round(y));
    //g.drawOval(Math.round(x), Math.round(y));
         }//end else
    }//end function dda
    }//end class ddda applet

    I took out the repaint(). and below is the updated version
    I am not getting anything now, no line
    import java.applet.*;
    import java.awt.*;
    import java.lang.Math;
    import java.awt.Point;
    import java.awt.Graphics;
    public class DDASimple extends Applet
         int   dx, dy, steps, k, absolutex, absolutey;
         float xinc, yinc, x, y;
       public void init()
    public void paint(Graphics g)
    DDASMPL(160, 140, 220, 140, g);
    public void DDASMPL(int x1, int y1, int x2, int y2, Graphics g)
      dx = (x2-x1);
      dy = (y2-y1);
    //absolutex =
      if( Math.abs(dx) > Math.abs(dy))
         steps = Math.abs(dx);
      else
         steps = Math.abs(dy);
         xinc = dx / steps;
         yinc = dy / steps;
         x = x1;
         y = y1;
    //Point xxx = new Point(x1, y1);
    g.fillRect(x1, y1, 1, 1);
          for (k = 1; k < steps; k++)
              x = x+ xinc;
              y = y + yinc;
    //Point.point(Math.round(x), Math.round(y));
    g.fillRect(Math.round(x), Math.round(y),1 ,1);
         }//end else
    }//end function dda
    }//end class ddda applet

  • Need help with Java applet, might need NetBeans URL

    I posted the below question. It was never answered, only I was told to post to the NetBeans help forum. Yet I don't see any such forum on this site. Can someone tell me where the NetBeans help forum is located (URL).
    Here is my original question:
    I have some Java source code from a book that I want to compile. The name of the file is HashTest.java. In order to compile and run this Java program I created a project in the NetBeans IDE named javaapplication16, and I created a class named HashTest. Once the project was created, I cut and pasted the below source code into my java file that was default created for HashTest.java.
    Now I can compile and build the project with no errors, but when I try and run it, I get a dialog box that says the following below (Ignore the [...])
    [..................Dialog Box......................................]
    Hash Test class wasn't found in JavaApplication16 project
    Select the main class:
    <No main classes found>
    [..................Dialog Box......................................]
    Does anyone know what the problem is here? Why won't the project run?
    // Here is the source code: *****************************************************************************************************
    import java.applet.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import java.util.*;
    public class HashTest extends Applet implements ItemListener
    // public static void main(String[] args) {
    // Hashtable to add tile images
    private Hashtable imageTable;
    // a Choice of the various tile images
    private Choice selections;
    // assume tiles will have the same width and height; this represents
    // both a tile's width and height
    private int imageSize;
    // filename description of our images
    private final String[] filenames = { "cement.gif", "dirt.gif", "grass.gif",
    "pebbles.gif", "stone.gif", "water.gif" };
    // initializes the Applet
    public void init()
    int n = filenames.length;
    // create a new Hashtable with n members
    imageTable = new Hashtable(n);
    // create the Choice
    selections = new Choice();
    // create a Panel to add our choice at the bottom of the window
    Panel p = new Panel();
    p.add(selections, BorderLayout.SOUTH);
    p.setBackground(Color.RED);
    // add the Choice to the applet and register the ItemListener
    setLayout(new BorderLayout());
    add(p, BorderLayout.SOUTH);
    selections.addItemListener(this);
    // allocate memory for the images and load 'em in
    for(int i = 0; i < n; i++)
    Image img = getImage(getCodeBase(), filenames);
    while(img.getWidth(this) < 0);
    // add the image to the Hashtable and the Choice
    imageTable.put(filenames[i], img);
    selections.add(filenames[i]);
    // set the imageSize field
    if(i == 0)
    imageSize = img.getWidth(this);
    } // init
    // tiles the currently selected tile image within the Applet
    public void paint(Graphics g)
    // cast the sent Graphics context to get a usable Graphics2D object
    Graphics2D g2d = (Graphics2D)g;
    // save the Applet's width and height
    int width = getSize().width;
    int height = getSize().height;
    // create an AffineTransform to place tile images
    AffineTransform at = new AffineTransform();
    // get the currently selected tile image
    Image currImage = (Image)imageTable.get(selections.getSelectedItem());
    // tile the image throughout the Applet
    int y = 0;
    while(y < height)
    int x = 0;
    while(x < width)
    at.setToTranslation(x, y);
    // draw the image
    g2d.drawImage(currImage, at, this);
    x += imageSize;
    y += imageSize;
    } // paint
    // called when the tile image Choice is changed
    public void itemStateChanged(ItemEvent e)
    // our drop box has changed-- redraw the scene
    repaint();
    } // HashTest

    BigDaddyLoveHandles wrote:
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    That wasn't attention-grabbing enough apparantly. Let's try it again.
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}

  • Java Applets and Packages

    Hi
    I have been having problems calling my own packages in java applets to no avail
    For a basic example i am storing graphics in a package called graphics and i have a class with a drawline function.
    How would i call this in my main program?
    At the top of the code i have imported the correct package using import useful.oh;
    I have tried the "oh oh = new oh();" which does not cause any compile errors however it doesnt result in a line on screen.
    I have also tried the oh.doIt(); function as suggested in some books, but java seems to dislike this and say it cannot find symbol doIt()
    Any help would be greatly appreciated!
    Excuse the formatting
    Thanks
    J Selby
    The package code:
    package useful;
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class oh {
    public void paint(Graphics g) {
    g.drawRect(100,50,200,50);
    The applet code:
    //Declare Java Libraries
    import useful.*;
    import java.lang.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class calculator extends Applet
         Font screen = new Font("Tahoma", Font.BOLD, 11);
         public void init()
         // Set null layout - Gives freedom for button placement
         setSize(400,400);
         setBackground(new Color(36, 48, 74));
         setLayout(null);
    Button exit = new Button("Exit");
         Button go = new Button("Go");
         add(exit);
         exit.setLocation(155,10);
              exit.setSize(40,22);
    add(go);
         go.setLocation(120,10);
         go.setSize(25,22);
    Choice tech=new Choice();
    tech.addItem("Tutorial Menu");
    tech.addItem("Applet A");
    tech.addItem("Applet B");
    tech.addItem("Applet C");
    tech.addItem("Applet D");
    tech.addItem("Applet E");
    tech.addItem("Java Quiz");     
    add(tech);
         tech.setLocation(10,10);
         oh oh = new oh();

    From your code it is no where written that you are using the package called graphics
    You are been using
    package useful;
    this implies u r using the package called useful
    well let me tell you how to use packages.
    For example if you use a package called pack1
    then that file you need to compile from parent directory as
    javac -d filename.java
    this will give you the folder called pack1 and the compiled file placed in it..
    so to use this in other folder from parent directory then
    you have to import that file
    import pack1.filename;
    then this will allow you to acess all the methods from that class file..
    i hope you get me if any concerns can mail me at
    [email protected]

  • Query to connect Java Applet to Oracle 10g.

    I am developing an Applet in Java 1.5.0.7.My database is Oracle 10g.Now when i connect Oracle to Java I get the Error : java.lang.ExceptionInInitializerError
    and it does not get connected.Please help me anyone.
    Below is the code which i have written.
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import java.sql.*;
    import java.util.ArrayList;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    public class tt7 extends JApplet
         implements ActionListener, PropertyChangeListener
    private int m_uniqueID = 0;
         JLabel m_lblRadius;
         // A button the user can click to display the Add Theme wizard.
         JButton m_btnAddTheme;
         static String m_mapxtremeURL = null;
         // TODO: Specify a map file name such as "uk.mdf" (if the mdf file is in
         // in same directory that the applet was loaded from),
         // or an URL to a map file, such as "http://host.com/maps/uk.mdf".
         // Or, instead of specifying this URL explicitly here, you can specify it
         // in the HTML page that loads the applet (using the 'filetoload' param).
    ResultSet rs=null ;
    ArrayList arrlist=null;
    ArrayList arrlist1=null;
    ArrayList arrlist2=null;
    //Connection con=null;
    Statement st=null;
         public void start()
         } // start method
         public void init()
    try{
    // System.out.println("helloooooooo");
    Class.forName("oracle.jdbc.driver.OracleDriver");
    //Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con= DriverManager.getConnection("Jdbc:oracle:thin:@asl005:1521:geo","system","1234567");//"jdbc:oracle:thin:@asl005:1521:geo","system","1234567");
    System.out.println("helloooooooo");
    System.out.println("CON:"+con.toString());
    st = con.createStatement();
    System.out.println("St:"+st);
    catch(Exception e2){System.out.println("Exception :"+e2);}
    catch(ExceptionInInitializerError s)
    System.out.println("Exception2 :"+s);
    }// If the HTML page specified parameters, use them to
              // override our default values.
              // See if a MapDef file was specified in the HTML file.
         }     // propertyChange method
         // Respond to the user actions, such as clicking
         // the Add Theme button.
    public void actionPerformed(ActionEvent e)
    // LocalDataProviderRef localDPRef = null;
    // a static label displayed in the applet
    public void propertyChange(PropertyChangeEvent evt) {
    This is the HTML CODE...
    <HTML>
    <HEAD>
    <TITLE>SimpleMap applet demonstration</TITLE>
    </HEAD>
    <BODY>
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 600 HEIGHT = 440
    codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0">
    <PARAM NAME = CODE VALUE = "tt7.class" >
    <PARAM NAME=archive VALUE="classes12.jar">
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.5">
    <COMMENT>
    <EMBED type="application/x-java-applet;version=1.5"
    CODE = "tt7.class"
    WIDTH = 600 HEIGHT = 440
    archive="classes12.jar"
    pluginspage="http://java.sun.com/products/plugin/1.3.1/plugin-install.html">
    <NOEMBED></COMMENT>
    alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason."
    Your browser is completely ignoring the &lt;APPLET&gt; tag!
    </NOEMBED></EMBED>
    </OBJECT>
    </BODY>
    </HTML>

    My dear colleague, You better consider asking this question in Jdeveloper forum.
    I have a simple code for Windows application. You can easily convert it into Applet application..
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import oracle.jdbc.*;
    import oracle.sql.*;
    public class QueryFrame extends Frame {
    TextField inputText;
    public QueryFrame() {
    super("Query Interface");
    setSize(450, 250);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    ActionListener printListener = new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    ConnectAndRun(inputText.getText());
    Panel toolbar = new Panel();
    toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));
    Button queryButton = new Button("Run Query");
    queryButton.addActionListener(printListener);
    toolbar.add(queryButton);
    inputText = new TextField(14);
    toolbar.add(inputText);          
    // The "preferred" BorderLayout add call
    add(toolbar, BorderLayout.NORTH);
    public static void main(String args[]) {
    QueryFrame tf1 = new QueryFrame();
    tf1.setVisible(true);
         public void ConnectAndRun(String s)
              String sqlquery;
              if (s.equals(""))
              sqlquery ="select * from DEPT where LOC is null";
              else
              sqlquery ="select * from DEPT where LOC like '" + s + "'";
              System.out.println(sqlquery);
              try
              DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
         Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:HELLO","scott","tiger");
         Statement stmt = conn.createStatement ();
              ResultSet rset = stmt.executeQuery (sqlquery);
              while (rset.next ())
                   System.out.println( rset.getInt("DEPTNO"));
                   System.out.println( rset.getString("DNAME"));
                   System.out.println (rset.getString("LOC"));
              rset.close();
         stmt.close();          
              catch (SQLException se)
                   System.out.println(se);
    Make sure you have appropriate libraries in classpath...

  • Java Scipt Calling Java Applet

    how could i call java applet in my java script code as i'm going to build an applet for internet application server but i'm going to check user input validation in java script !?!?!!?

    in javascript:
    theApplet.someMethod()
    in html: add a name attribute to the applet tag.
    <APPLET CODE=MyApplet.class
    NAME="theApplet"
    MAYSCRIPT
    HEIGHT=150
    WIDTH=500>
    </APPLET>
    the mayscript attribute is added if you want to make applet to javascript communication possible. (and not only javascript to applet communication)

  • Java Applets with AWT

    Hi,
    I have the problem to display the applet with AWT. If I am running the same applet in the internal server it works fine.If I am running through the web its giving Class not found exception.That web server also is mapped into the same server.
    Here is the code.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class NotHelloWorldApplet extends Applet
    public void init()
         try{
              setLayout(null);
              Label label1= new Label("Hello World!");
              label1.setSize(200,200);
              add(label1);
         }catch(Exception e){System.out.println(e);}
    <html><body>
    <applet
    code="NotHelloWorldApplet"
    codebase="."
    width=600 height=400
    >
    </applet>
    </body></html>
    can anyone help me please.
    Thanks

    Hello,
    Even I executed the program. Its works fine. I guess you must be having problem with the codebase. Just change the address in the codebase from current directory to the address where the class file is there and also change the permissions(set attributes to 755) of the class file. Hope this helps you.
    Regards,
    Sarada.

  • Illegal start to expression - java applet

    Hi Guys,
    this code is for a hangman game which will be in an applet. When I try putting the buttons in init, I'm getting an "illegal start of expression" for each button. Can someone tell me what I'm doing wrong?
    Cheers,
    * @(#)Hangman.java
    * Sample Applet application
    * @author
    * @version 1.00 06/10/17
    import java.util.Random;
    import java.util.*;
    import java.awt.*;
    import java.applet.*;
    import java.io.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    public class Hangman extends JApplet implements ActionListener
         Scanner textfile =new Scanner ("list.txt"); //file with words in
         int count=0;//count number of letters in chosen word
         int lives=6;//lives left
         String [] list= new String [count]; //word chosen stored in array
         boolean [] listDisplay=new boolean [count]; //whether letters in word have been guessed correct
         String guess=null; //guess
         boolean cont=false; //whether game continues or not
         public void read()
              try
                   while (textfile.hasNext()==true)
                        count++;
                   for (int i=0;i<count;i++)
                        String input=null;
                        list=input;
              catch (InputMismatchException e)
              System.out.println ("Mismatch exception:" + e );
         public String selectWord()
              int index=0;
              Random ind=new Random();
              String word=null;
              index=ind.nextInt();
              word=list[index];
              return word;
         public void wrongGuess(int lives)
              switch (lives)
                   case 6:               
                   break;
                   case 5:
                   break;
                   case 4:
                   break;
                   case 3:
                   break;
                   case 2:
                   break;
                   case 1:
                   break;
                   case 0:
                   cont=false;     
         public void game()
              String word=null;
              read();
              word=selectWord();
              while (cont==true)
         public void check(String letter)
              boolean tried=false;
              for (int i=0;i<list.length;i++)
                   if (list[i]==letter)
                        listDisplay[i]=true;
                   else
                        if (tried==false)
                             lives--;
                             tried=true;//guard to stop multiple lives lost by 1 letter
         public void init()
              //setup buttons
              private JButton jbtA=new JButton("A");
              private JButton jbtB=new JButton("B");
              private JButton jbtC=new JButton("C");
              private JButton jbtD=new JButton("D");
              private JButton jbtE=new JButton("E");
              private JButton jbtF=new JButton("F");
              private JButton jbtG=new JButton("G");
              private JButton jbtH=new JButton("H");
              private JButton jbtI=new JButton("I");
              private JButton jbtJ=new JButton("J");
              private JButton jbtK=new JButton("K");
              private JButton jbtL=new JButton("L");
              private JButton jbtM=new JButton("M");
              private JButton jbtN=new JButton("N");
              private JButton jbtO=new JButton("O");
              private JButton jbtP=new JButton("P");
              private JButton jbtQ=new JButton("Q");
              private JButton jbtR=new JButton("R");
              private JButton jbtS=new JButton("S");
              private JButton jbtT=new JButton("T");
              private JButton jbtU=new JButton("U");
              private JButton jbtV=new JButton("V");
              private JButton jbtW=new JButton("W");
              private JButton jbtX=new JButton("X");
              private JButton jbtY=new JButton("Y");
              private JButton jbtZ=new JButton("Z");
              JPanel p1=new JPanel();
              p1.add(jbtA);
              p1.add(jbtB);
              p1.add(jbtC);
              p1.add(jbtD);
              p1.add(jbtE);
              p1.add(jbtF);
              p1.add(jbtG);
              p1.add(jbtH);
              p1.add(jbtI);
              p1.add(jbtJ);
              p1.add(jbtK);
              p1.add(jbtL);
              p1.add(jbtM);
              p1.add(jbtN);
              p1.add(jbtO);
              p1.add(jbtP);
              p1.add(jbtQ);
              p1.add(jbtR);
              p1.add(jbtS);
              p1.add(jbtT);
              p1.add(jbtU);
              p1.add(jbtV);
              p1.add(jbtW);
              p1.add(jbtX);
              p1.add(jbtY);
              p1.add(jbtZ);
              getContentPane().add(p1,BorderLayout.CENTER);
         public void start()
              game();
         public void paint(Graphics g)
              g.drawString("Welcome to Java!!", 50, 60 );
         public void actionPerformed(ActionEvent e)
              if (e.getSource()==jbtA)
                   check("A");
              if (e.getSource()==jbtB)
                   check("B");
              if (e.getSource()==jbtC)
                   check("C");
              if (e.getSource()==jbtD)
                   check("D");
              if (e.getSource()==jbtE)
                   check("E");
              if (e.getSource()==jbtF)
                   check("F");
              if (e.getSource()==jbtF)
                   check("F");
              if (e.getSource()==jbtG)
                   check("G");
              if (e.getSource()==jbtH)
                   check("H");
              if (e.getSource()==jbtI)
                   check("I");
              if (e.getSource()==jbtJ)
                   check("J");
              if (e.getSource()==jbtK)
                   check("K");
              if (e.getSource()==jbtL)
                   check("L");
              if (e.getSource()==jbtM)
                   check("M");
              if (e.getSource()==jbtN)
                   check("N");
              if (e.getSource()==jbtO)
                   check("O");
              if (e.getSource()==jbtP)
                   check("P");
              if (e.getSource()==jbtQ)
                   check("Q");
              if (e.getSource()==jbtR)
                   check("R");
              if (e.getSource()==jbtS)
                   check("S");
              if (e.getSource()==jbtT)
                   check("T");
              if (e.getSource()==jbtU)
                   check("U");
              if (e.getSource()==jbtV)
                   check("V");
              if (e.getSource()==jbtW)
                   check("W");
              if (e.getSource()==jbtX)
                   check("X");
              if (e.getSource()==jbtY)
                   check("Y");
              if (e.getSource()==jbtZ)
                   check("Z");
    /code]

    cheers for the reply :)
    I've managed to compile the file, but nothing is displayed. I'm compiling using JDK 5. Any ideas?
    * @(#)Hangman.java
    * Sample Applet application
    * @author
    * @version 1.00 06/10/17
    import java.util.Random;
    import java.util.*;
    import java.awt.*;
    import java.applet.*;
    import java.io.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    public class Hangman extends JApplet implements ActionListener
         Scanner textfile =new Scanner ("list.txt"); //file with words in
         int count=0;//count number of letters in chosen word
         int lives=6;//lives left
         String [] list= new String [count]; //word chosen stored in array
         boolean [] listDisplay=new boolean [count]; //whether letters in word have been guessed correct
         String guess=null; //guess
         boolean cont=false; //whether game continues or not
         JButton jbtA;
         JButton jbtB;
         JButton jbtC;
         JButton jbtD;
         JButton jbtE;
         JButton jbtF;
         JButton jbtG;
         JButton jbtH;
         JButton jbtI;
         JButton jbtJ;
         JButton jbtK;
         JButton jbtL;
         JButton jbtM;
         JButton jbtN;
         JButton jbtO;
         JButton jbtP;
         JButton jbtQ;
         JButton jbtR;
         JButton jbtS;
         JButton jbtT;
         JButton jbtU;
         JButton jbtV;
         JButton jbtW;
         JButton jbtX;
         JButton jbtY;
         JButton jbtZ;
         public void read()
              try
                   while (textfile.hasNext()==true)
                        count++;
                   for (int i=0;i<count;i++)
                        String input=null;
                        list=input;
              catch (InputMismatchException e)
              System.out.println ("Mismatch exception:" + e );
         public String selectWord()
              int index=0;
              Random ind=new Random();
              String word=null;
              index=ind.nextInt();
              word=list[index];
              return word;
         public void wrongGuess(int lives)
              switch (lives)
                   case 6:               
                   break;
                   case 5:
                   break;
                   case 4:
                   break;
                   case 3:
                   break;
                   case 2:
                   break;
                   case 1:
                   break;
                   case 0:
                   cont=false;     
         public void game()
              String word=null;
              read();
              word=selectWord();
              while (cont==true)
         public void check(String letter)
              boolean tried=false;
              for (int i=0;i<list.length;i++)
                   if (list[i]==letter)
                        listDisplay[i]=true;
                   else
                        if (tried==false)
                             lives--;
                             tried=true;//guard to stop multiple lives lost by 1 letter
         public void init()
              //setup buttons
              jbtA=new JButton("A");
              jbtB=new JButton("B");
              jbtC=new JButton("C");
              jbtD=new JButton("D");
              jbtE=new JButton("E");
              jbtF=new JButton("F");
              jbtG=new JButton("G");
              jbtH=new JButton("H");
              jbtI=new JButton("I");
              jbtJ=new JButton("J");
              jbtK=new JButton("K");
              jbtL=new JButton("L");
              jbtM=new JButton("M");
              jbtN=new JButton("N");
              jbtO=new JButton("O");
              jbtP=new JButton("P");
              jbtQ=new JButton("Q");
              jbtR=new JButton("R");
              jbtS=new JButton("S");
              jbtT=new JButton("T");
              jbtU=new JButton("U");
              jbtV=new JButton("V");
              jbtW=new JButton("W");
              jbtX=new JButton("X");
              jbtY=new JButton("Y");
              jbtZ=new JButton("Z");
              JPanel p1=new JPanel();
              p1.add(jbtA);
              p1.add(jbtB);
              p1.add(jbtC);
              p1.add(jbtD);
              p1.add(jbtE);
              p1.add(jbtF);
              p1.add(jbtG);
              p1.add(jbtH);
              p1.add(jbtI);
              p1.add(jbtJ);
              p1.add(jbtK);
              p1.add(jbtL);
              p1.add(jbtM);
              p1.add(jbtN);
              p1.add(jbtO);
              p1.add(jbtP);
              p1.add(jbtQ);
              p1.add(jbtR);
              p1.add(jbtS);
              p1.add(jbtT);
              p1.add(jbtU);
              p1.add(jbtV);
              p1.add(jbtW);
              p1.add(jbtX);
              p1.add(jbtY);
              p1.add(jbtZ);
              getContentPane().add(p1,BorderLayout.CENTER);
         public void start()
              game();
         public void paint(Graphics g)
              g.drawString("Welcome to Java!!", 50, 60 );
         public void actionPerformed(ActionEvent e)
              if (e.getSource()==jbtA)
                   check("A");
              if (e.getSource()==jbtB)
                   check("B");
              if (e.getSource()==jbtC)
                   check("C");
              if (e.getSource()==jbtD)
                   check("D");
              if (e.getSource()==jbtE)
                   check("E");
              if (e.getSource()==jbtF)
                   check("F");
              if (e.getSource()==jbtF)
                   check("F");
              if (e.getSource()==jbtG)
                   check("G");
              if (e.getSource()==jbtH)
                   check("H");
              if (e.getSource()==jbtI)
                   check("I");
              if (e.getSource()==jbtJ)
                   check("J");
              if (e.getSource()==jbtK)
                   check("K");
              if (e.getSource()==jbtL)
                   check("L");
              if (e.getSource()==jbtM)
                   check("M");
              if (e.getSource()==jbtN)
                   check("N");
              if (e.getSource()==jbtO)
                   check("O");
              if (e.getSource()==jbtP)
                   check("P");
              if (e.getSource()==jbtQ)
                   check("Q");
              if (e.getSource()==jbtR)
                   check("R");
              if (e.getSource()==jbtS)
                   check("S");
              if (e.getSource()==jbtT)
                   check("T");
              if (e.getSource()==jbtU)
                   check("U");
              if (e.getSource()==jbtV)
                   check("V");
              if (e.getSource()==jbtW)
                   check("W");
              if (e.getSource()==jbtX)
                   check("X");
              if (e.getSource()==jbtY)
                   check("Y");
              if (e.getSource()==jbtZ)
                   check("Z");

  • Java Applet crashes Netscape upon Exit?

    Hello, I created an Applet that I am opening in NEtscape. When I make an attempt to exit (i.e. destroy) the APplet, it crashes the whole netscape. It even happens within Netscape 7. Is there a way around this since it makes a big problem for me to use the applet if it is going to crash my Netscape browser. I`ll appreciate any suggestions or comments, thanks Ivan

    The main class that everything is in is called GUI.java and it is a frame. In order to open this as an Applet in netscape, I created a GUI_RMIApplet.java file. And The GUI_RMIApplet.html file opens the GUI_RMIApplet.java file which in return opens GUI.java. The exit call is in GUI.java file.
    The html file code is as follows:
    <EMBED type="application/x-java-applet;version=1.3" CODE = "musr.client.gui.GUI
    _RMIApplet.class" CODEBASE = "." ARCHIVE = "jar/musr.jar" NAME = "MUSR GUI APPLE
    T" WIDTH = 400 HEIGHT = 300 ALIGN = middle VSPACE = 0 HSPACE = 0 UBBoption = "de
    velop" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/pl
    ugin-install.html">
    <NOEMBED>
    The GUI_RMIApplet.java code is:
    package musr.client.gui;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    import java.rmi.Naming;
    import java.rmi.RemoteException;
    import musr.server.*;
    public class GUI_RMIApplet extends Applet {
    boolean isStandalone = false;
    String message = "The application will launch in a separate window";
    GUI_RMIServer obj = null;
    /**Get a parameter value*/
    public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
    (getParameter(key) != null ? getParameter(key) : def);
    /**Construct the applet*/
    public GUI_RMIApplet() {
    /**Initialize the applet*/
    public void init() {
    try {
    jbInit();
    } catch (Exception e) {
    System.out.println("GUI_RMI exception: " + e.getMessage());
    e.printStackTrace();
    /**Component initialization*/
    private void jbInit() {
    // Main bulk for this applet
    GUI gui = new GUI();
    gui.setVisible(true);
    public void paint(Graphics g) {
    g.drawString(message, 25, 50);
    /**Get Applet information*/
    public String getAppletInfo() {
    return "Applet Information";
    /**Get parameter info*/
    public String[][] getParameterInfo() {
    return null;
    //static initializer for setting look & feel
    static {
    try {
    //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    catch(Exception e) {
    And, the GUI.java class calls these funcitons when exit menu button is selected:
    GUI.this.dispose(); // disposes the frame
              System.exit(-1); // disposes the applet (?or not?)
    I think the System.exit button is messing things up but I don't know what other function I can use to close teh applet.
    Hope this is enough information.

  • Help!!! Need Java Applet to work in IE

    I found some applets (text scrollers) from the sun site that i wanted to use. downloaded them, but they do not work in IE that does not have JVM. in IE that does have JVM it says 'Java 1.1 Required' where the applet should be. is there a simple way to get sun java applets to work with IE and the MS Virtual Machine? I can't require my site visitors to have to download extra toys/plugins...

    If you are looking for a purely AWT scrolling applet. Here is one I wrote several years ago. Please note that there are some deprecated methods in it (mainly the thread start and stop methods). It will still compile though. If you want it, take it.
    Source:import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.net.*;
    public class ScrollApplet extends Applet implements Runnable
       /*=*********************
       * private data members *
       private Thread myThread = null;
       private boolean hasTextDisplayed;
       private int appletWidth, appletHeight;
       private int yPosition;
       private int xPosition;
       private Image textImage;
       private int imageWidth;
       private Graphics textGraphics;
       private Cursor oldCursor;
       private Cursor newCursor = new Cursor(Cursor.HAND_CURSOR);
       //parameters
       private int delay;
       private String displayText;
       private Color bgColor, fgColor;
       private int fontSize, fontStyle;
       private Font fontType;
       private String urlValue;
       /*=***************
       * applet methods *
       public void init()
          //assign values to private data members
          hasTextDisplayed = false;
          appletHeight = yPosition = getSize().height;
          appletWidth = xPosition = getSize().width;
          //set up the environment
          extractParameters();
          //determine the yPosition to place the image
          calculateYPosition();
          //set up the text image
          FontMetrics fm = getFontMetrics(fontType);
          imageWidth = fm.stringWidth(displayText);
          textImage = createImage(imageWidth, appletHeight);
          textGraphics = textImage.getGraphics();
          textGraphics.setColor(bgColor);
          textGraphics.fillRect(0,0,imageWidth,appletHeight);
          textGraphics.setColor(fgColor);
          textGraphics.setFont(fontType);
          textGraphics.drawString(displayText, 0, yPosition);
          oldCursor = this.getCursor();
          addMouseListener(new MouseAdapter() {
             public void mouseExited(MouseEvent e)
                if (urlValue != null) {
                   Component thisApplet = e.getComponent();
                   thisApplet.setCursor(oldCursor);
                showStatus(" ");
                myThread.resume();
             public void mouseEntered(MouseEvent e)
                myThread.suspend();
                if (urlValue != null) {
                   Component thisApplet = e.getComponent();
                   thisApplet.setCursor(newCursor);
                   showStatus(urlValue);
                else
                   showStatus("paused");
             public void mouseClicked(MouseEvent e)
                if (urlValue != null)
                   try {
                      URL u = new URL(urlValue);
                      getAppletContext().showDocument(u, "_self");
                   } catch(MalformedURLException ex) {
                   showStatus("MalformedURLException: " +ex);
       }//end init method
       public void start()
          myThread = new Thread(this);
          myThread.start();
       }//end start method
       public void update(Graphics g)
       //overwrote this method to avoid repainting of background before all text displays
          if (hasTextDisplayed == true)
             //repaint the background
             g.setColor(bgColor);
             g.fillRect(xPosition+imageWidth, 0, appletWidth - (xPosition + imageWidth),
                          appletHeight);
             g.setColor(fgColor);
          paint(g);
       }//end update method
       public void paint(Graphics g)
          setBackground(bgColor);
          g.drawImage(textImage,xPosition,0,this);
       }//end paint method
       public void stop()
       { myThread = null; }
       /*=*******************************************************************************
       * applet method getParameterInfo():                                              *
       * Returns information about the parameters that are understood by this applet.   *
       * An applet should override this method to return an array of Strings describing *
       * these parameters.  Each element of the array should be a set of three Strings  *
       * containing the name, the type, and a description.                              *
       public String[][] getParameterInfo()
          String parameterInfo[][] = {
             {"DELAYPARAM", "int", "The interval to pause in milliseconds"},
             {"TEXTPARAM", "string", "The text that will be displayed"},
             {"BGPARAM", "Color", "The bg color for the applet, in html format #FFFFFF"},
             {"FGPARAM", "Color", "The fg color for the text, in html format #FFFFFF"},
             {"FONTSIZEPARAM", "int", "The font size of the text"},
             {"FONTTYPEPARAM", "string", "The name of the font to use"},
             {"FONTSTYLEPARAM", "string", "bold, italic, or bold+italic"},
             {"URLPARAM", "string", "hyperlink"}
          return parameterInfo;
       }//end getParameterInfo method
       /*=*****************************************************************************
       * applet method getAppletInfo():                                               *
       * Returns information about this applet. An applet should override this method *
       * to return a String containing information about the author, version, and     *
       * copyright of the applet.                                                     *
       public String getAppletInfo()
          String infoAboutMe;
          infoAboutMe = new String(
             "Author:  Your Name Here/n" +
             "Description:  My first text scroller\n" +
             "Version: 1.0"
          return infoAboutMe;
       }//end getAppletInfo method
       /*=***************
       * thread methods *
       public void run()
          Thread current = Thread.currentThread();
          //loop until thread is stopped
          while (myThread == current)
             repaint();
             try {
                current.sleep(delay);
                xPosition--;
             } catch (InterruptedException e) {}
             if (xPosition <= (appletWidth - imageWidth))
                hasTextDisplayed = true;
             else
                hasTextDisplayed = false;
             if (xPosition == (0 - imageWidth))
                xPosition = appletWidth;
       }//end required run method
       /*=**********************************************************************
       * extractParameters():  Sets all parameter values, if any were provided *
       public void extractParameters()
          String delayValue = getParameter("DELAYPARAM");
          String textValue = getParameter("TEXTPARAM");
          String bgColorValue = getParameter("BGPARAM");
          String fgColorValue = getParameter("FGPARAM");
          String fontSizeValue = getParameter("FONTSIZEPARAM");
          String fontTypeValue = getParameter("FONTTYPEPARAM");
          String fontStyleValue = getParameter("FONTSTYLEPARAM");
          String urlParam = getParameter("URLPARAM");
          //set delay to one tenth of a second if missing parameter
          delay = ((delayValue == null) ? 100 : Integer.parseInt(delayValue));
          urlValue = (urlParam == null ? null : urlParam);
          displayText = ((textValue == null) ?
                new String("NO TEXT WAS PROVIDED!") :
                textValue);
          bgColor = determineColor(bgColorValue);
          fgColor = determineColor(fgColorValue);
          fontStyle = determineFontStyle(fontStyleValue);
          fontSize = ((fontSizeValue == null) ? 12 : Integer.parseInt(fontSizeValue));
          fontType = new Font(fontTypeValue, fontStyle, fontSize);
       }//end extractParameters method
       /*=*************************************************
       * determineColor():  returns the appropriate color *
       public Color determineColor(String value)
          return parseHTMLHex(value);
       }//end determineColor method
       /*=*****************************************************************************
       * parseHTMLHex(): parses an HTML hex (eg #FFFFFF) and returns the Color object *
       public static Color parseHTMLHex(String htmlHex) {
          Color color = new Color(220,220,220);  //default grey
          if (htmlHex != null) {
             String red = htmlHex.substring(1,3);
             String green = htmlHex.substring(3,5);
             String blue = htmlHex.substring(5);
             color = new Color(Integer.parseInt(red,16),
                           Integer.parseInt(green,16),
                           Integer.parseInt(blue,16));
          }//end if
          return color;
       }//end parseHTMLHex method
       /*=******************************************
       * determineFontStyle():  returns font sytle *
       public int determineFontStyle(String value)
          int returnVal;
          if (value == null)
             returnVal = Font.PLAIN;
          else if (value.equalsIgnoreCase("plain"))
             returnVal = Font.PLAIN;
          else if (value.equalsIgnoreCase("bold"))
             returnVal = Font.BOLD;
          else if (value.equalsIgnoreCase("italic"))
             returnVal = Font.ITALIC;
          else if (value.equalsIgnoreCase("bold+italic"))
             returnVal = Font.BOLD + Font.ITALIC;
          else
             returnVal = Font.PLAIN;
          return returnVal;
       }//end determineFontStyle method
       /*=**********************************************************
       * calculateYPosition(): want text to be in middle of applet *
       public void calculateYPosition()
          //wasYPositionCalculated = true;
          //make calculations to center font in applet window
          int appletMidHeight = appletHeight / 2;         //the middle of the applet
          FontMetrics fm = getFontMetrics(fontType);    //font metrics for current font
          int fontMidHeight = fm.getAscent() / 2;         //the middle of the font
          int currentFontSizeValue;                       //temp value for font size
          //if the font size if too big, fix it
          if ((currentFontSizeValue = fm.getAscent()) > appletHeight)
             //cycle through font sizes until find one that fits
             while (currentFontSizeValue > appletHeight)
                fontType = new Font(getParameter("FONTTYPEPARAM"), fontStyle, --fontSize);
                fm = getFontMetrics(fontType);
                currentFontSizeValue = fm.getAscent();
             //set the new values for the new font
             setFont(fontType);
             fm = getFontMetrics(fontType);
             fontMidHeight = fm.getAscent() / 2;
          yPosition = appletMidHeight + fontMidHeight - 3;
       }//end calculateYPosition()
    }//end applethtml:<HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
    <TITLE>Test scroller applet</title>
    </head>
    <BODY>
    <h1>Scroller Applet</h1>
    <!--CODEBASE = "."-->
    <APPLET
      CODE     = "ScrollApplet.class"
      NAME     = "TestApplet"
      WIDTH    = 400
      HEIGHT   = 30
      HSPACE   = 0
      VSPACE   = 0
      ALIGN    = middle
    >
    <PARAM NAME="DELAYPARAM" VALUE="10">
    <PARAM NAME="TEXTPARAM" VALUE="Simple Old Scrolling Applet?">
    <PARAM NAME="BGPARAM" VALUE="#000000">
    <PARAM NAME="FGPARAM" VALUE="#CCCCCC">
    <PARAM NAME="FONTSIZEPARAM" VALUE="24">
    <PARAM NAME="FONTTYPEPARAM" VALUE="TimesRoman">
    <PARAM NAME="FONTSTYLEPARAM" VALUE="italic">
    <PARAM NAME="URLPARAM" VALUE="http://quote.yahoo.com/quotes?SYMBOLS=DISH">
    </applet>
    </body>
    </html>tajenkins

Maybe you are looking for

  • What are the common error while EBS installation in Unix /windows

    what are the common error while EBS R12 installation with os unix and windows. oracle have any any check after installation all installation are correct according to no of directory, files and file size ? regards

  • IPod Transfer.

    Hi guys, I'm wondering if anyone can shed some light on this issue! I'm having a problem transferring files from my computer to my iPod, and I'm not sure if it's my computer or my iPod that is giving me the problems. My computer is a 1.25 Powerbook G

  • IPad connection to docking station

    Wouldn't it be nice if a future version of iPad would have a connection for the docking station at the side as well ? Some apps don't work in portrait mode and I don't want to have my iPad on my lap all the time, because I use it as main computer in

  • How to importing AVCHD if I don't have all the folder files?

    Hi, I have to cut a few videos. I have been given an external drive with .MTS files. However, all the files regarding the structure of the folder... are not there!!!!! Now, when I import them to Adobe, they are glitchy and out of sync. - Do I have to

  • Business Objects 4 - 水晶报表演示

    由SAP专家详细演示新功能,[点击这里|http://www.tudou.com/programs/view/SzngJAN1HQA/]看视频.