I want to create payslip in java

public Vector createData()
    {
        Vector result = new Vector();
        Vector rec = new Vector();
        Object[] value = new Object[] {"Employee Name",ename.getSelectedItem().toString()};
        rec.add(value);
        value = new Object[] {"Mary-Kate Olsen", "Ashley Olsen"};
        rec.add(value);
        result.add(rec);
        rec = new Vector();
        value = new Object[] {"Charlie Read", "Craig Read"};
        rec.add(value);
        value = new Object[] {"Tegan Quin", "Sara Quin"};
        rec.add(value);
        result.add(rec);
        return result;
    }

I have exception in this line

Object[] value = new Object[] {"Employee Name",f.ename.getSelectedItem()};

It cant display the employee name. The employee name changed at any time. Its depend upon the user selection. But exception thrown. Please help me.

OK, I'm kind of confused about the purpose of your code... Let see your code...

public Vector createData() {
  Vector result = new Vector();
  Vector rec = new Vector();
  // the line below, where does 'ename' variable come from?
  Object[] value = new Object[] {"Employee Name",ename.getSelectedItem().toString()};

  // rec => [["Employee Name", ename.getSelectedItem().toString()], ["Mary..", "Ash.."]]
  // Result => [[["Employee Name", ename.getSelectedItem().toString()], ["Mary..", "Ash.."]]]
  rec.add(value);
  value = new Object[] {"Mary-Kate Olsen", "Ashley Olsen"};
  rec.add(value);
  result.add(rec);

  // rec => [["Charlie...", "Craig..."], ["Tegan..", "Sara.."]]
  // Result => [[["Employee Name", ename.getSelectedItem().toString()], ["Mary..", "Ash.."]], [["Charlie...", "Craig..."], ["Tegan..", "Sara.."]]]
  rec = new Vector();
  value = new Object[] {"Charlie Read", "Craig Read"};
  rec.add(value);
  value = new Object[] {"Tegan Quin", "Sara Quin"};
  rec.add(value);
  result.add(rec);

  return result;
}

// now about your error line question
Object[] value = new Object[] {"Employee Name",f.ename.getSelectedItem()};
// How do you implement the class that 'f' is declared under?
// You also confuse me by having 'getSelectedItem()' method right after ename.
// What ename is supposed to be? Another class?
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.