Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32589

Re: Applets?

From Knute Johnson <nospam@rabbitbrush.frazmtn.com>
Newsgroups comp.lang.java.programmer
Subject Re: Applets?
Date 2015-09-15 17:56 -0700
Organization A noiseless patient Spider
Message-ID <mtaeks$mbq$1@dont-email.me> (permalink)
References <a3f016f7-b5fa-4c80-8cb0-5ebf0a533298@googlegroups.com>

Show all headers | View raw


My best guess is you are using a 64bit Windows system and don't have 
32bit Java installed.  You need the i586 JRE if you have a 64bit Windows 
OS because Firefox is only 32bit.

You are going to have other problems though too.  Applets are very 
difficult to run anymore without code signing them.  You will need to 
use the Configure Java program to allow Applets to run.  If you want to 
run them from your local file system (and you have a Windows machine), 
add file:/ to the exceptions list.

If you are just learning Java, stick with applications.  They are much 
easier to deal with.

In any case, building a Swing GUI must be done on the Event Dispatch 
Thread (EDT).  To do that you need to use EventQueue.invokeLater() to 
wrap all your calls that create Swing GUI components.  Applet.init() is 
not running on the EDT.

Example;

public class MyApplet extends JApplet {
	public void init() {
		EventQueue.invokeLater(() -> {
			JTextArea area = new JTextArea("area");
			add(area);
		});
	}
}

So the above code does run but with all the discussed caveats.

knute...


On 9/15/2015 17:07, SpreadTooThin wrote:
> I tried writing a small applet that used swing.
> However when I try to run it in my browswer,  (firefox, chrome) I get a message saying
> "This plugin is not supported."
>
> It's a really simple swing listbox....
>
>
> // This is the html file
> <html>
> 	<head>
> 		<title>"my dpa class"</title>
> 	</head>
> 	<body>
> 		<applet code="dpa.class" widht="45" height="100"></applet>
> 	</body>
> </html>
>
> // This is the java file which i compiled into a class...
> import javax.swing.JApplet;
> import javax.swing.JTextArea;
>
> public class dpa extends JApplet {
>     @Override
>     public void init() {
> 	   JTextArea area = new JTextArea("Hello World");
> 	   this.add(area);
>     }
> }
>
> What have I done wrong?
> I looked for some security setting but maybe I'm missing something more fundamental.
>
>


-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Applets? SpreadTooThin <bjobrien62@gmail.com> - 2015-09-15 17:07 -0700
  Re: Applets? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-09-15 17:56 -0700
  Re: Applets? Jeff Higgins <jeff@invalid.invalid> - 2015-09-15 21:00 -0400
    Re: Applets? SpreadTooThin <bjobrien62@gmail.com> - 2015-09-16 07:21 -0700
      Re: Applets? e.d.programmer@gmail.com - 2015-09-16 07:28 -0700
      Re: Applets? Arne Vajhøj <arne@vajhoej.dk> - 2015-09-16 21:10 -0400
      Re: Applets? Arne Vajhøj <arne@vajhoej.dk> - 2015-09-16 21:16 -0400

csiph-web