|
-
Dec 6th, 2007, 03:29 PM
#1
Thread Starter
Member
Applet problem
Hi everyone
I run this program using netBeans it ok but, I tried to use internet explorer it does not show the interface despite there is an HTML file created by neatBeans. Could please anyone tell what is wrong. Thanks
Code:
package project;
import java.awt.Color;
import javax.swing.JOptionPane;
public class AddCustomerApplet extends javax.swing.JApplet {
Customer aCustomer;
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
Customer.initialize();
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void addCustomer()
{
String doorNumber = door_numberText.getText();
String streetName= street_nameText.getText();
String postCode = post_codeText.getText();
String phoneNumber = phone_numberText.getText();
if (doorNumber.length() == 0 || streetName.length() == 0 || postCode.length() == 0 || phoneNumber.length() == 0)
JOptionPane.showMessageDialog(this," Please Enter all data ");
else
{
aCustomer = new Customer(doorNumber,streetName,postCode,phoneNumber);
try //add New to Customer
{
aCustomer.addNew();
JOptionPane.showMessageDialog(this,"Customer added");
clearForm();
}
catch (DuplicateException e)
{
JOptionPane.showMessageDialog(this, e.toString());
}
}
}
private void clearForm()
{
door_numberText.setText(" ");
street_nameText.setText(" ");
post_codeText.setText(" ");
phone_numberText.setText(" ");
}
public void shutDown()
{
Customer.terminate();
}
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
street_nameText = new javax.swing.JTextField();
post_codeText = new javax.swing.JTextField();
phone_numberText = new javax.swing.JTextField();
order = new javax.swing.JButton();
clear = new javax.swing.JButton();
door_numberText = new javax.swing.JTextField();
setEnabled(false);
jLabel1.setText("Door Number");
jLabel2.setText("Strrt Name");
jLabel3.setText("Post Code");
jLabel4.setText("Phone Number");
order.setText("AddCustomer");
order.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
orderActionPerformed(evt);
}
});
clear.setText("Clear ");
clear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
clearActionPerformed(evt);
}
});
door_numberText.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
door_numberTextActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(28, 28, 28))
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(10, 10, 10)))
.addGap(27, 27, 27))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(door_numberText, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(order, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(5, 5, 5)
.addComponent(clear, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE))
.addComponent(post_codeText, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
.addComponent(street_nameText, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
.addComponent(phone_numberText, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE))
.addGap(57, 57, 57))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(door_numberText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(17, 17, 17)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(17, 17, 17)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(post_codeText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(17, 17, 17)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(phone_numberText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(street_nameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(59, 59, 59)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(order, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(clear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(63, 63, 63))
);
}// </editor-fold>
private void orderActionPerformed(java.awt.event.ActionEvent evt) {
addCustomer();
clearForm();
// TODO add your handling code here:
}
private void clearActionPerformed(java.awt.event.ActionEvent evt) {
clearForm();
// TODO add your handling code here:
}
private void door_numberTextActionPerformed(java.awt.event.ActionEvent evt) {
}
private javax.swing.JButton clear;
private javax.swing.JTextField door_numberText;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JButton order;
private javax.swing.JTextField phone_numberText;
private javax.swing.JTextField post_codeText;
private javax.swing.JTextField street_nameText;
// End of variables declaration
}
-
Dec 6th, 2007, 06:31 PM
#2
Re: Applet problem
If it runs in the Applet viewer it should be displayed in a web browser.
I guess netbeans is using the old <Applet> tag which causes compatibility issues in IE, FF,... you better check your IE settings to make sure Java is enabled and check the Java settings to make sure the applets are enabled then check the html page if it's in the acceptable format
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Dec 6th, 2007, 08:21 PM
#3
Thread Starter
Member
Re: Applet problem
Hi thank you for reply
the IE setting ok but I am not sure about java setting because no idea how to check java for applet could tell me please how to do it? about the HTML I think it is ok to be sure here is the HTML code for the applet programm
HTML Code:
<HTML>
<HEAD>
<TITLE>Applet HTML Page</TITLE>
</HEAD>
<BODY>
<!--
*** GENERATED applet HTML launcher - DO NOT EDIT IN 'BUILD' FOLDER ***
If you need to modify this HTML launcher file (e.g., to add applet parameters),
copy it to where your applet class is found in the SRC folder. If you do this,
the IDE will use it when you run or debug the applet.
Tip: To exclude an HTML launcher from the JAR file, use exclusion filters in
the Packaging page in the Project Properties dialog.
For more information see the online help.
-->
<H3><HR WIDTH="100%">Applet HTML Page<HR WIDTH="100%"></H3>
<P>
<APPLET codebase="classes" code="project/AddCustomerApplet.class" width=350 height=200></APPLET>
</P>
<HR WIDTH="100%"><FONT SIZE=-1><I>Generated by NetBeans IDE</I></FONT>
</BODY>
</HTML>
-
Dec 6th, 2007, 08:34 PM
#4
Re: Applet problem
As I said, the Applet tag is deprecated and you shouldn't be using it. Instead take a look at what sun has to say about this
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|