Getting error while using webrenderer in my applet - java

I am trying to get this code work (applet) its based on webrenderer trial , I got this code in example section.
Though I tried searching there site but it was of no use.I want to render page on my applet .
Below is full code I used , I really don't know what is wrong there.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.webrenderer.swing.*;
/**
* This example shows how to set up WebRenderer to run Java Applets
*
* #author JadeLiquid Software.
* #see www.webrenderer.com
*/
public class AppletExample
{
// instance of a browser
IMozillaBrowserCanvas browser;
JTextField textfield;
public AppletExample()
{
// Creates a JFrame to host the browser
JFrame frame = new JFrame("Applet Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create and append the browser
frame.setContentPane(createContent());
frame.setSize(640, 480);
frame.setVisible(true);
}
public JPanel createContent()
{
JPanel panel = new JPanel(new BorderLayout());
textfield = new JTextField();
panel.add(BorderLayout.NORTH, textfield);
// The action listener triggers when text is entered in the text field
textfield.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
browser.loadURL(textfield.getText());
}
});
// If you are behind a proxy server, it may be necessary to set the proxy authentication
// to enable access for page loading. Enable the following call(s) with the appropriate
// values for domain, port..
// These settings will need to be applied to both the browser and to enable applets.
//int yourProxyPort = 8080;
//String yourProxyServer = "proxyserver";
// Apply proxy settings to enable applets. Username and password will need to entered as
// a dialog does not appear automatically as is the case with the browser proxy.
//BrowserFactory.setAppletProxySettings(yourProxyServer, String.valueOf(yourProxyPort));
//BrowserFactory.setAppletProxyAuthentication("username", "password");
// Create a browser instance
browser = BrowserFactory.spawnMozilla();
// Required if a proxy server is being used.
//browser.setProxyProtocol(new ProxySetting( ProxySetting.PROTOCOL_ALL, yourProxyServer, yourProxyPort));
//browser.enableProxy();
// Required call to allow applets to function
browser.setAppletMode(IMozillaBrowserCanvas.ENABLE_JAVA_APPLETS);
// Load a site with many applet examples
browser.loadURL("java.sun.com/applets/jdk/1.4/index.html");
// Attach to the panel
panel.add(BorderLayout.CENTER, browser.getComponent());
return panel;
}
public static void main(String[] args)
{
/*
* TODO: Insert your username and key in the following setLicenseData call.
* WebRenderer operates with reduced functionality if the username and key are not correct.
* The sample key used below is a limited-duration trial key.
*/
BrowserFactory.setLicenseData( "30dtrial" , "9Q2QFT9JIK4OHO5BSNKHNMM9EMTR5NRG" );
new AppletExample();
}
}
When i try to run it i get error
java.lang.reflect.InvocationTargetException
Here is debug info
Initializing jdb ...
Internal exception:
java.io.IOException: The handle is invalid
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:242)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
at com.sun.tools.example.debug.tty.TTY.<init>(TTY.java:751)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1067)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at sun.applet.Main.invokeDebugger(Main.java:314)
at sun.applet.Main.run(Main.java:143)
at sun.applet.Main.main(Main.java:98)

Please make sure that you have followed these steps as outlined in the documentation: http://www.webrenderer.com/products/swing/developer/developersguide/files/appletdeploy.htm

Related

How to drag-and-drop data from a browser into a java swing application with a custom MIME type?

