Suela Smith

Greenhorn
+ Follow
since Apr 20, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Suela Smith

Where in javac lin should i add "deprecation"
18 years ago
Hi erveryone

anyone can halp me out with this compile error

Error:

java uses or overide a deprecated API

Recompile with -deprecation for details

any help would be greatly apriciated

Suela
18 years ago
Hi everyone

I got a JButton, JTextField, and JTextArea. I want to add the text from JTextField to JTextArea, and all this to happen when i click the JButton


thanks in advance for any help
18 years ago
hi
hi Michael and CR
thankyou both for your replay, they were very helpful

thanks again
SUE
18 years ago
Hi everyone
I need help with ActionListener, I have a JFrame which has some JLabels, some TextField, four JButtons, and a JTextArea. I want to add on the JTextArea what i write in the JTextField, so when i click the button Add the text goes to the textarea.

Thanks in advance

COde:

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

public class AddPersonsData extends JFrame {
public AddPersonsData(){
super("Add Persons Data");
setSize(790,270);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = getContentPane();
JPanel panel1 = new JPanel(new FlowLayout());

JButton button1 = new JButton("Load");
panel1.add(button1);
JButton button2 = new JButton("Save");
panel1.add(button2);
JButton button3 = new JButton("Clear");
panel1.add(button3);
JButton button4 = new JButton("Exit");
panel1.add(button4);
contentPane.add("South", panel1);

JPanel panel2 = new JPanel(new GridLayout(7, 2));

panel2.add(new JLabel("First Name", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Middle Name",JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Last Name", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Gender", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Birth Year", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Birth Month", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Birth Day", JLabel.RIGHT));
panel2.add(new JTextField(20));
contentPane.add("Center", panel2);

JPanel panel3 = new JPanel();
panel3.add(new JScrollPane(new JTextArea(11, 20)));
contentPane.add("West", panel3);

} //end constructor method
public static void main(String[] args) {
// perform any initialization
AddPersonsData apd=new AddPersonsData();
apd.setVisible(true);
}
}
18 years ago
Thank you Garrett
Now every thing works fine
18 years ago
hi everyone
I got a syntax error:
any help is greatly apriciate

Code:
import java.util.*;
import java.io.*;

