Class Employee
Class Employee
return empSalary;
}
public void setEmpSalary(double empSalary) {
this.empSalary = empSalary;
}
@Override
public String toString() {
return "Employee [empId=" + empId + ", empName=" + empName
+ ", empSalary=" + empSalary + "]";
}
import com.employee.Employee;
@SuppressWarnings("serial")
public class SearchPanel extends JPanel
{
setLayout(null);
jid = new JTextField();
jname= new JTextField();
jsalary= new JTextField();
jid.setBounds(100, 100, 100, 30);
jname.setBounds(100, 150, 100, 30);
jsalary.setBounds(100, 200, 100, 30);
add(jid);
add(jname);
add(jsalary);
for (int i = 0; i < e.length; i++) {
if(e[i].getEmpId()==id)
{
jid.setText(Integer.toString(e[i].getEmpId()));
jname.setText(e[i].getEmpName());
jsalary.setText(Double.toString(e[i].getEmpSalary()));
}
}
Class addPanel
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.employee.Employee;
@SuppressWarnings("serial")
public class AddPanel extends JPanel
{
public AddPanel()
{
setLayout(null);
jLabel= new JLabel("Enter Id");
jLabel.setBounds(20, 50, 100, 30);
add(jLabel);
jLabel2= new JLabel("Enter Name");
jLabel2.setBounds(20, 100, 100, 30);
add(jLabel2);
}
public Employee[] display(Employee e[] )
{
Employee employee[]= new Employee[e.length+1];
int i=0;
for (i = 0; i < e.length; i++)
{
employee[i]=e[i];
employee[i]=new
Employee(Integer.parseInt(jTextField.getText()),jTextField2.getText(),Double.parseDouble(jTextField3.ge
tText()));
return employee;
}
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import com.employee.Employee;
import com.searchpanel.AddPanel;
import com.searchpanel.SearchPanel;
@SuppressWarnings("serial")
public Test()
{
e[0]=new Employee(1,"shekhar",500.5);
e[1]= new Employee(2, "saste", 500000.50);
setLayout(null);
jadd= new JButton("ADD");
jdelete= new JButton("DELETE");
jexit= new JButton("Show All");
jsearch= new JButton("SEARCH");
jsearch.setBounds(100, 150, 100, 30);
jadd.setBounds(100, 200, 100, 30);
jdelete.setBounds(100, 250, 100, 30);
jexit.setBounds(100, 300, 100, 30);
add(jsearch);
add(jadd);
add(jdelete);
add(jexit);
jok= new JButton("OK");
jok.setBounds(400, 150, 100, 30);
add(jok);
jok.setVisible(false);
jLabel= new JLabel("Enter Id=");
jLabel.setBounds(200, 150, 100, 30);
add(jLabel);
jLabel.setVisible(false);
jTextField= new JTextField();
jTextField.setBounds(300, 150, 100, 30);
add(jTextField);
jTextField.setVisible(false);
jsearch.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0)
{
jLabel.setVisible(true);
jTextField.setVisible(true);
jok.setVisible(true);
}
});
jok.addActionListener(new ActionListener() {
jLabel.setVisible(false);
jTextField.setVisible(false);
jok.setVisible(false);
jPanel.setVisible(true);*/
jPanel2.setBackground(Color.CYAN);
}
});
jexit.addActionListener(new ActionListener() {
}
});
}
public static void main(String[] args)
{