I am currently writing a program that enables the user to drag-and-drop some data from a browser into a java swing application. This works as intended for the mime type "text/plain", but when using a custom mime type in the javascript, the java application does not receive the data anymore.
The javascript side is done as described in this answer:
for (const el of document.querySelectorAll('[draggable="true"]')) {
el.addEventListener('dragstart', (e) => {
e.dataTransfer.setData('text/plain', e.currentTarget.dataset.content);
});
}
The java application looks like this MRE. The MRE just prints out any received drops.
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.io.IOException;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame();
JTextArea area = new JTextArea();
area.setDropTarget(new DropTarget() {
#Override
public synchronized void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(TransferHandler.COPY_OR_MOVE);
try {
// For testing
System.out.println(Arrays.toString(dtde.getTransferable().getTransferDataFlavors()));
// Business logic, e.g.
System.out.println(dtde.getTransferable().getTransferData(DataFlavor.stringFlavor));
} catch (UnsupportedFlavorException | IOException e) {
e.printStackTrace();
}
}
});
frame.add(area);
// Only for MRE, never set size like this for actual programs
area.setPreferredSize(new Dimension(200, 100));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
This works as it should with the jsfiddle from the linked answer. However, the data that should be transferred is not just a plain text but actually a json string. Also, the string should only be dropped in my own application and not into any text editor. Therefore I changed the mime type in the javascript to 'text/json'. On the java side, I replaced
System.out.println(dtde.getTransferable().getTransferData(DataFlavor.stringFlavor));
with
System.out.println(dtde.getTransferable().getTransferData(new DataFlavor("text/json;class=java.lang.String")));
Which leads to an UnsupportedFlavorException in that line:
java.awt.datatransfer.UnsupportedFlavorException: text/json
at java.desktop/sun.awt.dnd.SunDropTargetContextPeer.getTransferData(SunDropTargetContextPeer.java:256)
at java.desktop/sun.awt.datatransfer.TransferableProxy.getTransferData(TransferableProxy.java:73)
at java.desktop/java.awt.dnd.DropTargetContext$TransferableProxy.getTransferData(DropTargetContext.java:386)
at Main$1.drop(Main.java:23)
Additionally, the TransferDataFlavors array is empty, suggesting no DataFlavor is available. I considered to overwrite the FlavorMap to ensure the native mime type is mapped to the correct flavor, but debugging the getFlavorsForFormats method in DataTransferer revealed only the following natives are requested (using chrome):
"DragContext", "chromium/x-renderer-taint", "Chromium Web Custom MIME Data Format", and "DragImageBits", so my custom mime type is not even available as native type.
How do I transfer the data correctly from the browser to the java application? Do I need to register my flavor somewhere? Or is this not possible and I need to stick to text/plain?

Java simple web browser weird output

