Discussion:
Why applet doesn't work?
(too old to reply)
Davisote
2005-03-22 23:52:52 UTC
Permalink
Hi.
I've created a project which include one single file called
ClientCenter.java. It's the applet wich create by default JBuilder 8. I
added a simple menu bar and when I try to see it, no way.

Why doesn't work.??
Any suggestions?
Thanks
Lori M Olson [TeamB]
2005-03-23 04:39:28 UTC
Permalink
Post by Davisote
Hi.
I've created a project which include one single file called
ClientCenter.java. It's the applet wich create by default JBuilder 8. I
added a simple menu bar and when I try to see it, no way.
Why doesn't work.??
Any suggestions?
Thanks
If it's that simple, then post the code, so we can see what might be
wrong. Also... you should be posting such quesitons in :

news://borland.public.jbuilder.applet-issues
--
Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Davisote
2005-03-23 18:10:03 UTC
Permalink
Hi.
Here is the code because news://borland.public.jbuilder.applet-issues seems
doesn't work
package myproject;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class myApplet extends Applet {
private boolean isStandalone = false;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JMenu jMenu2 = new JMenu();
//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 myApplet() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jMenu1.setText("File");
jMenu2.setText("About");
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}

Thanks
Post by Lori M Olson [TeamB]
Post by Davisote
Hi.
I've created a project which include one single file called
ClientCenter.java. It's the applet wich create by default JBuilder 8. I
added a simple menu bar and when I try to see it, no way.
Why doesn't work.??
Any suggestions?
Thanks
If it's that simple, then post the code, so we can see what might be
news://borland.public.jbuilder.applet-issues
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
http://www.borland.com/newsgroups/ngsearch.html
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Paul Nichols (TeamB)
2005-03-23 23:43:14 UTC
Permalink
Two mistakes in your code:
(1) Do not mix java.awt.Applet with Swing controls (see notes in code)
(2) You are not adding the JMenuBar to the Applet itself (see notes in
code)
Post by Davisote
package myproject;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
*/
public class myApplet extends Applet { //should be extending JApplet if
you want to use
//JMenuBar
Post by Davisote
private boolean isStandalone = false;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JMenu jMenu2 = new JMenu();
//Get a parameter value
public String getParameter(String key, String def) {
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public myApplet() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jMenu1.setText("File");
jMenu2.setText("About");
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
/ ** Add this line below:
this.getContentPane().add(jMenuBar1,BorderLayout.NORTH);
Post by Davisote
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}
Davisote
2005-03-24 00:38:16 UTC
Permalink
Thanks a lot.
Works great.
Sorry for posting in the wrong group.
Thanks
Post by Paul Nichols (TeamB)
(1) Do not mix java.awt.Applet with Swing controls (see notes in code)
(2) You are not adding the JMenuBar to the Applet itself (see notes in
code)
Post by Davisote
package myproject;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
*/
public class myApplet extends Applet { //should be extending JApplet if
you want to use
//JMenuBar
Post by Davisote
private boolean isStandalone = false;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JMenu jMenu2 = new JMenu();
//Get a parameter value
public String getParameter(String key, String def) {
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public myApplet() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jMenu1.setText("File");
jMenu2.setText("About");
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
this.getContentPane().add(jMenuBar1,BorderLayout.NORTH);
Post by Davisote
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}
Loading...