ClassNotFoundException - JApplet

Hello,
I am getting a class not found exception for a JApplet I have created. The class is in WEB-INF/classes/kk/Client.class
<applet code="kk\Client.class" width=500" height="400">
Your browser does not support the applet tag.
</applet>
Can anyone give any light as that what the code="" should be set to in order to see it?.
thanks
~ Kyle
Edited by: KyleG on Dec 16, 2008 5:32 AM
Edited by: KyleG on Dec 16, 2008 5:33 AM

<applet codebase="WEB-INF/classes/kk" code="Client.class" width=500" height="400">
Your browser does not support the applet tag.
</applet>
I seem to be still getting the same error although the class is in that directory

Similar Messages

  • Components in a JApplet

    im not so sure if i should use a layout or anything, but basicly what i have is a JApplet, and i want to put text fields so that they are aligned in the center at the bottom. i want to add 6 components the the bottom and reserve the top portion of my applet for drawing. i want a 3 text fields and a JLabel for each and im having two problems setting this up.
    1: i cannot get them on the bottom(the are created in the top center(with default layout)
    2: after the applet is constructed and the fields and whatnot added, the Textfields wont show unless you click on where they are supposed to be(or you press tab while in one of the other text fields. after the textfields are shown for the first time i have no problems after this.
    can anyone possibly suggest a solution to what i might be doing wrong?

    this is my constructor and init methods
    public class ThreeD extends JApplet implements MouseMotionListener, ActionListener, MouseListener
         private int windowWidth;
         private int windowHeight;
         private JTextField xval;
         private JTextField yval;
         private JTextField zval;
         public ThreeD(int width, int height)
              windowWidth = width;
              windowHeight = height;
              JFrame f = new JFrame("Window");//create new window
            f.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {System.exit(0);}//add a window listener
            this.setLayout(new BorderLayout());
            JPanel InfoPanel1 = new JPanel(new BorderLayout());
              JPanel InfoPanel2 = new JPanel(new GridLayout(1,6));//textfields
              JPanel InfoPanel3 = new JPanel(new BorderLayout());
              xval = new JTextField(4);
            yval = new JTextField(4);
            zval = new JTextField(4);
            xval.addActionListener(this);
            yval.addActionListener(this);
            zval.addActionListener(this);
            JLabel xtext = new JLabel("X:");
            JLabel ytext = new JLabel("Y:");
            JLabel ztext = new JLabel("Z:");
            xval.addActionListener(this);
            yval.addActionListener(this);
            zval.addActionListener(this);
              InfoPanel2.add(xtext);
              InfoPanel2.add(xval);
              InfoPanel2.add(ytext);
              InfoPanel2.add(yval);
              InfoPanel2.add(ztext);
              InfoPanel2.add(zval);
              JPanel bottomPanel = new JPanel(new GridLayout(1,3));
              bottomPanel.add(InfoPanel1);
              bottomPanel.add(InfoPanel2);
              bottomPanel.add(InfoPanel3);
              add(bottomPanel,BorderLayout.SOUTH);
              f.getContentPane().add(this,0);
              getContentPane().validate();
              f.pack();
            f.setSize(new Dimension(getWindowWidth(),(getWindowHeight())));//set the window size
            f.show();
              init();
         public void init()
              addMouseListener(this);
                addMouseMotionListener(this);
              setBackground(Color.BLACK);
            setForeground(Color.WHITE);
         my action listeners that are currently set to help me test this appletpublic void actionPerformed(ActionEvent e)
         public void mouseExited(MouseEvent e)
         {repaint();}
         public void mouseEntered(MouseEvent e)
         {repaint();}
         public void mouseReleased(MouseEvent e)
         {repaint();}
         public void mousePressed(MouseEvent e)
         {repaint();}
         public void mouseClicked(MouseEvent e)
         {repaint();}
         public void mouseMoved(MouseEvent e)
              System.out.println(e.getX() + " " +e.getY());
              repaint();}
         public void mouseDragged(MouseEvent e)
         {repaint();}paint and update     public void paint(Graphics g)
              System.out.println("Paint " + num);
              Graphics2D g2 = (Graphics2D)g;
              g2.setPaint(Color.BLACK);
              g2.fill(new Rectangle2D.Double(99,90,120,101));//repaints the backround
              g2.setPaint(Color.WHITE);
              g2.drawString(""+num, 100,100);
              num++;
         public void update(Graphics g)
              paint(g);
         and main
    public static void main(String[] args) throws IOException , ClassNotFoundException
              JApplet applet = new ThreeD(1000,700, Objects1);
    }note:not all code shown(just code that i think helps create and draw the applet)

  • Japplet throws ClassNotFoundException

    I've built an applet (from JApplet) that consumes several other jar files.  I've signed the jar that contains the main class and included all of the jars I need (I think).  However, no matter what I try, I consistently get "java.lang.ClassNotFoundException: newposting" where 'newposting' is the main class within my signed jar.  I'm using the following html for this:
    <p><applet code="newposting" archive="HartfordRowingNewPosting.jar, javax.mail.jar, jcalendar-1.4.jar, junit-4.6.jar, jgoodies-common-1.2.0.jar, jgoodies-looks-2.4.1.jar, mysql-connector-java-5.1.25-bin.jar" width="500" height="850">
    <param name="permissions" value="sandbox" /> <param name="codebase" value="HartfordRowingNewPosting" /></applet></p>
    I've been frustrated with this on and off for the last month or so.  Can someone shed some light on this?  Am I getting this error because of JApplet?

    I doubt it's to do with JApplet.
    It's too long ago for me to remember what, if any, is the significance to the applet of your codebase parameter (as opposed to attribute), but I'm a bit suspicious of that and also of the code attribute: does signed code have to be in a package, or is it OK for it to be in the default package? Certainly, the applet class name "newposting" is contrary to convention, though that wouldn't cause an error in itself.. So I'd be tempted to refactor to put your classes in a package (i.e. include the package statement in your .java files).
    What does your web server access log say? Lot's of 200 and 304 status codes, or 404?

  • JApplet Bad Path/ClassNotFoundException

    I am writing a JApplet that of course runs fine using an appletviewer but gives me the following error in IE or Netscape (copied from the Java console)
    com.ms.security.SecurityExceptionEx[Host]: java.io.IOException: bad path: C:\cs101\RITA\apppack\javax\swing\JApplet.class
    at com/ms/security/permissions/FileIOPermission.check (FileIOPermission.java)
    at com/ms/security/PolicyEngine.deepCheck (PolicyEngine.java)
    at com/ms/security/PolicyEngine.checkPermission (PolicyEngine.java)
    at com/ms/security/StandardSecurityManager.chk (StandardSecurityManager.java)
    at com/ms/security/StandardSecurityManager.checkRead (StandardSecurityManager.java)
    at java/io/File.isDirectory (File.java)
    at sun/net/www/protocol/file/FileURLConnection.connect (FileURLConnection.java)
    at sun/net/www/protocol/file/FileURLConnection.getInputStream (FileURLConnection.java)
    at com/ms/vm/loader/ResourceLoader.getURLData (ResourceLoader.java)
    at com/ms/vm/loader/ResourceLoader.getCodebaseRelativeData (ResourceLoader.java)
    at com/ms/vm/loader/ResourceLoader.getClassData (ResourceLoader.java)
    at com/ms/vm/loader/URLClassLoader.findClass (URLClassLoader.java)
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at java/lang/ClassLoader.loadClassInternal (ClassLoader.java)
    at java/lang/ClassLoader.resolveClass (ClassLoader.java)
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.run (AppletPanel.java)
    at java/lang/Thread.run (Thread.java)
    java.lang.ClassNotFoundException: javax.swing.JApplet
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at java/lang/ClassLoader.loadClassInternal (ClassLoader.java)
    at java/lang/ClassLoader.resolveClass (ClassLoader.java)
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.run (AppletPanel.java)
    at java/lang/Thread.run (Thread.java)
    I have the Java 1.3.1 Plug-in for swing installed but I am not sure I am using it. What I mean is I think I need to switch my VM from Microsoft's VM to something that allows swing and I have no idea how to do this... Please Help!!! Thanks in advance :)

    This problem occurred because your applet is trying to access files byapplet, for your application access files you shall signed you applet, or you can use policytool in your jdk1.3/bin and give permission for FilePermission.
    For use the Plugin you can do download the HTMLConverter and convert your old html code for new html code.
    http://www.java.sun.com/products/plugin/1.3/docs/html_converter.html
    Best Regards,
    Isa�as Cristiano Barroso

  • ClassNotFoundException Error when invokeing a JApplet

    I get the java.lang.classNot foundException when trying to inokve my JApplet from a Servlet.
    I use the code
    out.println("<APPLET code=\"JGoodVisApp\" width=700 height = 500></APPLET>");
    Any suggesstions.
    Regards,
    Jason

    check to see if the class is present in the WEB-INF/classes directory.
    Are you able to invoke other classes but not the applet classes ?
    -Manish

  • Creation of an applet JApplet in a desktop JDesktopPane

    how its posible to load from a jar file an applet which come from package my.package.myclass of the jar file.
    next i want to put it in a JInternalFrame and put this desktop frame in a JDesktopPane.
    indeed i can move the applet around with other applets in a little window!
    here's the code of the desktop_panel.javapackage kevin_shell;
    import kevin_shell.Kdemos.*;
    import java.awt.*;
    import java.awt.event.*;
    import java2d.MemoryMonitor;
    //import java2d.demos.Lines.*;
    import javax.swing.*;
    import javax.swing.border.BevelBorder;
    import javax.swing.border.Border;
    import com.l2fprod.gui.plaf.skin.Skin;
    import com.l2fprod.gui.plaf.skin.SkinLookAndFeel;
    public class desktop_panel extends JPanel {
    JInternalFrame win_info = new JInternalFrame();
    public void killme(KDemo demo) {
    demo = null;
    public void view_image(String file) {
    thread_load_cube load = new thread_load_cube(file);
    load.start();
    JPanel jPanel2 = new JPanel();
    JDesktopPane pan_workspace = new JDesktopPane();
    public void paint(Graphics p) {
    p.setColor(Color.blue);
    p.fillRect(0, 0, 1000, 1000);
    p.setColor(Color.red);
    p.drawString("kevin OS", 10, 10);
    super.paint(p);
    BorderLayout borderLayout1 = new BorderLayout();
    JPanel jPanel3 = new JPanel();
    JButton jButton1 = new JButton();
    JInternalFrame win_memory = new JInternalFrame();
    JInternalFrame win_terminal = new JInternalFrame();
    MemoryMonitor win_mem = new MemoryMonitor();
    KClock win_perf = new KClock();
    JPanel jPanel4 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JButton jButton2 = new JButton();
    JLabel jLabel6 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JButton but_collect = new JButton();
    JButton but_refresh = new JButton();
    JTextField nb_free = new JTextField();
    Border border1;
    Border border2;
    JLabel jLabel2 = new JLabel();
    JTextField ed_jdk_path = new JTextField();
    JTextField nb_total = new JTextField();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel5 = new JLabel();
    bean_clock bean_clock1 = new bean_clock();
    JPanel jPanel5 = new JPanel();
    JPanel jPanel1 = new JPanel();
    JTabbedPane tabber = new JTabbedPane();
    BorderLayout borderLayout2 = new BorderLayout();
    JList list1 = new JList();
    JList list_system = new JList();
    JList list3 = new JList();
    JButton jButton3 = new JButton();
    JButton jButton4 = new JButton();
    JButton jButton5 = new JButton();
    JButton jButton6 = new JButton();
    test_applet Itest_applet = new test_applet();
    JButton jButton7 = new JButton();
    public desktop_panel() {
    try {
    jbInit();
    System.out.println("initializing desk");
    bean_clock1.setLocation(0, 0);
    bean_clock1.setSize(win_info.getPreferredSize());
    //bean_clock1.start();
    pan_workspace.add(win_info);
    win_info.show();
    win_info.setLocation(0, 0);
    win_info.setSize(win_info.getPreferredSize());
    //Class bruno=java.lang.ClassLoader.getSystemClassLoader().loadClass("demo_cube");
    //Object b=bruno.newInstance();
    pan_workspace.add(win_memory);
    win_memory.show();
    win_memory.setSize(win_memory.getPreferredSize());
    pan_workspace.add(win_terminal);
    win_terminal.show();
    win_terminal.setSize(win_terminal.getPreferredSize());
    pan_workspace.add(win_mem);
    win_mem.setVisible(true);
    win_mem.setSize(win_mem.getPreferredSize());
    pan_workspace.add(win_perf);
    win_perf.setVisible(true);
    win_perf.setSize(100, 100);
    win_perf.setLocation(400, 400);
    win_perf.startClock();
    //list_system.add("welcome to kevin os");
    //tabber.add(list_system);
    tabber.add(list1);
    tabber.add(list3);
    win_terminal.getContentPane().add(tabber, BorderLayout.CENTER);
    win_terminal.setSize(300, 300);
    win_terminal.setResizable(true);
    win_terminal.setLocation(400, 400);
    System.out.println("ok");
    } catch (Exception e) {
    e.printStackTrace();
    class thread_load_cube extends Thread {
    String file;
    thread_load_cube() {
    file = "pics/babe1.jpg";
    thread_load_cube(String f) {
    file = f;
    //win_cube
    public void run() {
    try {
    System.out.println("cube loading");
    Class demo = java.lang.ClassLoader.getSystemClassLoader().
    loadClass("kevin_shell.Kdemos.demo_cube");
    KDemo win_cube = (KDemo) demo.newInstance();
    //list_system.add("win cube (loading....)");
    java.net.URL stoneURL = main_win.class.getResource(file);
    java.net.URL skyURL = main_win.class.getResource(
    "pics/babe2.jpg");
    //win_cube=new demo_cube();
    win_cube.set_parameters(stoneURL, skyURL);
    //pan_workspace.add(win_cube);
    win_cube.show();
    win_cube.setLocation(300, 300);
    win_cube.setSize(300, 300);
    win_cube.setResizable(true);
    win_cube.setTitle("java 3d cube");
    win_cube.setIconifiable(true);
    win_cube.init();
    win_cube.setClosable(true);
    System.out.println("ok");
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    System.out.println("problem with class");
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    System.out.println("acces problem");
    } catch (InstantiationException e) {
    e.printStackTrace();
    System.out.println("instance");
    class thread_load_j3d extends Thread {
    public void run() {
    //list_system.add("j3d test loading...");
    //kev
    try {
    Class demo = java.lang.ClassLoader.getSystemClassLoader().
    loadClass("kevin_shell.Kdemos.demo_j3d");
    KDemo win = (KDemo) demo.newInstance();
    //pan_workspace.add(win);
    win.show();
    win.setLocation(300, 300);
    win.setSize(300, 300);
    win.setResizable(true);
    win.setTitle("j3d test");
    win.setIconifiable(true);
    win.init();
    win.setClosable(true);
    System.out.println("ok");
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    System.out.println("problem with class");
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    System.out.println("acces problem");
    } catch (InstantiationException e) {
    e.printStackTrace();
    System.out.println("instance");
    private void jbInit() throws Exception {
    border1 = BorderFactory.createMatteBorder(4, 4, 4, 4,
    new Color(91, 91, 91));
    border2 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
    Color.white, Color.white,
    new Color(153, 153, 204),
    new Color(153, 153, 204));
    jButton2.setBackground(Color.white);
    jButton2.setBorder(BorderFactory.createLineBorder(Color.black));
    jButton2.setPreferredSize(new Dimension(70, 70));
    //jButton2.setIcon(new ImageIcon(desktop_panel.class.getResource("icons/on_kevin.gif")));
    jButton2.setMargin(new Insets(0, 0, 0, 0));
    jButton2.setBounds(new Rectangle(9, 6, 52, 54));
    jLabel1.setFont(new java.awt.Font("Dialog", 1, 70));
    jLabel1.setForeground(SystemColor.desktop);
    jLabel1.setText("kevin os 1.0");
    jLabel1.setBounds(new Rectangle(66, 6, 255, 22));
    this.setLayout(borderLayout1);
    this.setBackground(UIManager.getColor("EditorPane.selectionBackground"));
    jPanel2.setLayout(null);
    jPanel2.setBackground(UIManager.getColor(
    "InternalFrame.activeTitleBackground"));
    jPanel2.setMaximumSize(new Dimension(100, 100));
    jPanel2.setMinimumSize(new Dimension(100, 100));
    jPanel2.setPreferredSize(new Dimension(100, 100));
    jPanel3.setBackground(new Color(255, 231, 0));
    jPanel3.setPreferredSize(new Dimension(60, 10));
    jButton1.setBackground(Color.white);
    jButton1.setBorder(BorderFactory.createLineBorder(Color.black));
    jButton1.setPreferredSize(new Dimension(50, 50));
    //jButton1.setIcon(new ImageIcon(desktop_panel.class.getResource("icons/info.gif")));
    jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton1_mouseClicked(e);
    pan_workspace.setBackground(UIManager.getColor(
    "List.selectionBackground"));
    pan_workspace.setOpaque(false);
    pan_workspace.setAlignmentX((float) 0.0);
    pan_workspace.setAlignmentY((float) 0.0);
    pan_workspace.setLayout(null);
    win_memory.setToolTipText("");
    win_memory.getContentPane().setBackground(SystemColor.controlDkShadow);
    win_memory.setTitle("memory");
    win_memory.setBorder(border2);
    win_memory.setIconifiable(true);
    win_memory.setNormalBounds(new Rectangle(10, 10, 381, 254));
    win_memory.setPreferredSize(new Dimension(381, 254));
    win_memory.setMinimumSize(new Dimension(381, 254));
    win_info.setFrameIcon(null);
    win_info.setPreferredSize(new Dimension(269, 230));
    win_info.setMinimumSize(new Dimension(269, 230));
    win_info.setBorder(border2);
    win_info.getContentPane().setBackground(UIManager.getColor(
    "CheckBoxMenuItem.selectionBackground"));
    win_info.setMaximumSize(new Dimension(100, 100));
    win_info.setResizable(true);
    win_info.setIconifiable(true);
    win_info.setTitle("kevin OS info");
    but_collect.setBackground(Color.orange);
    but_collect.setText("garbage collector");
    but_collect.setBounds(new Rectangle(13, 114, 162, 31));
    but_collect.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    but_collect_mouseClicked(e);
    but_refresh.setText("refresh");
    but_refresh.setBounds(new Rectangle(11, 150, 162, 32));
    but_refresh.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    but_refresh_mouseClicked(e);
    nb_free.setBackground(Color.white);
    nb_free.setDisabledTextColor(Color.white);
    nb_free.setEditable(false);
    nb_free.setBounds(new Rectangle(107, 40, 108, 22));
    jPanel4.setBackground(UIManager.getColor(
    "InternalFrame.activeTitleBackground"));
    jLabel2.setBackground(Color.pink);
    jLabel2.setFont(new java.awt.Font("Dialog", 1, 50));
    jLabel2.setForeground(Color.red);
    jLabel2.setText("-OS-");
    jLabel2.setBounds(new Rectangle(98, 12, 139, 52));
    ed_jdk_path.setBackground(Color.white);
    ed_jdk_path.setDisabledTextColor(Color.white);
    ed_jdk_path.setEditable(false);
    ed_jdk_path.setBounds(new Rectangle(104, 14, 190, 22));
    nb_total.setBackground(Color.white);
    nb_total.setDisabledTextColor(Color.white);
    nb_total.setEditable(false);
    nb_total.setBounds(new Rectangle(228, 40, 108, 22));
    jLabel3.setToolTipText("");
    jLabel3.setText("free");
    jLabel3.setBounds(new Rectangle(106, 70, 112, 16));
    jLabel5.setBounds(new Rectangle(228, 70, 112, 16));
    jLabel5.setText("total");
    jLabel5.setToolTipText("");
    win_terminal.setTitle("terminal");
    jPanel5.setLayout(borderLayout2);
    jButton3.setPreferredSize(new Dimension(50, 27));
    jButton3.setText("cube");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton3_actionPerformed(e);
    jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton3_mouseClicked(e);
    jButton4.setText("test");
    jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton4_mouseClicked(e);
    jButton5.setText("skin cool");
    jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton5_mouseClicked(e);
    jButton6.setText("skin xp");
    jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jButton6_mouseClicked(e);
    jButton7.setText("test applet");
    jButton7.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton7_actionPerformed(e);
    win_memory.getContentPane().add(jPanel4, BorderLayout.CENTER);
    jPanel4.setLayout(null);
    jPanel4.setMinimumSize(new Dimension(100, 100));
    jPanel4.setPreferredSize(new Dimension(100, 100));
    jLabel6.setText("java memory");
    jLabel6.setBounds(new Rectangle(16, 40, 78, 18));
    jLabel4.setText("jdk path");
    jLabel4.setBounds(new Rectangle(18, 16, 76, 18));
    this.add(jPanel3, BorderLayout.WEST);
    jPanel3.add(jButton7);
    jPanel3.add(jButton1, null);
    jPanel3.add(jButton3, null);
    jPanel3.add(jButton4, null);
    jPanel3.add(jButton5, null);
    jPanel3.add(jButton6, null);
    this.add(pan_workspace, java.awt.BorderLayout.CENTER);
    jPanel4.add(jLabel4, null);
    jPanel4.add(jLabel6, null);
    jPanel4.add(but_collect, null);
    jPanel4.add(ed_jdk_path, null);
    jPanel4.add(nb_free, null);
    jPanel4.add(nb_total, null);
    jPanel4.add(but_refresh, null);
    jPanel4.add(jLabel3, null);
    jPanel4.add(jLabel5, null);
    win_info.getContentPane().add(jPanel2, BorderLayout.CENTER);
    jPanel2.add(jButton2, null);
    jPanel2.add(jLabel1, null);
    jPanel2.add(jLabel2, null);
    tabber.add(list1, "list1");
    tabber.add(list_system, "list_system");
    tabber.add(list3, "list3");
    void but_refresh_mouseClicked(MouseEvent e) {
    nb_free.setText(String.valueOf(java.lang.Runtime.getRuntime().
    freeMemory()));
    nb_total.setText(String.valueOf(java.lang.Runtime.getRuntime().
    totalMemory()));
    void jButton1_mouseClicked(MouseEvent e) {
    win_info.show();
    win_info.setLocation(0, 0);
    //win_info.setSize(100,100);
    void but_collect_mouseClicked(MouseEvent e) {
    java.lang.Runtime.getRuntime().gc();
    but_refresh_mouseClicked(e);
    //list_system.add("collecting memory");
    void jButton3_mouseClicked(MouseEvent e) {
    //win_cube.begin_anim();
    void jButton4_mouseClicked(MouseEvent e) {
    thread_load_j3d load = new thread_load_j3d();
    load.start();
    void jButton6_mouseClicked(MouseEvent e) {
    try {
    Skin skin = null;
    //windows xp
    skin = SkinLookAndFeel.loadThemePack("skins/BeOS-theme.jar");
    // set the skin
    SkinLookAndFeel.setSkin(skin);
    // ask Swing to use Skin Look And Feel
    UIManager.setLookAndFeel(
    "com.l2fprod.gui.plaf.skin.SkinLookAndFeel");
    SwingUtilities.updateComponentTreeUI(this);
    this.validate();
    this.updateUI();
    } catch (Exception er) {
    System.out.println("Failed loading L&F: ");
    er.printStackTrace();
    void jButton5_mouseClicked(MouseEvent e) {
    try {
    Skin skin = null;
    skin = SkinLookAndFeel.loadThemePack("skins/themepack.zip");
    // set the skin
    SkinLookAndFeel.setSkin(skin);
    // ask Swing to use Skin Look And Feel
    UIManager.setLookAndFeel(
    "com.l2fprod.gui.plaf.skin.SkinLookAndFeel");
    } catch (Exception er) {
    er.printStackTrace();
    void jButton3_actionPerformed(ActionEvent e) {
    thread_load_cube load = new thread_load_cube();
    load.start();
    public void jButton7_actionPerformed(ActionEvent e) {
    JApplet applet=null;
    frame_applet frame=null;
    try{
    //ExtClassLoader ecl = new ExtClassLoader("/home/kevinet/CODE/JAVA/jlguiapplet2.3.1-selfsigned/lib/jlguiapplet2.3.jar");
    //Class demo = ecl.loadClass("javazoom.jlgui.player.amp.PlayerApplet");
    Class demo = java.lang.ClassLoader.getSystemClassLoader().loadClass("kevin_shell.Kdemos.test_applet");
    applet = (JApplet) demo.newInstance();
    frame=new frame_applet(applet);
    } catch (ClassNotFoundException cnfe) {
    cnfe.printStackTrace();
    System.out.println("problem with class");
    catch (IllegalAccessException iae) {
    iae.printStackTrace();
    System.out.println("acces problem");
    catch (InstantiationException ie) {
    ie.printStackTrace();
    System.out.println("instance");
    System.out.println("hello");
    pan_workspace.add(frame);
    applet.init();
    //applet.setLocation(0,0);
    applet.start();
    frame.setVisible(true);
    frame.show();
    frame.setLocation(300, 300);
    frame.setSize(300, 300);
    frame.setResizable(true);
    frame.setTitle("test applet");
    frame.setIconifiable(true);
    frame.setClosable(true);
    }

    What about calling getLocation on the applet itself?
    Otherwise, if you are using Swing, you can try (where "this" is the applet object):
    javax.swing.SwingUtilities.getWindowAncestor(this).getLocation();
    or
    javax.swing.SwingUtilities.convertPointToScreen(this.getLocation(), this);
    The latter should work, at least.

  • JApplet not found in Internet Explorer 5.0

    I learning how works JApplet's, but I Have a problem.
    Somebody can say to me because my code does not work?
    My code:
    import javax.swing.JApplet;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    public class JAppletExample extends JApplet
    JButton jb;
    BorderLayout layout;
    public void init()
    layout=new BorderLayout(20,10);
    this.setLayout(layout);
    jb=new JButton("prueba ");
    this.add("Center",jb);
    public void start() { }
    This is the error message from the Java Console:
    java.lang.ClassNotFoundException: javax.swing.JApplet
         at com/ms/vm/loader/URLClassLoader.loadClass
         at java/lang/ClassLoader.loadClassInternal
         at java/lang/ClassLoader.resolveClass
         at com/ms/vm/loader/URLClassLoader.loadClass
         at com/ms/vm/loader/URLClassLoader.loadClass
         at com/ms/applet/AppletPanel.securedClassLoad
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.run
         at java/lang/Thread.run
    Thanks in advance.

    You can force Internet Explorer to use the Sun Java Plugin by changing this key into windows registry:
    Registry>HKEY_LOCAL_MACHINE>SOFTWARE>JavaSoft>Java Plug-in>1.4.1_02>UseJava2Iexplorer
    Modify the value REG_DWORD from 0x00000000 (0) to 0x00000001 (1). This way you force IE to use your installed Sun Java Virtual Machine (with Swing support) instead the old Microsoft Virtual Machine.

  • Fighting with JApplet and HTML

    Ifmy Browser is using jvm1.4.1 do I still have to use the html converter to display my JApplet?
    This is the error I get from the java console:
    java.lang.InstantiationException: QuestionScreen
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Thanks
    Jim

    The reason that I ask is because if the MS JVM is used, which is version 1.1, and an applet that has been compiled with a recent version of Sun JVM like 1.4.2 attempts to run in the MS JVM, then a ClassNotFoundException will be generated regardless of the position of the class files. So it is very important to determine that your browser is really using the Sun JVM..Try to view the console with the applet running to be sure.
    Note that the applet tag has been deprecated. But if you use the applet tag, I suggest including a codebase attribute such as "." which refers to the current working directory, where the index.html file originated.
    <applet code="com.myjavaserver.codecraig.applet.JMoviesApplet.class" codebase="." archive="JMovies.jar, jdom.jar, packer.jar" width="800" height="600">
    Your browser is completely ignoring the <APPLET> tag.
    </applet>You may want to try the object tag, and see if you can avoid the error. The class id value is for dynamic versioning..
    <object classid="8AD9C840-044E-11D1-B3E9-00805F499D93" width="800" height="600">
    <param name="type" value="application/x-java-applet;version=1.4">
    <param name="code" value="com.myjavaserver.codecraig.applet.JMoviesApplet.class">
    <param name="codebase" value=".">
    <param name="archive" value="JMovies.jar, jdom.jar, packer.jar">
    Your browser is completely ignoring the <object> tag.
    </object>

  • Why JApplet and JSP cannot connect to MySQL

    When i use applet connect to MySQL, it show that no suitable driver.
    My program is
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    public class fuck extends JApplet implements ActionListener
    private JButton bb = new JButton("update");
    private JTextArea aa = new JTextArea(1,7);
    private JTextArea ss = new JTextArea(1,7);
    private JPanel pp = new JPanel();
    public fuck()
    Container c=getContentPane();
    pp.add(aa);
    pp.add(ss);
    pp.add(bb);
    c.add(pp);
    bb.addActionListener(this);
    public void actionPerformed(ActionEvent ee)
    try
    Class.forName("org.gjt.mm.mysql.Driver");
    catch(ClassNotFoundException e)
    System.out.println(e.getMessage());
    try
    Connection con =
    DriverManager.getConnection("jdbc:mysql://localhost/air","root","");
    Statement st = con.createStatement();
    //PreparedStatement pst = con.prepareStatement(
    // "update aa set condition=? where temp=?");
    //pst.setInt(1,3);
    //pst.setString(2,"hg");
    //pst.executeUpdate();
    ResultSet rs=
    st.executeQuery("select * from aa");
    while (rs.next())
    aa.setText(rs.getString("temp"));
    ss.setText(rs.getString("condition"));
    st.close();
    con.close();
    catch(SQLException ex)
    System.err.println("SQLException:"+ex.getMessage());
    If I using JSP, it also have some condition

    Clearly it is in the classpath, otherwise the error would have been "Class not found". But here's a quote from the documentation for the driver, the part that explains how to make a connection:// The newInstance() call is a work around for some
    // broken Java implementations
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();The "broken Java implementations" it refers to are certain JVMs that run applets in browsers...

  • Regarding  problem  of database connectivity of JApplet

    Below written code gives the error "JAVA.Lang.RuntimePermissionaccessClasslnPackage.sun.jdbc.odbc".
    import javax.swing.*;
    import java.sql.*;
    import java.awt.event.*;
    import java.awt.*;
    public class appletDatabase extends JApplet implements ActionListener {
    JLabel l1;
    JLabel l2;
    JLabel l3;
    JTextField tf1;
    JPasswordField tf2;
    JButton btn;
    Connection cn;
    Statement st;
    String hostname;
    public void init() {
    //hostname = "localhost";
    l1 = new JLabel("User Name: ");
    l2 = new JLabel(" Password: ");
    l3 = new JLabel(" ");
    tf1 = new JTextField(20);
    tf2 = new JPasswordField(20);
    btn = new JButton("Sign in");
    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT));
    c.add(l1);
    c.add(tf1);
    c.add(l2);
    c.add(tf2);
    c.add(btn);
    c.add(l3);
    btn.addActionListener(this);
    setSize(300,300);
    setVisible(true);
    public void actionPerformed(ActionEvent e) {
    if (e.getSource()==btn)
         JOptionPane.showMessageDialog(null,"btn click");
         check();
         JOptionPane.showMessageDialog(null,"success");
    public void check() {
    String query="SELECT * from TBJAVA";
    try {
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         cn = DriverManager.getConnection("jdbc:odbc:Temp","trg123","training");
         st = cn.createStatement();
         ResultSet rs = st.executeQuery(query);}
    /*if (!(rs==null))
    if (rs.next())
    b = true;
    rs.close();
    st.close();
    cn.close();
    /* catch (SQLException e1) {
              e1.printStackTrace();
              JOptionPane.showMessageDialog(null,"error in sql exception");
    catch (ClassNotFoundException e1) {
              e1.printStackTrace();
              JOptionPane.showMessageDialog(null,"error in class not founf");
         catch (Exception e1) {
              e1.printStackTrace();
              JOptionPane.showMessageDialog(null,"error in exception"+e1.getMessage());
    corresponding HTML code is given below:
    <html>
    <head>
    </head>
    <body><applet code="appletDatabase" width =400 height =400></applet>
    </body>
    </html>
    Please help
    regards
    kamal preet

    Please use code tags when posting code
    Applet sandbox do not allow you to access local system respurces unless the applet is signed.
    jdbc:odbc bridge always connect to the ODBC interface in the local system.

  • JApplet initialization problem

    I am experiencing a problem with a JApplet that has me perplexed... I wrote the JApplet to act as a front end to a servlet. I am using the Jakarta Tomcat server to execute both the servlet and to serve the web page which contains the applet. The html page containing the applet has been configure to load the latest JRE plugin into a users browser, if need be, and that works OK. When I run the applet from a browser on my own system, I don't have any problems, but when I tried to load the applet over the internet, at a friends house, I get the following walkback... Seems to be complaining about a "no proxy"... Can anyone tell me what this means? The applet does use Swing components, but my understanding is that is OK so long as the latest JRE plugin is installed. My server is up an down a lot, as I develop this application, but you are free to give the applet a try and let me know what you see... The URL is http://www.marcchamberlin.com/control.htm and don't be surprised that it is slow to respond, that is done on purpose so give it a minute... Any help would be much appreciated... ;-)
    Opening http://www.marcchamberlin.com/javax/swing/JApplet.class no proxy
    load: class DisplayStarChart.class not found.
    java.lang.ClassNotFoundException: DisplayStarChart
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:385)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:462)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:395)
    at sun.applet.AppletPanel.run(Compiled Code)
    at java.lang.Thread.run(Thread.java:474)
    P.S. What are Duke Dollars???? Seems to be a lack of documentation about them ;-)

    Seems to work OK for me. I got the applet, no problem, and the star-chart was a grey area with the text "star chart goes here". Eventually, the real star-chart appeared (and mighty cool iot looked, too ;-). Here's the output from my Java console:
    Servlet URL = http://www.marcchamberlin.com/servlet/StarChartServlet
    Servlet URL = http://www.marcchamberlin.com/servlet/StarChartServlet
    Attempting to connect to Star Chart Servlet
    Attempting to connect to Star Chart Servlet
    Connection to servlet has succeeded!
    Servlet URL = http://www.marcchamberlin.com/servlet/StarChartServlet?user=userIdent&move=RA%3A+19h30m00.00sDEC%3A+%2B0%B00%270.0%22FOV%3A%2B20%B000%2700%22&date=2001-6-1T10%3A54%3A11
    Attempting to connect to Star Chart Servlet
    Connection to servlet has succeeded!
    Maybe the "no proxy" thing on your friend's system is because he/she is behind some kind of "difficult"' firewall, or the ISP has some strange proxy setup or something?? (I'm using a router as a firewall, and have no proxy set up). Anyway, I get the impression that it's the hardware, not your software, that is the problem. Maybe try it from somewhere else (the local library?!?)

  • Tomcat can't detect the class file of the JApplet.

    Hi,
    I am relatively new in the applet field. I am trying to invoke an JApplet through JSP.
    Problem is that i have to package the JApplet class files as it has to access other packages. also the JSP with the embedded JApplet exists in a different folder from the JApplet class files.
    I am getting the class not found exception.
    Context Path: http://localhost:8080/sncdatagate
    folder structure as follows.
    sncdatagate\jsp\myApplet.jsp
    sncdatagate\WEB-INF\classes\datagate\ui\myApplet.class
    package for myApplet.java : datagate.ui
    The JSP code is as follows :-
    <jsp:plugin
    type="applet"
    code="datagate.ui.myApplet"
    codebase="/sncdatagate/"
    width ="700"
    height="400"
    iepluginurl="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_01a-win.cab#version=1,3,1,1"
    nspluginurl="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_01a-win.cab#version=1,3,1,1"
    jreversion="1.3.1_01">
         <jsp:params>
                             <jsp:param name = "encodedString" value="<%=encodedString%>"/>
              </jsp:params>
    </jsp:plugin>
    The error on Java console is as follows:-
    load: class datagate.ui.myApplet not found.
    java.lang.ClassNotFoundException: java.io.FileNotFoundException: File not found: http://localhost:8080/sncdatagate/datagate/ui/myApplet.class
         at sun.plugin.protocol.jdk12.http.HttpURLConnection.getInputStream(Unknown Source)
         at java.net.HttpURLConnection.getResponseCode(Unknown Source)
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Kind help!
    Would greatly appreciate any suggestions.
    Thank You.
    regards,
    Priya

    The WEB-INF\classes\ folder is meant for servlets and the files insides are accessed thru the "servlet/" folder. To run applets, place them outside of the web-inf folder together with your jsp files.
    If your applet has a package, remember to create appropriate folders for it. Eg.
    sncdatagate\jsp\myApplet.jsp
    sncdatagate\datagate\ui\myApplet.class
    <applet
    code="datagate.ui.myApplet"
    codebase="/sncdatagate/" ...

  • JApplet  AND DB MYSQL

    Greetings from MX.
    I am generating a JApplet with connection to a database when running in appletviewer this send me the following error: (java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver).
    Now if I run it from IExplorer or Netscape only loads me the graphic hambiente.
    Already generate a file XXX.jar with the XX.class and the mysql driver.
    As this it could solve..?
    Thanks for your help.

    did you put the MySQL driver in your classpath somewhere?
    either it can't find the driver because of a classpath problem or the applet is restricted from accessing the driver because of some sandbox restriction.
    hope this helps

  • Trouble getting at JApplet from HTML

    Hey just wanted to pick your brains about this one. I have tried to put my JApplet online, however I'm getting a ClassNotFoundException caused by IOException openHTTP connection failed.
    It has been set up as follows.
    On my server space I have a page
    http://www.computingscotland.org/hangcipher.php
    The applet is called by the following HTML:
                        <!--[if !IE]>-->
                        <object classid="java:hang_cipher.hang_cipher.Applet_Control.class"
                                  type="application/x-java-applet"
                                  archive="/Applet/hang_cipher.jar"
                                  height="800" width="710" >
                        <!-- Konqueror browser needs the following param -->
                        <param name="archive" value="/Applet/hang_cipher.jar" />
                        <!--<![endif]-->
                        <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                                  height="800" width="710" >
                             <param name="code" value="hang_cipher.hang_cipher.Applet_Control" />
                             <param name="archive" value="/Applet/hang_cipher.jar" />
                        </object>
                        <!--[if !IE]>-->
                        </object>
                        <!--<![endif]-->
    The applet is located here in this folder
    http://www.computingscotland.org/Applet
    The folder contains hang_cipher.jar
    The jar file contains a package called hang_cipher
    finally in this package is Applet_Control.class

    Ok I just ditched one of the hang_ciphers, using this now
                        <!--[if !IE]>-->
                        <object classid="java:hang_cipher.Applet_Control.class"
                                  type="application/x-java-applet"
                                  archive="/Applet/hang_cipher.jar"
                                  height="800" width="710" >
                        <!-- Konqueror browser needs the following param -->
                        <param name="archive" value="/Applet/hang_cipher.jar" />
                        <!--<![endif]-->
                        <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                                  height="800" width="710" >
                             <param name="code" value="hang_cipher.Applet_Control" />
                             <param name="archive" value="/Applet/hang_cipher.jar" />
                        </object>
                        <!--[if !IE]>-->
                        </object>
                        <!--<![endif]-->
    But instead I get NoClassDefFoundError: hang_cipher/Applet_Control(wrong name: Applet_Control)
    Ok a different error message is this a step in the right direction.
    Is this something to do with x-java-applet being the wrong one to use. I have no idea

  • Need to convert JApplet to JFrame

    I need to write code for where I have 60 balls bouncing around inside a window. The client will then be able to select a button and it will pull out a ball with the number 1-60 written on it. The user will be able to do this up to 7 times. Each time it is done the past numbers that have already appeared can not reappear. What I am stuck on right now is geting my balls into a JFrame. Can anyone give advice or show how to. I currently have my 60 balls running in a JApplet. Here is the JAVA code and the HTML code. Thanks!
    Here is the JAVA code
    import java.awt.*;
    import java.applet.*;
    import java.util.*;
    import javax.swing.*;
    class CollideBall{
    int width, height;
    public static final int diameter=20;
    //coordinates and value of increment
    double x, y, xinc, yinc, coll_x, coll_y;
    boolean collide;
    Color color;
    Graphics g;
    Rectangle r;
    //the constructor
    public CollideBall(int w, int h, int x, int y, double xinc, double yinc, Color c){
    width=w;
    height=h;
    this.x=x;
    this.y=y;
    this.xinc=xinc;
    this.yinc=yinc;
    color=c;
    r=new Rectangle(150,80,130,90);
    public double getCenterX() {return x+diameter/2;}
    public double getCenterY() {return y+diameter/2;}
    public void alterRect(int x, int y, int w, int h){
    r.setLocation(x,y);
    r.setSize(w,h);
    public void move(){
    if (collide){  
    double xvect=coll_x-getCenterX();
    double yvect=coll_y-getCenterY();
    if((xinc>0 && xvect>0) || (xinc<0 && xvect<0))
    xinc=-xinc;
    if((yinc>0 && yvect>0) || (yinc<0 && yvect<0))
    yinc=-yinc;
    collide=false;
    x+=xinc;
    y+=yinc;
    //when the ball bumps against a boundary, it bounces off
    if(x<6 || x>width-diameter){
    xinc=-xinc;
    x+=xinc;
    if(y<6 || y>height-diameter){
    yinc=-yinc;
    y+=yinc;
    //cast ball coordinates to integers
    int x=(int)this.x;
    int y=(int)this.y;
    //bounce off the obstacle
    //left border
    if(x>r.x-diameter&&x<r.x-diameter+7&&xinc>0&&y>r.y-diameter&&y<r.y+r.height){
    xinc=-xinc;
    x+=xinc;
    //right border
    if(x<r.x+r.width&&x>r.x+r.width-7&&xinc<0&&y>r.y-diameter&&y<r.y+r.height){
    xinc=-xinc;
    x+=xinc;
    //upper border
    if(y>r.y-diameter&&y<r.y-diameter+7&&yinc>0&&x>r.x-diameter&&x<r.x+r.width){
    yinc=-yinc;
    y+=yinc;
    //bottom border
    if(y<r.y+r.height&&y>r.y+r.height-7&&yinc<0&&x>r.x-diameter&&x<r.x+r.width){
    yinc=-yinc;
    y+=yinc;
    public void hit(CollideBall b){
    if(!collide){
    coll_x=b.getCenterX();
    coll_y=b.getCenterY();
    collide=true;
    public void paint(Graphics gr){
    g=gr;
    g.setColor(color);
    //the coordinates in fillOval have to be int, so we cast
    //explicitly from double to int
    g.fillOval((int)x,(int)y,diameter,diameter);
    g.setColor(Color.white);
    g.drawArc((int)x,(int)y,diameter,diameter,45,180);
    g.setColor(Color.darkGray);
    g.drawArc((int)x,(int)y,diameter,diameter,225,180);
    public class BouncingBalls extends Applet implements Runnable {
    Thread runner;
    Image Buffer;
    Graphics gBuffer;
    CollideBall ball[];
    //Obstacle o;
    //how many balls?
    static final int MAX=60;
    boolean intro=true,drag,shiftW,shiftN,shiftE,shiftS;
    boolean shiftNW,shiftSW,shiftNE,shiftSE;
    int xtemp,ytemp,startx,starty;
    int west, north, east, south;
    public void init() {  
    Buffer=createImage(getSize().width,getSize().height);
    gBuffer=Buffer.getGraphics();
    ball=new CollideBall[MAX];
    int w=getSize().width-5;
    int h=getSize().height-5;
    //our balls have different start coordinates, increment values
    //(speed, direction) and colors
    for (int i = 0;i<60;i++){
    ball=new CollideBall(w,h,50+i,20+i,1.5,2.0,Color.white);
    /* ball[1]=new CollideBall(w,h,60,210,2.0,-3.0,Color.red);
    ball[2]=new CollideBall(w,h,15,70,-2.0,-2.5,Color.pink);
    ball[3]=new CollideBall(w,h,150,30,-2.7,-2.0,Color.cyan);
    ball[4]=new CollideBall(w,h,210,30,2.2,-3.5,Color.magenta);
    ball[5]=new CollideBall(w,h,360,170,2.2,-1.5,Color.yellow);
    ball[6]=new CollideBall(w,h,210,180,-1.2,-2.5,Color.blue);
    ball[7]=new CollideBall(w,h,330,30,-2.2,-1.8,Color.green);
    ball[8]=new CollideBall(w,h,180,220,-2.2,-1.8,Color.black);
    ball[9]=new CollideBall(w,h,330,130,-2.2,-1.8,Color.gray);
    ball[10]=new CollideBall(w,h,330,10,-2.1,-2.0,Color.gray);
    ball[11]=new CollideBall(w,h,220,230,-1.2,-1.8,Color.gray);
    ball[12]=new CollideBall(w,h,230,60,-2.3,-2.5,Color.gray);
    ball[13]=new CollideBall(w,h,320,230,-2.2,-1.8,Color.gray);
    ball[14]=new CollideBall(w,h,130,300,-2.7,-3.0,Color.gray);
    ball[15]=new CollideBall(w,h,210,90,-2.0,-1.8,Color.gray);*/
    public void start(){
    if (runner == null) {
    runner = new Thread (this);
    runner.start();
    /* public void stop(){
    if (runner != null) {
    runner.stop();
    runner = null;
    public void run(){
    while(true) {
    Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    try {runner.sleep(15);}
    catch (Exception e) { }
    //move our balls around
    for(int i=0;i<MAX;i++)
    ball[i].move();
    handleCollision();
    repaint();
    boolean collide(CollideBall b1, CollideBall b2){
    double wx=b1.getCenterX()-b2.getCenterX();
    double wy=b1.getCenterY()-b2.getCenterY();
    //we calculate the distance between the centers two
    //colliding balls (theorem of Pythagoras)
    double distance=Math.sqrt(wx*wx+wy*wy);
    if(distance<b1.diameter)
    return true;
    return false;
    private void handleCollision()
    //we iterate through all the balls, checking for collision
    for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
    if(i!=j)
    if(collide(ball[i], ball[j]))
    ball[i].hit(ball[j]);
    ball[j].hit(ball[i]);
    public void update(Graphics g)
    paint(g);
    public void paint(Graphics g)
    gBuffer.setColor(Color.lightGray);
    gBuffer.fillRect(0,0,getSize().width,getSize().height);
    gBuffer.draw3DRect(5,5,getSize().width-10,getSize().height-10,false);
    //paint our balls
    for(int i=0;i<MAX;i++)
    ball[i].paint(gBuffer);
    g.drawImage (Buffer,0,0, this);
    Here is the HTML code
    <html>
    <body bgcolor="gray">
    <br><br>
    <div align="center">
    <applet code="BouncingBalls.class" width="1000" height="650"></applet>
    </div>
    </body>
    </html>

    In the future, Swing related questions should be posted in the Swing forum.
    First you need to convert your custom painting. This is done by overriding the paintComponent() method of JComponent or JPanel. Read the Swing tutorial on [Custom Painting|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html].
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the [Code Formatting Tags|http://forum.java.sun.com/help.jspa?sec=formatting], so the posted code retains its original formatting.

Maybe you are looking for

  • How to change message v1 501 to be an error message ?

    Hi guys, When i  use VA01  creating a sales order reference to contact, if sales order's quantity is larger than contact's quantity, the system gives an warning message : Target qty of reference: 100 PC (total referenced: 101 PC) Message no. V1501 I

  • Workflow & camera choice

    I'm considering purchasing the Panasonic AG-HMC40. However, the idea of shooting in a native FCP format (like the JVC GY-HM100) strikes me as a fantastic idea. On the other hand it costs 50-75% more. (Cost is always an issue, no?) After you trick out

  • UPDATE statment

    hi for all, plz i have a question ,i have a tabel called (ClientT) which contain these fielde First_Name Last_Name UserID Address Password BirthDate Answer and i need to make an Update to this table according to some informatio ,My Code Class.forName

  • Task flow question

    I have couple of jsf pages in adfc-config. Also, I have a bounded task flow. I want to invoke this bounded tf after users entered data in those unbounded tf pages. Thank you.

  • MBP not waking from sleep and getting very hot

    When my Mac Book Pro 15 inch is left for a period of time greater than approximately an hour and plugged in it should automatically go into sleep/hibernate mode. Something happens during this period but I can hear the fan running heavily, the MBP is