public class Person implements Serializable {
private String first_name = null;
private String middle_name = null;
private String last_name = null;
private Calendar birthday = null;
private String gender = null;

public static final String MALE = "Male";
public static final String FEMALE = "Female";

public Person(String f_name, String m_name, String l_name, int dob_year, int dob_month, int dob_day,String gender){

first_name = f_name;
middle_name = m_name;
last_name = l_name;
this.gender = gender;

birthday = Calendar.getInstance();
birthday.set(dob_year, dob_month, dob_day);
}

public int getAge(){
Calendar today = Calendar.getInstance();
int now = today.get(Calendar.YEAR);
int then = birthday.get(Calendar.YEAR);
return (now - then);
}

public String getFullName(){ return (first_name + " " + middle_name + " " + lastname);

public String getFirstName(){ return first_name;}
public void setFirstName{String f_name) ( first_name = f_name

public String getMiddleName(){ return middle_name;}
public void setMiddleName{String m_name) ( middle_name = m_name

public String getLastName(){ return last_name;}
public void setLastName{String l_name) ( last_name = l_name

public String getNameAndAge(){ return (getFullName() + " " + getAge());

public String getGender(){ return gender;}
public void setGender(String gender){ this.gender = gender; }

public void setBirthday(int year, int month, int day){ birthday.set(year, month, day);}

public String toString(){
return.this.getFullName() + " " + gender + " " + birthday.get(Calendar.DATE) + "/" + birthday.get(Calendar.MONTH) + "/" + birthday.get(Calendar.YEAR);
}

public boolen equals(Object o){
if(o == null) return false;
boolen is_equal = false;
if(o instanceof Person){
if(this.first_name.equals(((Person)o).first_name) &&
this.middle_name.equals(((Person)o).middle_name) && this.gender.equals(((Person)o).gender) &&
this.birthday.get(Calendar.YEAR) == ((Person)o).birthday.get(Calendar.YEAR)) &&
this.birthday.get(Calendar.MONTH) == ((Person)o).birthday.get(Calendar.MONTH)) &&
this.birthday.get(Calendar.DATE) == ((Person)o).birthday.get(Calendar.DATA)) ){
is_equal = true;
}
}
return is_equal;
}
} //end Person class

Errors:
34: illegal start of expression
public String getFirstName(){ return first_name;}
68: ";" expected
} //end Person class
18 years ago
Hi everyone
any idea why i got this runtime errors

code:

import java.awt.*;
import javax.swing.*;

public class Exercise extends JFrame {

public Exercise(){
super("Exercise3");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
createGUI();
}

public void createGUI(){
JLabel label1 = null;
JLabel label2 = null;
JLabel label3 = null;
JLabel label4 = null;
JLabel label5 = null;

JTextField textfield1 = null;
JTextField textfield2 = null;
JTextField textfield3 = null;
JTextField textfield4 = null;
JTextField textfield5 = null;

JButton jbutton1 = null;
JButton jbutton2 = null;
JButton jbutton3 = null;
JButton jbutton4 = null;

JPanel jpanel1 = null;
JPanel jpanel2 = null;

jpanel1 = new JPanel();
jpanel2 = new JPanel();

label1 = new JLabel("First Name");
textfield1 =new JTextField("20");

label2 = new JLabel("Middle Name");
textfield1 =new JTextField("20");

label1 = new JLabel("Last Name");
textfield1 =new JTextField("20");

label1 = new JLabel("Gender");
textfield1 =new JTextField("20");

label1 = new JLabel("Age");
textfield1 =new JTextField("20");

jbutton1 = new JButton("Load");
jbutton2 = new JButton("Save");
jbutton3 = new JButton("Clear");
jbutton4 = new JButton("Next");

jpanel1.setLayout(new GridLayout(5,2,0,0));
jpanel1.add(label1);
jpanel1.add(textfield1);
jpanel1.add(label2);
jpanel1.add(textfield2);
jpanel1.add(label3);
jpanel1.add(textfield3);
jpanel1.add(label4);
jpanel1.add(textfield4);
jpanel1.add(label5);
jpanel1.add(textfield5);

jpanel2.setLayout(new GridLayout(3,3,0,0));
jpanel2.add(jbutton1);
jpanel2.add(jbutton2);
jpanel2.add(jbutton3);
jpanel2.add(jbutton4);

this.getContentPane().setLayout(new GridLayout(3,1,0,0));
this.getContentPane().add(jpanel1);
this.getContentPane().add(jpanel2);

this.setSize(400, 300);
this.setLocation(200, 200);
this.show();

}

public static void main(String[] arg) {
JFrame frame = new Exercise();
frame.pack();
frame.setVisible(true);
}
}

run time errors:

Exeption in thread "main" java.lang.NullPointerExeption
at java.awt.Container.addImpl<Uknown Source>
at java.awt.Container.add<Uknown Source>
at Exercise.createGUI<Exercise.java:60>
at Exercise.<int><Exercise.java:9>
at Exercise.main<Exercise.java:85>

thnak you in advance

Suela
18 years ago
thanks Craig for your help
I need your help again becouse i still get an error
error:

";" expected
al = ActionLstener(){

when i replaced "{" with ";" i got more erors

thanks again
18 years ago
Hi, I want to create a JFrame that has JLabels, JTextArea, JTextField, and JButtons, i have this code but when i try to cmpile i got an error.

code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;


public class PersonGUI extends JFrame {{

JPanel panel1 = null;
JPanel panel2 = null;
JPanel panel2a = null;
JPanel panel2b = null;
JPanel panel2c = null;
JPanel panel2a1 = null;

JLabel label1 = null;
JLabel label2 = null;
JLabel label3 = null;
JLabel label4 = null;
JLabel label5 = null;

JTextField textfield1 = null;
JTextField textfield2 = null;
JTextField textfield3 = null;
JTextField textfield4 = null;
JTextField textfield5 = null;

JTextArea textarea1 = null;

JButton button1 = null;
JButton button2 = null;
JButton button3 = null;
JButton button4 = null;


panel1 = new JPanel();
panel2 = new JPanel();
panel2a = new JPanel();
panel2b = new JPanel();
panel2c = new JPanel();
panel2a1 = new JPanel();

label1 = new JLabel("First Name");
label2 = new JLabel("Last Name");
label3 = new JLabel("Middle Name");
label4 = new JLabel("Age");
label5 = new JLabel("Gender");

textfield1 = new JTextField(20);
textfield2 = new JTextField(20);
textfield3 = new JTextField(20);
textfield4 = new JTextField(20);
textfield5 = new JTextField(20);

textarea1 = new JTextArea(50, 20);
JScrollPane scrollpane = new JScrollPane(textarea1);

button1 = new JButton("Save");
button1.addActionListener(al);
button2 = new JButton("Next");
button2.addActionListener(al);
button3 = new JButton("Load");
button3.addActionListener(al);
button4 = new JButton("Clear");
button4.addActionListener(al);

panel2.setLayout(new GridLayout(3, 1, 0, 0));

panel2a.setLayout(new GridLayout(2, 1, 0, 0));
panel1.add(scrollpane);

panel2a1.add(label1);
panel2a1.add(textfield1);

panel2a1.add(label2);
panel2a1.add(textfield2);

panel2a1.add(label3);
panel2a1.add(textfield3);

panel2a1.add(label4);
panel2a1.add(textfield4);

panel2a1.add(label5);
panel2a1.add(textfield5);

panel2.add(panel2a);

panel2.add(panel2b);
panel2.add(panel2c);

this.getContentPane().setLayout(new GridLayout(2, 1, 0, 0));
this.getContentPane().add(panel1);
this.getContentPane().add(panel2);
this.setSize(800,600);
this.setLocation(200,200);
this.pack();
this.setVisible(true);
}
}
errors:
cannot resolve symbol
variable al
button1.addActionListener(al);

Ty in advance for ur help
18 years ago
Hi everyone
I'm trying to build a JFrame that includes JPanels, JLabels, JButton, and JTextArea; I don't know why i get an error when i try to compile the code

code:

private JPanele panel1 = null;
private JPanele panel2 = null;
private JPanele panel2a = null;
private JPanele panel2b = null;
private JPanele panel2c = null;
private JPanele panel2a1 = null;

private JLabel label1 = null;
private JLabel label2 = null;
private JLabel label3 = null;
private Jlabel label4 = null;
private JLabel label5 = null;

private JTextField textfield1 = null;
private JTextField textfield2 = null;
private JTextField textfield3 = null;
private JTextField textfield4 = null;
private JTextField textfield5 = null;

private JTextArea textarea1 = null;

private JButton button1 = null;
private JButton button2 = null;
private JButton button3 = null;
private JButton button4 = null;


panel1 = new JPanel();
panel2 = new JPanel();
panel2a = new JPanel();
panel2b = new JPanel();
panel2c = new JPanel();
panel2a1 = new JPanel();

label1 = new JLabel("First Name");
label2 = new JLabel("Last Name");
label3 = new JLabel("Middle Name");
label4 = new JLabel("Age");
label5 = new JLabel("Gender");

textfield1 = new JTextField(20);
textfield2 = new JTextField(20);
textfield3 = new JTextField(20);
textfield4 = new JTextField(20);
textfield5 = new JTextField(20);

textarea1 = new JTextArea(50, 20);
JScrollPane scrollpane = new JScrollPane(textarea1);

button1 = new JButton("Save");
button1.addActionListener(al);
button2 = new JButton("Next");
button2.addActionListener(al);
button3 = new JButton("Load");
button3.addActionListener(al);
button4 = new JButton("Clear");
button4.addActionListener(al);

panel2.setLayout(new GridLayout(3. 1, 0, 0));

panel2a.setLayout(new GridLayout(2. 1, 0, 0));
panel1.add(scrollpane);

panel2a1.add(label1);
panel2a1.add(textfield1);

panel2a1.add(label2);
panel2a1.add(textfield2);

panel2a1.add(label3);
panel2a1.add(textfield3);

panel2a1.add(label4);
panel2a1.add(textfield4);

panel2a1.add(label5);
panel2a1.add(textfield5);

panel2.add(panel2a);
panel2.add(panel2b);
panel2.add(panle2c);

this getContentPane().setLayout(new GridLayout(2, 1, 0, 0);
this.getContentPane().add(panel1);
this.getContentPane().add(panel2);
this.setSize(800,600);
this.setLocation(200,200);
this.pack();
this.setVisible(true);
}//end constructor

Error:
illegal start of expresion
private JPanel panel1 = null;

any help is greatly appriciated
18 years ago