FileDocCategorySizeDatePackage
HelpDesk.javaAPI DocExample2189Wed Oct 17 18:38:18 BST 2001None

HelpDesk

public class HelpDesk extends Applet implements ActionListener

Fields Summary
Button
b1
Button
b2
Button
b3
Button
b4
String
work
TextField
intext
TextField
outext
TextArea
space
Vector
v1
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent ae)

	if (ae.getSource()==b1)
		{
		work = (String)intext.getText();
		intext.setText("");
		addToVector();
		}
	if (ae.getSource()==b2)
		{
		work = (String)outext.getText();
		 if (findString())
		 	outext.setText("Job removed");
		 else 
		 	outext.setText("Job not found");
		
		}
	if (ae.getSource()==b3)
		listJobs();
	if (ae.getSource()==b4)
		{
		v1.clear();
		//space.setText("");
		}
public voidaddToVector()

	v1.addElement(work);
public booleanfindString()

boolean b=false;
if (!(v1.isEmpty()))

	{ 
		for (int i=0; i<v1.size(); i++)
			{
				if (work.equals((String)v1.elementAt(i)))
				{
					b = true;
					v1.remove(i);
				} // endif
			} // end for
	} //endif
	return b;
public voidgetFromVector()

	if (!(v1.isEmpty()))
		{
			work=(String) v1.firstElement();
			v1.remove(0);
		}
	else
		work="No Jobs";
public voidinit()

	b1 = new Button ("Enter Job");
	b2 = new Button ("Completed Job");
	b3 = new Button("List Jobs");
	b4 = new Button("Clear All Jobs");
	intext = new TextField(10);
	outext = new TextField(10);
	space = new TextArea(10,40);
	v1 = new Vector ();
	b1.addActionListener(this);
	b2.addActionListener(this);
	b3.addActionListener(this);
	b4.addActionListener(this);
	intext.addActionListener(this);
	
	add(b1); add (intext); add(b2);  add (outext); add(b3); add (b4);
	add(space);
	
public voidlistJobs()

	space.setText(" ");
	 
	if (v1.size()>0)
		{
		for (int i=0; i<v1.size(); i++)
		
			{
		 	work=(String) v1.elementAt(i);
		 	space.append(work + "\n");
			}
		}
	else 
		{
		space.append("No Jobs in List");
		}

public voidpaint(java.awt.Graphics g)