To learn Networking in Java, I followed a tutorial to create a new web browser in NetBeans. Here is the code in ReadFile class:
package WebBrowser;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/**
*
* #author Siddharth Venu
*
*/
public class ReadFile extends JFrame{
private JTextField addressBar;
private JEditorPane display;
//constructor
public ReadFile(){
super("Sid Browser");
addressBar=new JTextField("Enter address");
//lambda expression instead of anonymous class
addressBar.addActionListener((ActionEvent event) -> {
loadData(event.getActionCommand());
});
add(addressBar,BorderLayout.NORTH);
display = new JEditorPane();
display.setEditable(false);
display.addHyperlinkListener((HyperlinkEvent event) -> {
if(event.getEventType()==HyperlinkEvent.EventType.ACTIVATED)
loadData(event.getURL().toString());
});
add(new JScrollPane(display), BorderLayout.CENTER);
setSize(500,300);
setVisible(true);
}
//load the data to display on the screen
private void loadData(String address){
try{
display.setPage(address);
addressBar.setText(address);
}catch(Exception e){
System.out.println(e);
}
}
}
And here is the code in the Main class:
package WebBrowser;
import javax.swing.JFrame;
/**
*
* #author Siddharth Venu
*
*/
public class Main {
public static void main(String[] args){
ReadFile browser=new ReadFile();
browser.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
I then ran the Main class, at beginning, as it is not displaying any data from a website, it is looking good with address bar on the top. But when I enter an URL, say http://google.com, it displays weird output as in the following image.
Why exactly is this happening? The weird blue background and misaligned Google logo.
[Edit] I got to know that the setPage method can only handle HTML, plain text or RTF and not js. But it should at least display the HTML part without the weird blue screen na? PS: The blue screen is appearing in other sites like facebook too.
I've tested your browser. I'm getting the same results on pages with html5, javascript and css like google.com or facebook.com.
But when I use bare to the bones website like this it obviously works. So I must assume that the issue was the lack of support for these technologies in this simple browser.
As for the guy in the video linked he used bare html google webpage which I was unable to find or read out from the video (or made the video some time ago). People in the youtube comment section were addressing your issue as well. They were describing it as a lack of support for html5 in Swing. However some managed to make it work properly in JavaFX.

Constructor must call super() or this()

Can anyone help me with the following error report (for the code at the bottom):
Exception in thread "AWT-EventQueue-0" java.lang.VerifyError: Constructor must call super() or this() before return in method org.jfree.ui.RectangleInsets.<init>()V at offset 0
at org.jfree.chart.axis.Axis.<clinit>(Axis.java:153)
at org.jfree.chart.StandardChartTheme.<init>(StandardChartTheme.java:233)
at org.jfree.chart.StandardChartTheme.<init>(StandardChartTheme.java:319)
at org.jfree.chart.ChartFactory.<clinit>(ChartFactory.java:231)
at odesolver.ODESolver.createGraph(ODESolver.java:81)
at odesolver.ODESolver.<init>(ODESolver.java:35)
at odesolver.ODESolver$2.run(ODESolver.java:105)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
BUILD SUCCESSFUL (total time: 2 seconds)
which relates to the following 3 lines of the code:
ODESolver.java:81
JFreeChart chart = ChartFactory.createXYLineChart(
ODESolver.java:35
createGraph();
ODESolver.java:105
new ODESolver(); // Let the constructor do the job
Whole program:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package odesolver;
/**
*
* #author User
*/
import java.awt.*; // Using AWT containers and components
import java.awt.event.*; // Using AWT events and listener interfaces
import javax.swing.*; // Using Swing components and containers
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.ChartPanel;
import org.jfree.data.general.Series;
// A Swing GUI application inherits the top-level container javax.swing.JFrame
public class ODESolver extends JFrame {
private JTextField tfInput, tfOutput;
private int numberIn; // input number
private int sum = 0; // accumulated sum, init to 0
/** Constructor to setup the GUI */
public ODESolver() {
// Retrieve the content-pane of the top-level container JFrame
// All operations done on the content-pane
Container cp = getContentPane();
cp.setLayout(new GridLayout(2, 2, 5, 5));
createGraph();
add(new JLabel("Enter an Integer: "));
tfInput = new JTextField(10);
add(tfInput);
add(new JLabel("The Accumulated Sum is: "));
tfOutput = new JTextField(10);
tfOutput.setEditable(false); // read-only
add(tfOutput);
// Allocate an anonymous instance of an anonymous inner class that
// implements ActionListener as ActionEvent listener
tfInput.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
// Get the String entered into the input TextField, convert to int
numberIn = Integer.parseInt(tfInput.getText());
sum += numberIn; // accumulate numbers entered into sum
tfInput.setText(""); // clear input TextField
tfOutput.setText(sum + ""); // display sum on the output TextField
}
});
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Exit program if close-window button clicked
setTitle("ODE Accumulator"); // "this" Frame sets title
setSize(350, 120); // "this" Frame sets initial size
setVisible(true); // "this" Frame shows
}
private JPanel createGraph() {
JPanel panel = new JPanel();
XYSeries series = new XYSeries("MyGraph");
series.add(0, 1);
series.add(1, 2);
series.add(2, 5);
series.add(7, 8);
series.add(9, 10);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
JFreeChart chart = ChartFactory.createXYLineChart(
"XY Chart",
"x-axis",
"y-axis",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
ChartPanel chartPanel = new ChartPanel(chart);
panel.add(chartPanel);
return panel;
}
/** The entry main() method */
public static void main(String[] args) {
// Run the GUI construction in the Event-Dispatching thread for thread-safety
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
new ODESolver(); // Let the constructor do the job
}
});
}
}
Maybe the problem is that there are files in ODESolver, src and lib with errors, as netbeans reports (see screenshot below). I don't know which files are upposed to have errors though, as none of then have an exclamation mark on them, as they usually do of they have errors.
You appear to be running an old version of JFreeChart which produces this error. Upgrade to version 1.0.13 as found here
problem was solved by adding the jar files to the classpath, rather than the folder containing them
The various constructors of JFrame do important initialisation work, that any JFrame requires. Therefore, every JFrame that is ever created must have one of those constructors called. But because an ODESolver is also a JFrame, that applies to ODESolver objects too.
Fortunately, the Java language enforces this. We can't create an ODESolver, without one of the JFrame constructors getting called. The way it enforces it is by requiring every ODESolver constructor to be mapped to a JFrame constructor.
When we create an ODESolver, one of the ODESolver constructors will get called. But that constructor must specify which JFrame constructor will get called. The way it does that is by doing one of the following.
specifying explicitly which JFrame constructor to use, via a call to super(), with or without some arguments;
calling another ODESolver constructor, via a call to this(), with or without some arguments.
In either case, the call to super() or this() must be the first line of the ODESolver constructor.

browsing javascript

