• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JOptionPane

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
When I implemented JOptionPane in a simple program which is illustrated below, its working fine. But When I implemented it in an applet it is giving me java.lang.ClassNotFound Exception. My question is, can we implement all of the Swing componeets in an applet (Are there any Swing components that can't be embedded in an applet). I have included the below code snippets for clarification.
----------- (Working :: SwingTest.java)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SwingTest1 {
public static void main(String args[]) {
Frame f = new Frame("SwingTest1");
f.setSize(200,300);
f.setVisible(true);
JOptionPane.showMessageDialog(f, "There's no \"there\" there.");
}
}
-----------
------------ (not working :: SwingTest1Applet.java)
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SwingTest1Applet extends Applet {
public void init() {
Frame f = new Frame("SwingTest1");
f.setSize(200,300);
f.setVisible(true);
JOptionPane.showMessageDialog(f, "There's no \"there\" there.");
}
}
-------------
------------- ( testswingtest.html [SwingTest1Applet.class and testswingtest.html are in same directory] )
<applet code="SwingTest1Applet" width=200 height=300>
</applet>
-------------
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Praveen,
It looks (to me) like you need to familiarize yourself with the Java Plug-in Technology.
Good Luck,
Avi.
 
ch praveen
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Avi for your response. In my browser applets that containing awt components are working well. Now I want to switch the interface to Swings. Initially When I incorporated JOptionPane in my applet as shown above it, browser thrown a ClassNotFound Exception, later I have included a classpath to rt.jar. Now its throwing jva.lang.UnsatisfiedlinkError: java/security/AccessController doPriviled Exception. Can't we implement swings in applet that extends Applet instead of JApplet (code depicted in SwingTest1Applet.java , my firt post wrt.this topic)
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your applet is throwing a ClassNotFoundException when using Swing, the solution is not to add rt.jar to the classpath! That would mean the user would have to download the full Java API ( a ~22MB jarfile) every time they accessed the applet. The problem is that you don't have the Java Plugin installed in your browser (follow the link provided above by Avi). You shouldn't mix AWT and Swing components - so you shouldn't use Swing components in a regular Applet (with extends AWT's Panel class). You should use JApplet instead if you want to use Swing.
 
You can't expect to wield supreme executive power just because
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic