-
my applet not run in browser
I already install plugin java, enable the browers for java(IE e netscape) but my applet not run.
Another applets already test run, mas my applet not...
I make mey applet in linux, I try run in linux and windows, but not run none.
Are there anything wrong in mey applet?
I don't have a function start() in my applet, need have?
file.java=
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.applet.Applet;
public class InterfaceApplet extends javax.swing.JApplet {
private String names[] = { "vm700t_2.jpg", "hp_8591c_2.jpg"};
private ImageIcon icone=new ImageIcon("bug.jpg");
private Icon icons[] =
{ new ImageIcon( names[ 0 ] ),
new ImageIcon( names[ 1 ] )};
public void init() {
initComponents();
setLocation(50,50);
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jBAdicionar = new javax.swing.JButton();
jCBEqpto = new javax.swing.JComboBox();
jLFigura = new javax.swing.JLabel();
jLEqpto = new javax.swing.JList();
jLCopy = new javax.swing.JList();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
getContentPane().setLayout(new java.awt.GridBagLayout());
jBAdicionar.setText("Adicionar >>");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 4);
getContentPane().add(jBAdicionar, gridBagConstraints);
jCBEqpto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "VM700T", "HP8591C" }));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 3;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 84, 26);
getContentPane().add(jCBEqpto, gridBagConstraints);
jLFigura.setText("teste");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 28, 0);
getContentPane().add(jLFigura, gridBagConstraints);
jLEqpto.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "VM700T", "HP8591C" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 2);
getContentPane().add(jLEqpto, gridBagConstraints);
jLCopy.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "teste" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 4;
gridBagConstraints.insets = new java.awt.Insets(0, 9, 0, 0);
getContentPane().add(jLCopy, gridBagConstraints);
jMenu1.setLabel("Arquivo");
jMenuItem1.setText("Novo");
jMenu1.add(jMenuItem1);
jMenuItem2.setText("Abrir");
jMenu1.add(jMenuItem2);
jMenuItem3.setText("Salvar");
jMenu1.add(jMenuItem3);
jMenuItem4.setText("Fechar");
jMenu1.add(jMenuItem4);
jMenuBar1.add(jMenu1);
setJMenuBar(jMenuBar1);
}
private javax.swing.JButton jBAdicionar;
private javax.swing.JComboBox jCBEqpto;
private javax.swing.JList jLCopy;
private javax.swing.JList jLEqpto;
private javax.swing.JLabel jLFigura;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
// End of variables declaration
}
-
You don't need the start() method unless there is something
specific you want to do when the user revisits your applet
page. The init method is called by the browser when he applet
has been loaded. If there is a start method in your applet then
that will be called by the browser after the init.
If the client revisits your applet page, then the browser doesn't
call the init method if your applet is still in the browsers memory
cache, it only calls the start method. So the start & stop
methods are basically intended for starting/stopping threads.
I see that you are using the new ImageIcon(<fileName>)
constructor. This is no good on the web, only on a local
machine. You must use the applet methods for getting the
images downloaded to the client.
Java Wreck
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks