Meaningless Drivel is fun!*
The moose likes Applets and the fly likes Applet doesn't show up with IE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet doesn Watch "Applet doesn New topic
Author

Applet doesn't show up with IE

Sathya Jith
Greenhorn

Joined: Dec 02, 2000
Posts: 14
I have written an Applet which opens in appletviewer but doesn't
open with a browser. I tried with IE5.5
Kindly help
The code is here :

import javax.swing.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet code = "Applicant.class" height = 300 width =500>
</applet>
*/
public class Applicant extends JApplet
{
//variabels for labels
JPanel panel;

//varaibles for labels
JLabel nc;
JLabel labelAppName;
JLabel labelAppAddress;
JLabel labelAppPosition;
JButton buttonAccept;

//variabels for data entry controls
JTextField nct;
JTextField textAppName;
JTextField textAppAddress;
JComboBox comboAppPosition;
//variables for the layout

GridBagLayout gl;
GridBagConstraints gbc;
public void init()
{
//initialise the layout variables
gl= new GridBagLayout();
gbc= new GridBagConstraints();
panel = (JPanel)getContentPane();
panel.setLayout(gl);

//initialise label controls
nc =new JLabel("Number of copies");
labelAppName= new JLabel("Name");
labelAppAddress= new JLabel("Address");
labelAppPosition = new JLabel("Country");
buttonAccept = new JButton("Order");

//initialize data entry controls
nct = new JTextField(5);
textAppName = new JTextField(30);
textAppAddress = new JTextField(30);
String positions[]={"India","US","Other"};
comboAppPosition= new JComboBox(positions);


//Add the Button
gbc.anchor = GridBagConstraints.NORTHEAST;
gbc.gridx = 8;
gbc.gridy = 11;
gl.setConstraints(buttonAccept,gbc);
panel.add(buttonAccept);
validateAction validateButton = new validateAction();
buttonAccept.addActionListener(validateButton);

//Add controls for Applicant Id
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx= 1;
gbc.gridy= 1;
gbc.gridwidth=2;
gl.setConstraints(nc,gbc);
panel.add(nc);

gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx= 3;
gbc.gridy= 1;
gbc.gridwidth=1;
gl.setConstraints(nct,gbc);
panel.add(nct);
//Add controls for Applicant Name
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx= 1;
gbc.gridy= 3;
gbc.gridwidth=2;
gl.setConstraints(labelAppName,gbc);
panel.add(labelAppName);

gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx= 3;
gbc.gridy= 3;
gbc.gridwidth=2;
gl.setConstraints(textAppName,gbc);
panel.add(textAppName);
//Add controls for Applicant Address
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx= 1;
gbc.gridy= 5;
gbc.gridwidth=2;
gl.setConstraints(labelAppAddress,gbc);
panel.add(labelAppAddress);

gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx=3;
gbc.gridy= 5;
gbc.gridwidth=4;
gl.setConstraints(textAppAddress,gbc);
panel.add(textAppAddress);

//Add controls for Applicant Position
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx= 1;
gbc.gridy= 7;
gbc.gridwidth=2;
gl.setConstraints(labelAppPosition,gbc);
panel.add(labelAppPosition);

gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx= 3;
gbc.gridy= 7;
gbc.gridwidth=2;
gl.setConstraints(comboAppPosition,gbc);
panel.add(comboAppPosition);


}
class validateAction implements ActionListener
{


public void actionPerformed(ActionEvent evt)
{
//extracting source of action
Object obj = evt.getSource();
if(obj == buttonAccept)
{
//Retrieving the number of copies from the textBox
String ncb = nct.getText();

//checking whether the user has entered the value
if(ncb.length() == 0)
{
//displ the error message on tyhe status bar
getAppletContext().showStatus("Please mention the number of copies");
return;
}

//Retrieving the Applicant Name from the textBox
String applicantName = textAppName.getText();

//checking whether the user has entered the value
if(applicantName.length() == 0)
{
//displ the error message on tyhe status bar
getAppletContext().showStatus("Name should be entered");
return;
}
//Retrieving the Applicant Address from the textBox
String applicantAddress = textAppAddress.getText();

//checking whether the user has entered the value
if(applicantAddress.length() == 0)
{
//displ the error message on tyhe status bar
getAppletContext().showStatus("Adress is required");
return;

}
getAppletContext().showStatus("Thank you for ordering the Bilingual Master");

}
}


}

}
------------------
Sathyajith


Sathyajith
Noah Carroll
Ranch Hand

Joined: Sep 20, 2000
Posts: 96
The reason that it will not display in Internet Explorer is because IE5.5 does not support Java 2. These applets must run using a plug-in or active x control. The applets request this be used by using special object or embed tags not applet tags. You can download a program that will modify your html documents putting in the correct tags (Java 2 Application). You can get it here
http://java.sun.com/products/plugin/1.3/features.html
------------------
I hope its helps, feel free to email me noahcarroll@juno.com
Sathya Jith
Greenhorn

Joined: Dec 02, 2000
Posts: 14
Thank you Noah Carroll.

------------------
Sathyajith
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Applet doesn't show up with IE
 
Similar Threads
Creating and opening a window if the button is clicked in an applet
code can't work
Applets
JDBC ODBC Concetivity
Parent and Child JDialogs