This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
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

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "run time error" Watch "run time error" New topic

run time error

karen chong

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"));
p1.add(bSearch = new JButton ("Search"));
p1.add(bDisplay = new JButton ("Display"));
p1.add(bExit = new JButton ("Exit"));
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"));


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)

{ = 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

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));



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

Joined: Jul 08, 2003
Posts: 24189

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:
subject: run time error