Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Why am I getting this error

  • 28-08-2009 2:11pm
    #1
    Closed Accounts Posts: 32


    New(java.lang.String,java.lang.String,java.sql.Date,java.lang.String) in Employees cannot be applied to (java.lang.String)

    Here is my code:


    /*
    * EmployeeForm2.java
    *
    * Created on 22-Aug-2009, 12:52:49
    */


    import java.sql.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.Date;
    public class frmEmployee extends javax.swing.JFrame {

    private Roster7 r7 = null;
    private javax.swing.table.DefaultTableModel tm= new javax.swing.table.DefaultTableModel(GetEmployees(),GetColumns());
    // private Date date;
    /** Creates new form EmployeeForm2 */
    public frmEmployee() {
    initComponents();


    }

    private void UpdateRecord(){
    int i=0;
    int c=0;

    c=r7.GetEmployees().getCount();

    }

    private void UpdateMode(){
    Delete.setEnabled(true);
    Contracts.setEnabled(true);

    Insert.setText("Update");

    int row = EmployeeTable.getSelectedRow();

    Id.setText(EmployeeTable.getValueAt(row,0).toString());
    Desc.setText(EmployeeTable.getValueAt(row,1).toString());
    lname.setText(EmployeeTable.getValueAt(row,2).toString());
    birthday.setText(EmployeeTable.getValueAt(row,3).toString());
    add.setText(EmployeeTable.getValueAt(row,4).toString());
    }

    private void InsertRecord(){
    AvailabilityType at=null;

    r7.GetEmployees().New(Desc.getText().toString());

    Object nr[] = new Object[5];

    int i=0;

    i=r7.GetEmployees().getCount();

    nr[0]=0;//r7.GetAvailabilityTypes().getItem(i-1).getAvailabilityTypeID();
    nr[1]=Desc.getText().toString();
    nr[2]=lname.getText().toString();
    nr[3]=birthday.getText().toString;
    nr[4]=add.getText().toString();


    tm.addRow(nr);
    //tm.insertRow()

    //MyTableListener(null);
    }


    private void InsertMode(){
    Delete.setEnabled(false);
    Insert.setText("Insert");
    Clear.enable(false);
    Id.setText("");
    Desc.setText("");
    lname.setText("");
    birthday.setText("");
    add.setText("");
    }

    private String[] GetColumns(){
    String str[] = new String[5];

    str[0]="Employee ID";
    str[1]="First Name";
    str[2]="Surname";
    str[3]="DOB";
    str[4]="Address";


    return str;
    }

    private Object[][] GetEmployees(){
    if(r7==null){
    r7 = new Roster7();
    }

    Object data[][]=null;

    Employees emps = r7.GetEmployees();
    Employee emp = null;
    int i = 0;
    int c =0;

    c = emps.getCount();

    data=new Object[c][5];

    for(i=0; i<c; i++){
    emp = emps.getItem(i);
    data[0]=emp.getEmployeeId();
    //JOptionPane.showMessageDialog(null,data[0]);
    data[1]=emp.getFirstName();
    data[2]=emp.getLastName();
    data[3]=emp.getDOB();
    data[4]=emp.getAddress();
    }
    return data;
    }



    @SuppressWarnings(&quot;unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    EmployeeID = new javax.swing.JLabel();
    ID = new javax.swing.JTextField();
    FirstName = new javax.swing.JLabel();
    FName = new javax.swing.JTextField();
    Surname = new javax.swing.JLabel();
    SName = new javax.swing.JTextField();
    DOB = new javax.swing.JLabel();
    DateOfBirth = new javax.swing.JTextField();
    Insert = new javax.swing.JButton();
    Delete = new javax.swing.JButton();
    Clear = new javax.swing.JButton();
    Contracts = new javax.swing.JButton();
    Avalibilty = new javax.swing.JButton();
    Address = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    AddressBox = new javax.swing.JTextArea();
    jScrollPane2 = new javax.swing.JScrollPane();
    EmployeeTable = new javax.swing.JTable();
    Desc = new javax.swing.JTextField();
    birthday = new javax.swing.JTextField();
    add = new javax.swing.JTextField();
    lname = new javax.swing.JTextField();
    Id = new javax.swing.JTextField();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    EmployeeID.setText("Employee ID");
    ID.setEnabled(false);
    FirstName.setText("First Name");
    Surname.setText("Surname");
    DOB.setText("DOB");
    Insert.setText("Insert");
    Insert.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    InsertActionPerformed(evt);
    }
    });
    Delete.setText("Delete");
    Delete.setEnabled(false);
    Delete.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    DeleteActionPerformed(evt);
    }
    });
    Clear.setText("Clear");
    Clear.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    ClearActionPerformed(evt);
    }
    });
    Contracts.setText("Contracts");
    Contracts.setEnabled(false);
    Contracts.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    ContractsActionPerformed(evt);
    }
    });





    Avalibilty.setText("Avalibility");
    Avalibilty.setEnabled(true);
    Avalibilty.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    AvalibiltyActionPerformed(evt);
    }
    });
    Address.setText("Address");
    AddressBox.setColumns(20);
    AddressBox.setRows(5);
    jScrollPane1.setViewportView(AddressBox);

    EmployeeTable.setModel(tm);

    tm.addTableModelListener(new MyTableListener());



    // EmployeeTable.setModel(new javax.swing.table.DefaultTableModel(
    // GetEmployees(),
    // GetColumns()
    //));
    EmployeeTable.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    EmployeeTableMouseClicked(evt);
    }
    });
    jScrollPane2.setViewportView(EmployeeTable);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE)
    .addGap(37, 37, 37)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(DOB)
    .addComponent(Surname)
    .addComponent(EmployeeID)
    .addComponent(FirstName)))
    .addGroup(layout.createSequentialGroup()
    .addComponent(Insert)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(Delete)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(Clear)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(Contracts)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(Avalibilty)))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    .addComponent(Address))
    .addComponent(FName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(SName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(DateOfBirth, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap())
    );
    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {Avalibilty, Clear, Contracts, Delete, Insert});
    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {DateOfBirth, FName, ID, SName});
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 358, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(EmployeeID)
    .addComponent(ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(Address))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(FirstName)
    .addComponent(FName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(Surname)
    .addComponent(SName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(DateOfBirth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(DOB)))
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(297, 297, 297)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(Insert)
    .addComponent(Delete)
    .addComponent(Clear)
    .addComponent(Contracts)
    .addComponent(Avalibilty))))
    .addContainerGap(29, Short.MAX_VALUE))
    );
    layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {Avalibilty, Clear, Contracts, Delete, Insert});
    layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {DateOfBirth, FName, ID, SName});
    pack();
    }// </editor-fold>
    private void DeleteActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    JOptionPane.showMessageDialog(null,"Delete Pressed");

    }
    private void InsertActionPerformed(java.awt.event.ActionEvent evt) {

    if(Insert.getText()=="Insert"){
    //Perform Insert Action
    try{
    InsertRecord();
    JOptionPane.showMessageDialog(null,"Insert Succeeded");
    }
    catch(Exception ex){
    JOptionPane.showMessageDialog(null,"Insert Failed");
    }
    UpdateRecord();
    InsertMode();
    }
    else{
    //Permform Update Action
    InsertMode();
    }

    }





    private void AvalibiltyActionPerformed(java.awt.event.ActionEvent evt) {

    frmAvailability f = new frmAvailability();

    f.setVisible(true);




    }

    private void ClearActionPerformed(java.awt.event.ActionEvent evt) {
    InsertMode();
    }
    private void ContractsActionPerformed(java.awt.event.ActionEvent evt) {
    frmEmployeeContracts con = new frmEmployeeContracts();
    con.setVisible(true);
    }
    private void EmployeeTableMouseClicked(java.awt.event.MouseEvent evt) {
    UpdateMode();

    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new frmEmployee().setVisible(true);
    }
    });
    }
    // Variables declaration - do not modify
    private javax.swing.JLabel Address;
    private javax.swing.JTextArea AddressBox;
    private javax.swing.JButton Avalibilty;
    private javax.swing.JButton Clear;
    private javax.swing.JButton Contracts;
    private javax.swing.JLabel DOB;
    private javax.swing.JTextField DateOfBirth;
    private javax.swing.JButton Delete;
    private javax.swing.JLabel EmployeeID;
    private javax.swing.JTable EmployeeTable;
    private javax.swing.JTextField FName;
    private javax.swing.JLabel FirstName;
    private javax.swing.JTextField ID;
    private javax.swing.JButton Insert;
    private javax.swing.JTextField SName;
    private javax.swing.JLabel Surname;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField Desc;
    private javax.swing.JTextField birthday;
    private javax.swing.JTextField lname;
    private javax.swing.JTextField add;
    private javax.swing.JTextField Id;
    // End of variables declaration
    }


Comments

  • Closed Accounts Posts: 909 ✭✭✭Captain Furball


    Does java come with a debugger?
    I've never used the language but i'm sure it does?
    Where in your code does it stop executing?


  • Registered Users, Registered Users 2 Posts: 3,945 ✭✭✭Anima


    [PHP]r7.GetEmployees().New(Desc.getText().toString());[/PHP]

    Your not sending enough information to the constructor. Your giving it one string when its asking for 4 different variables.

    [PHP]New(java.lang.String,java.lang.String,java.sql.Date,java.lang.String)[/PHP]

    So either add in the missing variables or make another version of New (not a great name btw) that takes in just one string.


Advertisement