• Post Reply Bookmark Topic Watch Topic
  • New Topic

What wrong in code!!!

 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
This following is very simple code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class TLabel extends JApplet{
public void init()
{
Container contentPane = getContentPane();
JLabel label = new JLabel("This is Swing Applet",JLabel.CENTER);
contentPane.add(label);
}
}
No problem in compilation? But I can't see anything when i run in Browser.When I have windows 98, it was running.Now I have windows 2000,it is not running.So the problem is regarding platform or Browser or in my code or HTML file!!!
I have to use appletviewer(if yes,please give me syntax) or HTML?
Please let me know,
Thanks
Angela
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angela, have you checked for the java plugin? Go to your control panel and open the JavaPlugin. Check the box that says "Enable Java plug-in" and reboot. If you don't have this plug in, you can download it from java.sun.com. If you already have this and it is already enabled, then please post your HTML.
Bodie
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bodie,
I tried in control panel.Its Enabled.But still I can't see anything in Browser

Please let me know,
Thanks
Angela
Originally posted by Angela Jessi:
Hi all,
This following is very simple code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class TLabel extends JApplet{
public void init()
{
Container contentPane = getContentPane();
JLabel label = new JLabel("This is Swing Applet",JLabel.CENTER);
contentPane.add(label);
}
}
No problem in compilation? But I can't see anything when i run in Browser.When I have windows 98, it was running.Now I have windows 2000,it is not running.So the problem is regarding platform or Browser or in my code or HTML file!!!
I have to use appletviewer(if yes,please give me syntax) or HTML?
Please let me know,
Thanks
Angela

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post the HTML?
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bodie
I appreciate your response.
I wrote this HTML and open it in Browser
<HTML>
<HEAD>
<TITLE>Key Event JApplet one</TITLE>
<APPLET code="TLabel" HEIGHT=200 WIDTH=200>
</APPLET>
</HEAD>
</HTML>
Please let me know b'coz still I can't see anything in Browser?
Regds
Angela
[This message has been edited by Bodie Minster (edited December 01, 2000).]
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Angela Jessi:
Hi Bodie
I appreciate your response.
I wrote TLabel.HTML and open it in Browser. And I am getting following.
<HTML>
<HEAD>
<TITLE>Key Event JApplet one</TITLE>
<APPLET code="TLabel" HEIGHT=200 WIDTH=200>
</APPLET>
</HEAD>
</HTML>

Please let me know b'coz still I can't see anything in Browser?
Regds
Angela

 
Brent Worden
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your applet tag should be something like this:
<applet codebase="." code="TLabel.class" width="460" height="160">
</applet>
That is provided, your TLabel.class file is in the same directory as your HTML file. If not, change the codebase attribute
------------------
Brent Worden
http://www.Brent.Worden.org/
[This message has been edited by Bodie Minster (edited December 01, 2000).]
[This message has been edited by Brent Worden (edited December 01, 2000).]
 
Noah Carroll
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angela, when you make an applet using JApplet, it is the swing version. Browsers do not support swing, so you must have a plugin installed and you must call the object using an object tag, not an applet tag. If you have the html converter use it, if not the code can be found on the java.sun.com web site.
------------------
I hope its helps, feel free to email me noahcarroll@juno.com
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Noah Carroll,
I really appreciate your help.
I have Java Plugin installed.I don't know how to use object tag instead of applet tag. and Also whatis HTML converter & how I can download and use it.(If you can explain how to use Object tag by example please!)
Thanks again,
Angela

 
Noah Carroll
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angela,
Like I mentioned before, Java 2 is not supported by the available web browsers(although, netscape 6 will soon). Because this java support is not built into the browser users that want to be able to view Java 2 applets inside their browser must download a Java Runtime Environment that supports Java 2. It is run as an active-x control in microsoft internet explorer and a plug-in in netscape. However, once this is installed it does not auotmatically work with the ordinary applet tag. Internet explorer has an object tag that when used with certain numbers will call the java runtime environment. Unfortunately, netscape does not recognize the object tag, but they do recognize the embed tag(which ie does not support). When a browser finds a tag does not know it simply ignores it, and everything in between. The HTML converter makes up a somewhat complex block of html code that you must use in place of this applet tag. When the browsers find this code they know what to ignore and what to run. Java 2 applets is what they end up running. I hope I didn't confuse you, but it is actually quite an easy thing to accomplish.
The HTML converter can be downloaded at http://java.sun.com/products/plugin/1.3/features.html
------------------
I hope its helps, feel free to email me noahcarroll@juno.com
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Noah Carroll
thanks a lot!!!
regds,angela

Originally posted by Noah Carroll:
Angela,
Like I mentioned before, Java 2 is not supported by the available web browsers(although, netscape 6 will soon). Because this java support is not built into the browser users that want to be able to view Java 2 applets inside their browser must download a Java Runtime Environment that supports Java 2. It is run as an active-x control in microsoft internet explorer and a plug-in in netscape. However, once this is installed it does not auotmatically work with the ordinary applet tag. Internet explorer has an object tag that when used with certain numbers will call the java runtime environment. Unfortunately, netscape does not recognize the object tag, but they do recognize the embed tag(which ie does not support). When a browser finds a tag does not know it simply ignores it, and everything in between. The HTML converter makes up a somewhat complex block of html code that you must use in place of this applet tag. When the browsers find this code they know what to ignore and what to run. Java 2 applets is what they end up running. I hope I didn't confuse you, but it is actually quite an easy thing to accomplish.
The HTML converter can be downloaded at http://java.sun.com/products/plugin/1.3/features.html

 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Well there is no such association with Netscape and IE as far u r code is concerned.. well lemme see. yeah! Applet tag is not recognised by Netscape.. but object is.. well although u have the plug in the code doesnt work.. well I trid running it but it gave me a javax.swing.JApplet classNotFoundException. I dunno why.. but lemme work on it and let u know.. I WILL solve the puzzle for sure..
Please be patient
Regds
Gautham Kasinath
 
chak ms
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Gautam
U said that u've got error like ClassNotFoundException. U should check your class path. I think u didn't mention the location of ur swing classes in the class path. I hope this might help you.
with regards
chak
Originally posted by gautham kasinath:
Hi! Well there is no such association with Netscape and IE as far u r code is concerned.. well lemme see. yeah! Applet tag is not recognised by Netscape.. but object is.. well although u have the plug in the code doesnt work.. well I trid running it but it gave me a javax.swing.JApplet classNotFoundException. I dunno why.. but lemme work on it and let u know.. I WILL solve the puzzle for sure..
Please be patient
Regds
Gautham Kasinath

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!