I want to write a simple web browser in java and here’s my code!
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class WebBrowser extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
public JPanel
address_panel, window_panel;
public JLabel
address_label;
public JTextField
address_tf;
public JEditorPane
window_pane;
public JScrollPane
window_scroll;
public JButton
address_b;
private Go go = new Go();
public WebBrowser() throws IOException {
// Define address bar
address_label = new JLabel(" address: ", SwingConstants.CENTER);
address_tf = new JTextField("http://www.yahoo.com");
address_tf.addActionListener(go);
address_b = new JButton("Go");
address_b.addActionListener(go);
window_pane = new JEditorPane("http://www.yahoo.com");
window_pane.setContentType("text/html");
window_pane.setEditable(false);
address_panel = new JPanel(new BorderLayout());
window_panel = new JPanel(new BorderLayout());
address_panel.add(address_label, BorderLayout.WEST);
address_panel.add(address_tf, BorderLayout.CENTER);
address_panel.add(address_b, BorderLayout.EAST);
window_scroll = new JScrollPane(window_pane);
window_panel.add(window_scroll);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
pane.add(address_panel, BorderLayout.NORTH);
pane.add(window_panel, BorderLayout.CENTER);
setTitle("web browser");
setSize(800,600);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public class Go implements ActionListener{
public void actionPerformed(ActionEvent ae){
try {
window_pane.setPage(address_tf.getText());
} catch (MalformedURLException e) { // new URL() failed
window_pane.setText("MalformedURLException: " + e);
} catch (IOException e) { // openConnection() failed
window_pane.setText("IOException: " + e);
}
}
}
public static void main(String args[]) throws IOException {
WebBrowser wb = new WebBrowser();
}
}
It works fine for simple html pages but it cannot load JavaScript part of the code! My problem is what should I add to the code to load the javascripts? Thank you!
Swing's default widgets only have very basic support for HTML4 and CSS, with absolutely no support for JavaScript at all (by default). You could potentially use the built-in Rhino JavaScript engine to execute the code, but that would have to be done manually and would be pretty difficult. HtmlUnit uses this tactic to parse HTML pages and execute the JavaScript, but it has generally poor compatibility and completely lacks a renderer, so you'd have to write that yourself (i.e. no display, you only get access to the page content from code).
There's a few Swing-based browser widgets floating around which embed a Gecko (Firefox) or WebKit (Chrome/Safari) renderer and would thus be able to take advantage of proper JavaScript interpreters, but they're all buggy, expensive, or unmaintained. These would all support JavaScript but they generally use very old versions of the various browser engines and have poor compatibility with modern websites, in addition to lacking cross-platform compatibility.
Eclipse's SWT project includes a browser widget that appears to be actively maintained, but has a dependence on the SWT libraries and would be somewhat more difficult to use in a Swing application, though it may be possible. SWT is an entirely different UI toolkit from AWT/Swing (which you're currently using) and in order to take advantage of its browser widget, you'd have to find a way to embed it in a Swing app, or use only the SWT toolkit.
Overall, SWT's browser is probably your best bet for getting a decent browser in Java, but it may still be troublesome to use. Good luck!

Debugging java applet in browser - works in Eclipse but not browser

