Hi,
I have asked a similar question before but I still need more ideas.
I am working on my final year project and I am using
Java.
I want to be able to access an
applet on the click of a button using Java. Is that possible and if it is, how can it be done.
Can somebody give me an example, I would appreciate it very much because it would probably help me a lot.
In case you need to see my code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Applet1 extends JApplet implements
ActionListener
{
JLabel labelId, labelName, labelSurname;
JTextField txtId, txtName, txtSurname;
JButton btOK;
GridBagConstraints gbc;
GridBagLayout gbl;
JPanel panel;
public void init()
{
labelId = new JLabel("Employee ID:");
txtId = new JTextField(5);
labelName = new JLabel("Name:");
txtName = new JTextField(15);
labelSurname = new JLabel("Surname");
txtSurname = new JTextField(15);
btOK = new JButton(" OK ");
gbc= new GridBagConstraints();
gbl = new GridBagLayout();
panel = (JPanel)getContentPane();
panel.setLayout(gbl);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 2;
gbl.setConstraints(labelId, gbc);
panel.add(labelId);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 4;
gbc.gridy = 2;
gbl.setConstraints(txtId, gbc);
panel.add(txtId);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 4;
gbl.setConstraints(labelName, gbc);
panel.add(labelName);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 4;
gbc.gridy = 4;
gbl.setConstraints(txtName, gbc);
panel.add(txtName);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 6;
gbl.setConstraints(labelSurname, gbc);
panel.add(labelSurname);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 4;
gbc.gridy = 6;
gbl.setConstraints(txtSurname, gbc);
panel.add(txtSurname);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridy = 3;
gbc.gridy = 8;
gbl.setConstraints(btOK, gbc);
panel.add(btOK);
}
public void actionPerformed(ActionEvent e)
{
//This is where the code that brings up the other
//applet should come
}
}
Please format my code.
[ February 19, 2002: Message edited by: Patrick Mugabe ]
[ February 19, 2002: Message edited by: Patrick Mugabe ]