import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class EmployeeTitle3 extends JApplet implements ActionListener
{
Container con = getContentPane();
JLabel greeting = new JLabel("Emplyoyees are: John,Allan,Henry,David,Chris and the jobs are Manager,Asst_Mgr,CEO, EEO_Mgr, Fin_Mgr ");
Font bigFont = new Font("Times Roman", Font.ITALIC, 24);
JLabel Label = new JLabel("Please enter a name or job: ");
JTextField firstField = new JTextField("",10);
JButton viewButton = new JButton(" Display match");
FlowLayout flow = new FlowLayout();
public void init()
final int NUMBER_OF_NAMES = 5;
String [] validNames = {"John", "Allan", "Henry", "David", "Chris"};
String [] title = {"Manager", "Asst_Mgr", "CEO", "EEO_Mgr", "Fin_Mgr"};
String strItem;
double vaildNames;
double empName=vaildNames;
boolean validName = false;
{
greeting.setFont(bigFont);
con.add(greeting);
con.setLayout(flow);
con.add(firstLabel);
con.add(lastLabel);
con.add(viewButton);
viewButton.addActionListener(this);
firstField.requestFocus();
}
public void actionPerformed(ActionEvent thisEvent)
{
String firstName = firstField.getText();
int x;
for(x = 0; x < validNames.lenght; x++)
{
if(strItem.equals(validNames[x]))
break;
}
if(x == validNames.length)
greeting.setText("Sorry - invalid item entered");
else
greeting.setText(strItem + " is the " + title[x]);
}
}
This post has been edited by rphotos: 06 July 2008 - 07:21 PM

New Topic/Question
Reply



MultiQuote





|