I have created an applet that opens a JFileChooser to select a file on the click of a JButton. It works fine when I run it in Eclipse. When I embed it in an HTML page with the applet tag nothing happens when I click the button.
Any suggestions as to why the JFileChooser does not open in the browser would be appreciated, but my main question is how would I debug this? I haven't been able to find anything on Google about how to add a Java console to Firefox 3.6 or Chrome. Is there a way to get some kind of information as to why the JFileChooser does not open?
Debugging answered in comment below
So the console says there is an access denied exception, which I'm guessing is because I have not "signed" the applet. What should the development process be as far as signing an applet goes? Do I have to sign it with a certificate issued by a valid CA before I can test it in a browser, or is there some simple thing you can do while just testing?
Here is my code:
package com.putapplet;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.net.URL;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
#SuppressWarnings("serial")
public class PutToS3Applet extends JApplet {
private static long maxFileSizeInBytes = 1048576;
private static String listenerUrl = "xxx";
private String listenerQueryString;
private String signedPutUrl;
private JProgressBar progressBar;
private JButton button;
private JLabel messageField;
public void init() {
setMaxFilesize(1);
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGUI();
}
});
} catch (Exception e) {
System.err.println("createGUI didn't complete successfully");
}
}
private void createGUI() {
button = new JButton("Choose File...");
button.addActionListener(new ButtonListener());
progressBar = new JProgressBar(0, 100);
progressBar.setStringPainted(true);
messageField = new JLabel();
//messageField.setPreferredSize(new Dimension(300, 20));
FlowLayout layout = new FlowLayout();
layout.setAlignment(FlowLayout.LEFT);
JPanel topPanel = new JPanel();
topPanel.setLayout(layout);
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(layout);
topPanel.add(button);
topPanel.add(progressBar);
bottomPanel.add(messageField);
setLayout(new GridLayout(2,1));
add(topPanel);
add(bottomPanel);
}
class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent ae) {
JFileChooser fileChooser = new JFileChooser();
int showOpenDialog = fileChooser.showDialog(null, "Upload File");
if (showOpenDialog != JFileChooser.APPROVE_OPTION) return;
final File fileToUpload = fileChooser.getSelectedFile();
if (fileToUpload.length() > PutToS3Applet.maxFileSizeInBytes) {
messageField.setText("Your file must be smaller than " + getHumanReadableMaxFilesize());
return;
}
listenerQueryString = "query[filename]=" + fileToUpload.getName();
//get signed PUT url for s3
try {
URL listener = new URL(listenerUrl + listenerQueryString);
BufferedReader in = new BufferedReader(new InputStreamReader(listener.openStream()));
signedPutUrl = in.readLine().replace("http://", "https://");
messageField.setText(signedPutUrl);
} catch (Exception e) {
messageField.setText("Oops, there was a problem connecting to the server. Please try again.");
e.printStackTrace();
}
}
}
private String getHumanReadableMaxFilesize() {
return Long.toString((PutToS3Applet.maxFileSizeInBytes / 1024 / 1024)) + "MB";
}
private void setMaxFilesize(int sizeInMegaBytes) {
PutToS3Applet.maxFileSizeInBytes = PutToS3Applet.maxFileSizeInBytes * sizeInMegaBytes;
}
}
Here is the exception:
Exception in thread "AWT-EventQueue-1" java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)
at java.lang.System.getProperty(System.java:650)
at javax.swing.filechooser.FileSystemView.getHomeDirectory(FileSystemView.java:393)
at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(MetalFileChooserUI.java:253)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:136)
at javax.swing.plaf.metal.MetalFileChooserUI.installUI(MetalFileChooserUI.java:126)
at javax.swing.JComponent.setUI(JComponent.java:662)
at javax.swing.JFileChooser.updateUI(JFileChooser.java:1763)
at javax.swing.JFileChooser.setup(JFileChooser.java:360)
at javax.swing.JFileChooser.<init>(JFileChooser.java:333)
at javax.swing.JFileChooser.<init>(JFileChooser.java:286)
at com.putapplet.PutToS3Applet$ButtonListener.actionPerformed(PutToS3Applet.java:82)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6289)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6054)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4652)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4482)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Component.dispatchEvent(Component.java:4482)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:603)
at java.awt.EventQueue$1.run(EventQueue.java:601)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:617)
at java.awt.EventQueue$2.run(EventQueue.java:615)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Just a side note. It's rather easy to remote debug applets.
Configure the Java plugin to allow remote debugging. You do it in different ways in different platforms, but it will be something like this on windows. Start the control panel, select java. Click around till you find VM options, and add these VM arguments:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=6789,suspend=n
6789 will be the debug port.
Starting the remote debugging in Eclipse is done by doing something similar to. Debug configurations, Remote Java Application, Create a new configuration. Select Standard (Socket Attach) as connection type, and enter locahost as address and 6789 as port.
Consider enabling the Java Console which will allow you to see all the exception stack traces hopefully making it easier for you to debug.
Also "appletviewer" is designed for testing applets outside a browser including allowing you to see the exceptions.
It's very likely that your SecurityManager isn't allowing it.
In FireFox, you can check the java console by going to Tools > Java Console. Firefox should already have it set up.
Implementing a logging solution (such as Log4j) is another option that might be worth looking at. Some quick tutorials on how to get this up and running.
when you embed your applet in html page you have to sign the applet jar file
See the documentation
oracle docs
create your certificate then use
then in command prompt type the following command
jarsigner jarfilename.jar yourcertificatename

Categories

Resources