Please can you help. We've set defaults to a class employee & added data for each of the input form values 'age', 'dob', 'street' etc now we are asked to print void display for the values we have added . Have tried setText=P[0].age but this is not recognised, what is the syntax please to display the data we have read in onto the screen? All clues gratefully recieved
4 3679
Please can you help. We've set defaults to a class employee & added data for each of the input form values 'age', 'dob', 'street' etc now we are asked to print void display for the values we have added . Have tried setText=P[0].age but this is not recognised, what is the syntax please to display the data we have read in onto the screen? All clues gratefully recieved
don't think we have sufficent information - can you post the code where the problem is?
-
import java.awt.*;
-
import java.awt.event.*;
-
import java.io.*;
-
class FormDemo extends CloseableFrame implements ActionListener, ItemListener
-
{
-
private FileOutputStream outStream;
-
private PrintWriter outFile;
-
public boolean storeOpen;
-
public boolean fileOpen;
-
public boolean fileSaved;
-
Button closeButton, saveButton;
-
private MenuBar mb = new MenuBar();
-
private Menu menu1 = new Menu("File");
-
private Menu menu2 = new Menu("Record");
-
private MenuItem File,Record,New,Save,ReadIn,Add,Display,Clear;
-
TextField id,Start,Gender,Address,NatInsceNo,PhoneNo, Firstname,Surname,title,Dob,Age, number, street, city, postCode;
-
//Store[] myStore;
-
Employee[] P;
-
Employee P1;
-
int counter;
-
-
public FormDemo(String fname) throws IOException
-
{
-
outStream = new FileOutputStream(fname);
-
outFile = new PrintWriter(outStream);
-
setTitle("Input Form");
-
setLayout(new BorderLayout());
-
setSize(545,450);
-
Panel top = new Panel(new FlowLayout(FlowLayout.CENTER));
-
top.add(new Label("Applicant Details"));
-
add("North",top);
-
-
Panel mid = new Panel(new FlowLayout(FlowLayout.LEFT));
-
mid.add(new Label ("id"));
-
id = new TextField("",5);
-
mid.add(id);
-
mid.add(new Label ("Start"));
-
Start = new TextField("",5);
-
mid.add(Start);
-
-
mid.add(new Label ("Surname"));
-
Surname = new TextField("",5);
-
mid.add(Surname);
-
mid.add(new Label ("Firstname"));
-
Firstname = new TextField("",15);
-
mid.add(Firstname);
-
mid.add(new Label ("Age"));
-
Age = new TextField("",5);
-
mid.add(Age);
-
mid.add(new Label ("Gender"));
-
Gender = new TextField("",5);
-
mid.add(Gender);
-
mid.add(new Label("Dob"));
-
Dob = new TextField("",5);
-
mid.add(Dob);
-
mid.add(new Label ("Address"));
-
Address = new TextField("",5);
-
mid.add(Address);
-
mid.add(new Label ("NatInsceNo"));
-
NatInsceNo = new TextField("",5);
-
mid.add(NatInsceNo);
-
mid.add(new Label ("PhoneNo"));
-
PhoneNo = new TextField("",5);
-
mid.add(PhoneNo);
-
addMenu();
-
add("Center",mid);
-
-
Panel lower = new Panel(new GridLayout (2,3));
-
closeButton = new Button("close");
-
saveButton = new Button("save");
-
saveButton.addActionListener(this);
-
lower.add(saveButton);
-
closeButton.addActionListener(this);
-
lower.add(closeButton);
-
add("South",lower);
-
setVisible(true);
-
}
-
-
public void actionPerformed (ActionEvent e)
-
{
-
if (e.getSource() == closeButton)
-
{
-
outFile.close();
-
System.exit(0);
-
}
-
if (e.getSource() == Save)
-
{
-
fileOut();
-
}
-
if(e.getSource()==Clear)
-
{
-
Storeit();
-
}
-
}
-
public void Storeit()
-
{
-
if(!storeOpen && !fileSaved)
-
{
-
P = new Employee[100];
-
storeOpen = true;
-
fileSaved = true;
-
counter=0;
-
}
-
}
-
private void clear()
-
{
-
Surname.setText("");
-
Firstname.setText("");
-
Age.setText("");
-
Gender.setText("");
-
Dob.setText("");
-
Address.setText("");
-
NatInsceNo.setText("");
-
PhoneNo.setText("");
-
}
-
-
private void add()
-
{
-
if(storeOpen)
-
{
-
P1 =new Employee();
-
id.getText( );
-
Dob.getText();
-
Start.getText();
-
fileSaved =false;
-
P[counter]=P1;
-
counter++;
-
}
-
}
-
private void display()
-
{
-
displayText.setText();
-
text() = P[0].Start;
-
}
-
public void itemStateChanged (ItemEvent e)
-
{
-
-
}
-
-
public void fileOut()
-
{
-
-
outFile.println(number.getText()+" " + street.getText());
-
outFile.println(city.getText());
-
outFile.println(postCode.getText());
-
-
-
}
-
private void addMenu()
-
{
-
// creates each menu item with appropriate label
-
-
New = new MenuItem("New");
-
Save = new MenuItem("Save");
-
ReadIn = new MenuItem("Readin");
-
Add = new MenuItem("Add");
-
Display = new MenuItem("Display");
-
Clear = new MenuItem("Clear");
-
-
// adds each item to menu1
-
-
menu1.add(New);
-
menu1.add(Save);
-
menu1.add(ReadIn);
-
menu2.add(Add);
-
menu2.add(Display);
-
menu2.add(Clear);
-
//adds menu1 and menu2 to menu bar and adds menu bar to frame
-
-
mb.add(menu1);
-
mb.add (menu2);
-
setMenuBar(mb);
-
-
// sets upp actionlistener for each menu item
-
-
New.addActionListener(this);
-
Save.addActionListener(this);
-
ReadIn.addActionListener(this);
-
Add.addActionListener(this);
-
Display.addActionListener(this);
-
Clear.addActionListener(this);
-
-
}
-
}
-
The code seems to work up until private void display then it says it doesnt recognise the syntax getText to return the info we would have added to the
form. Could you help with this please.....the rest is OK. thANKS....
is displayText a TextArea? if so you use method append() to add a String to it
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/TextArea.html
Please can you help. We've set defaults to a class employee & added data for each of the input form values 'age', 'dob', 'street' etc now we are asked to print void display for the values we have added . Have tried setText=P[0].age but this is not recognised, what is the syntax please to display the data we have read in onto the screen? All clues gratefully recieved
setText takes a String as an argument. You have
which takes nothing so that wont work.
Where didi you define displayText? It has to be a some component for that to work?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: joes |
last post by:
Hello there !
I rendering a PDF with XSLT using Xalan and FOP.
I like to place in my article an image, so that the text is floating
around the image. I tried several things but it didn't work so...
|
by: Xerxes |
last post by:
Hi,
I need help in setting up a page where the text wraps around an image.
Right now, I am using table, with text in one <td> and the image in the
adjacent <td>. The problem is when the text is...
|
by: Macsicarr |
last post by:
Hi All
Wonder if you could help me.
I have created a CMS system that allows the user to enter text and pic
'tags' for their own About us page, eg
text.... text.... text.... text.......
|
by: Jiri Palecek |
last post by:
I have a question on web authoring (probably HTML+CSS). Is it
somehow possible to put two words above each other inside a paragraph
so the result would be valid and render at least in Mozilla?
I...
|
by: Arif Çimen |
last post by:
Hi to everybody,
I have chnged a button text in design mode. But After compiling and
executing the program
the text of the button do not change to new value.
Any Ideas?
Thaks for helps.
|
by: jweinberg1975 |
last post by:
I would like for users to be able to select from a small number of options
that come from a little drop down menu which then closes.
.....
|
by: bbepristis |
last post by:
Hey all I have this code that reads from one text file writes to
another unless im on a certian line then it writes the new data however
it only seems to do about 40 lines then quits and I cant...
|
by: acecraig100 |
last post by:
I am fairly new to Javascript. I have a form that users fill out to
enter an animal to exhibit at a fair. Because we have no way of
knowing, how many animals a user may enter, I created a table...
|
by: jonniethecodeprince |
last post by:
Hi all,
I have trouble getting an array of data stored in a separate javascript file i.e. a file called books.js into a table of data for a .xhtml file.
There are 50 Records in this file....
|
by: bluemountain |
last post by:
Hi there,
Iam new to python forms and programming too
I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |