• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Applet doesn't show up with IE

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 [email protected]
 
Sathya Jith
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Noah Carroll.

------------------
Sathyajith
 
reply
    Bookmark Topic Watch Topic
  • New Topic