Can anyone help me in finding error in this Java Applet program?

this is the program in connection with TextField, that asks consumer to key in his PRIMARY NAME, LAST NAME, TIME, COUNTRY and CNIC.but my program is not really displaying consequence,, don’t know why:(

might anyone explain to me that did when i miss any kind of function
This is the value

significance java.applet.Applet;
significance java.awt.*;
significance java.awt.celebration.*;
significance java.applet.*;
//import coffee.awt.TextField;

/**
*
* source AMNA
*/
open public class NewApplet offers Applet accessories ActionListener
TextField firstname, lastname, age1, region, cnic1;

/**
* Initialization method that should be called following your applet can be loaded
* in the browser.
*/

open public void init()
// TODO start off asynchronous download of major resources
Content label nameF=new Label(“FIRSTT NAME”, Content label.RIGHT); // TODO start off asynchronous download of major resources
Content label nameL=new Label(“LAST NAME”, Content label.CENTER);
Content label age=new Label(“AGE”, Content label.RIGHT); // TODO start off asynchronous download of major resources
Content label c=new Label(“COUNTRY”, Content label.CENTER);
Content label cnic=new Label(“CNIC”, Content label.CENTER);
firstname=new TextField(15);
firstname=new TextField(15);
age1=new TextField(15);
country=new TextField(15);
cnic1=new TextField(15);
add(nameF);
add(nameL);
add(age);
add(c);
add(cnic);
firstname.addActionListener( this);
lastname.addActionListener( this);
age1.addActionListener( this);
region.addActionListener( this);
cnic1.addActionListener( this);

open public void actionPerformed(ActionEvent e)
repaint();

open public void paint(Graphics g)

gary.drawString(“FiRST APPOINT:”+firstname.getText(), NINE, 9);
gary.drawString(” Picked NAME:”+firstname.getSelectedText(), NINETY DAYS, 19);

gary.drawString(“LAST APPOINT:”+lastname.getText(), NINE, 39);
gary.drawString(“Selected text in name:”+lastname.getSelectedText(), HALF A DOZEN, 20);
gary.drawString(“AGE:”+age1.getText(), NINE, 49);
gary.drawString(“COUNTRY:”+country.getText(), NINE, 59);
gary.drawString(“CNIC:”+cnic1.getText(), NINE, 69);

That computer code had several problems, as well as:
– Mixing custom made painting with added components.
– Mis-spelling one of several field names
– (Creating but) definitely not adding this fields.

This is an altered version on the code, seen to figure (it least basically) the following.

//
significance java.applet.Applet;
significance java.awt.*;
significance java.awt.celebration.*;

open public class NewApplet offers Applet accessories ActionListener

TextField firstname, lastname, time, country, cnic;
OutputPanel outputPanel;

/** Initialization method that should be named.*/
open public void init()
firstname=new TextField(15);
lastname=new TextField(15);
age=new TextField(15);
country=new TextField(15);
cnic=new TextField(15);

add( brand new Label(“FIRSTT NAME”, Content label.RIGHT) );
add(firstname);
add(new Label(“LAST NAME”, Content label.CENTER));
add(lastname);
add(new Label(“AGE”, Content label.RIGHT));
add(age);
add(new Label(“COUNTRY”, Content label.CENTER));
add(country);
add(new Label(“CNIC”, Content label.CENTER));
add(cnic);

firstname.addActionListener( this);
lastname.addActionListener( this);
time.addActionListener( this);
region.addActionListener( this);
cnic.addActionListener( this);

outputPanel = brand new OutputPanel();
outputPanel.setPreferredSize(new Dimension(500, 100));
add(outputPanel);

validate();

open public void actionPerformed(ActionEvent e)
outputPanel.repaint();

training OutputPanel provides Panel

open public void paint(Graphics g)

gary.drawString(“FiRST APPOINT:”+firstname.getText(), NINE, 9);
gary.drawString(” Picked NAME:”+firstname.getSelectedText(), NINETY DAYS, 19);

gary.drawString(“LAST APPOINT:”+lastname.getText(), NINE, 39);
gary.drawString(“Selected text in name:”+lastname.getSelectedText(), HALF A DOZEN, 20);
gary.drawString(“AGE:”+age.getText(), NINE, 49);
gary.drawString(“COUNTRY:”+country.getText(), NINE, 59);
gary.drawString(“CNIC:”+cnic.getText(), NINE, 69);

Shouldn’t an individual add this textboxes too i.age.add.(firstname) inside the init function

you have to add your textboxes in the init() procedure ans established their default benefit also.

Leave a Reply