R
RCS
I am having trouble viewing my results. My JAVA code below compiles,
but when I write out my HTML file and generate appletviewer, I am
getting a window that is blank but I receive a message at the bottom
of the blank applet saying:
Start:applet not initialized
HTML code:
<HTML>
<BODY>
<P>
<APPLET CODE = "HelloWorld.class" width="200" height="200">
<PARAM NAME = CODE VALUE = "JButtons4.class">
<PARAM NAME = CODEBASE VALUE = "applets">
<PARAM NAME ="type" Value = "application/x-java-applet;version=1.4.2">
</APPLET>
</P>
</BODY>
</HTML>
Java code:
import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class JButtons4 extends JFrame{
private JButton phonekeys[];
private String KEYS[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"*", "0", "+"};
private int counter = 0;
private String numbers[];
private int i;
private JLabel label;
private JPanel content;
private JPanel content3;
public static void main(String[] args)
{
new JButtons();
}
public void init()
{
JPanel content = new JPanel();
JPanel content2 = new JPanel();
Container content3 = getContentPane();
label = new JLabel();
phonekeys = new JButton[ KEYS.length ];
content2.setLayout( new GridLayout(4, 3) );
ButtonHandler handler = new ButtonHandler();
for( int i = 0 ; i < 12 ; i++ )
{
phonekeys = new JButton( KEYS );
content2.add( phonekeys );
phonekeys.addActionListener( handler );
}
content3.add(content2, BorderLayout.SOUTH);
content3.add(content, BorderLayout.NORTH);
pack();
setVisible(true);
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
for( i = 0; i < phonekeys.length; i++ )
{
if( e.getSource() == phonekeys )
{
label.setText( KEYS );
content.add(label);
break;
}
}
}
}
}
but when I write out my HTML file and generate appletviewer, I am
getting a window that is blank but I receive a message at the bottom
of the blank applet saying:
Start:applet not initialized
HTML code:
<HTML>
<BODY>
<P>
<APPLET CODE = "HelloWorld.class" width="200" height="200">
<PARAM NAME = CODE VALUE = "JButtons4.class">
<PARAM NAME = CODEBASE VALUE = "applets">
<PARAM NAME ="type" Value = "application/x-java-applet;version=1.4.2">
</APPLET>
</P>
</BODY>
</HTML>
Java code:
import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class JButtons4 extends JFrame{
private JButton phonekeys[];
private String KEYS[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"*", "0", "+"};
private int counter = 0;
private String numbers[];
private int i;
private JLabel label;
private JPanel content;
private JPanel content3;
public static void main(String[] args)
{
new JButtons();
}
public void init()
{
JPanel content = new JPanel();
JPanel content2 = new JPanel();
Container content3 = getContentPane();
label = new JLabel();
phonekeys = new JButton[ KEYS.length ];
content2.setLayout( new GridLayout(4, 3) );
ButtonHandler handler = new ButtonHandler();
for( int i = 0 ; i < 12 ; i++ )
{
phonekeys = new JButton( KEYS );
content2.add( phonekeys );
phonekeys.addActionListener( handler );
}
content3.add(content2, BorderLayout.SOUTH);
content3.add(content, BorderLayout.NORTH);
pack();
setVisible(true);
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
for( i = 0; i < phonekeys.length; i++ )
{
if( e.getSource() == phonekeys )
{
label.setText( KEYS );
content.add(label);
break;
}
}
}
}
}