File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes run time error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "run time error" Watch "run time error" New topic
Author

run time error

karen chong
Greenhorn

Joined: Oct 10, 2003
Posts: 1
i'm using JCreator to code. i cant solve the run time error.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.TitledBorder;

public class Api implements ActionListener//extends JApplet
{ JFrame f;
JPanel p1, p2, p3, p4, p5, p6, p7;
JButton bAdd, bSearch,bDisplay, bExit;
JTextField txtcompany, txtjobtitle, txtsalary, txtref;
JTextField txtskill,txtskill2,txtskill3,txtskill4,txtskill5;
JLabel lbl1,lbl2,lbl3,lbl4,lbl5,lbl6,lbl7,lbl8,lbl9,lbl10,lbltotal,lbl11;
JList listtitle;
JTextArea txtdetail;
Container contentPane;


public void go()
{
f = new JFrame ("Job Vacancies");

contentPane = f.getContentPane();
contentPane.setLayout(new BorderLayout());
p1 = new JPanel();
p1.setLayout(new GridLayout(4,1,0,20));
p1.add(bAdd = new JButton ("Add Record"));
bAdd.addActionListener(this);
p1.add(bSearch = new JButton ("Search"));
bSearch.addActionListener(this);
p1.add(bDisplay = new JButton ("Display"));
bDisplay.addActionListener(this);
p1.add(bExit = new JButton ("Exit"));
bExit.addActionListener(this);
p1.setBorder(new TitledBorder("Menu"));

p2 = new JPanel();
p2.setLayout(new GridLayout(9,1));
p2.add(lbl1 = new JLabel ("Company"));
p2.add(lbl2 = new JLabel ("Job Title"));
p2.add(lbl3 = new JLabel("Job Reference Number"));
p2.add(lbl4 = new JLabel ("Salary"));
p2.add(lbl5 = new JLabel ("Skill 1"));
p2.add(lbl6 = new JLabel("Skill 2"));
p2.add(lbl7 = new JLabel ("Skill 3"));
p2.add(lbl8 = new JLabel ("Skill 4"));
p2.add(lbl9 = new JLabel ("Skill 5"));
p3 = new JPanel();
p3.setLayout(new GridLayout(9,1));
p3.add(txtcompany = new JTextField(25));
p3.add(txtjobtitle = new JTextField());
p3.add(txtref = new JTextField());
p3.add(txtsalary = new JTextField());
p3.add(txtskill = new JTextField());
p3.add(txtskill2 = new JTextField());
p3.add(txtskill3 = new JTextField());
p3.add(txtskill4 = new JTextField());
p3.add(txtskill5 = new JTextField());
p4 = new JPanel();
p4.setLayout(new BorderLayout());
p4.add(p2, BorderLayout.CENTER);
p4.add(p3, BorderLayout.EAST);
p4.setBorder(new TitledBorder("Vacancies"));

p5 = new JPanel();
p5.setLayout(new FlowLayout(FlowLayout.RIGHT));
p5.add(lbltotal= new JLabel("Total of job: 0"));
lbltotal.setFont(new Font("Arial", Font.BOLD, 18));

p6 = new JPanel();
p6.setLayout(new FlowLayout());
//p6.add(lbl11 = new JLabel("Click for more details"));
//lbl11.setFont(Font = new Font="Times New Roman, Font.ITALIC,12));
p6.add(listtitle = new JList());
p6.setBorder(new TitledBorder("Job List"));

p7 = new JPanel();
p7.setLayout(new FlowLayout());
p7.add(txtdetail = new JTextArea("",10,30));
p7.setBorder(new TitledBorder("Vacancies Detail"));
contentPane.add(p1,BorderLayout.EAST);
contentPane.add(p4,BorderLayout.CENTER);
contentPane.add(p5,BorderLayout.NORTH);
contentPane.add(p6,BorderLayout.WEST);
contentPane.add(p7,BorderLayout.SOUTH);


f.pack();
f.setVisible(true);
}

class Job
{
private String company;
private String jobtitle;
private String ref;
private String salary;
private String skill1;
private String skill2;
private String skill3;
private String skill4;
private String skill5;
public Job(String company,
String jobtitle,
String ref,
String Salary,
String skill1,
String skill2,
String skill3,
String skill4,
String skill5)

{this.company = company;
this.jobtitle = jobtitle;
this.ref = ref;
this.salary = salary;
this.skill1 = skill1;
this.skill2 = skill2;
this.skill3 = skill3;
this.skill4 = skill4;
this.skill5 = skill5;
}
public String getCompany()
{
return company;
}
public String getJobTitle()
{
return jobtitle;
}

public String getReferenceNo()
{
return ref;
}

public String getSalary()
{
return salary;
}

public String getSkill1()
{
return skill1;
}

public String getSkill2()
{
return skill2;
}

public String getSkill3()
{
return skill3;
}

public String getSkill4()
{
return skill4;
}

public String getSkill5()
{
return skill5;
}
}
class Vacancies
{
Job[] j = new Job[10];
public int length=0;

public void addNewJob (String company,
String jobtitle,
String ref,
String salary,
String skill1,
String skill2,
String skill3,
String skill4,
String skill5)

{j[length] = new Job
(company,
jobtitle,
ref,
salary,
skill1,
skill2,
skill3,
skill4,
skill5);
length++;
}

public String getCompany(int x)
{
return j[x].getCompany();
}

public String getJobTitle(int x)
{
return j[x].getJobTitle();
}

public String getReferenceNo(int x)
{
return j[x].getReferenceNo();
}

public String getSalary(int x)
{
return j[x].getSalary();
}

public String getSkill1(int x)
{
return j[x].getSkill1();
}

public String getSkill2(int x)
{
return j[x].getSkill2();
}

public String getSkill3(int x)
{
return j[x].getSkill3();
}

public String getSkill4(int x)
{
return j[x].getSkill4();
}

public String getSkill5(int x)
{
return j[x].getSkill5();
}

}
Vacancies v = new Vacancies();


public void actionPerformed (ActionEvent z)
{
if (z.getSource() == bAdd)
{ String company = txtcompany.getText();
String jobtitle = txtjobtitle.getText();
String ref = txtref.getText();
String salary = txtsalary.getText();
String skill1 = txtskill.getText();
String skill2 = txtskill2.getText();
String skill3 = txtskill3.getText();
String skill4 = txtskill4.getText();
String skill5 = txtskill5.getText();

v.addNewJob(company, jobtitle, ref, salary, skill1, skill2, skill3, skill4, skill5);


lbltotal.setText("Total of job: "+ v.length);


String[] data = new String[v.length];

listtitle = new JList(data);
for(int i=0; i<v.length; i++)
{
data[i] = new String(v.getJobTitle(i));
}

//listjobtitle.addListenSelectionListener(this);
listtitle.setListData(data);

txtdetail.setText("");
txtcompany.setText("");
txtjobtitle.setText("");
txtref.setText("");
txtsalary.setText("");
txtskill.setText("");
txtskill2.setText("");
txtskill3.setText("");
txtskill4.setText("");
txtskill5.setText("");
}

}
public static void main(String args[])
{
Api gui= new Api();
gui.go();
} }
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi Karen,
Welcome to JavaRanch!
We'd more easily be able to help you if you describe the error you're seeing. "I get an error X when I do Y while running this program."


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: run time error