am developing a gui based application.my problem is that i want to see a second gui form i created when i click on the continue button on my first form....here is a portion of my code......please i need your help,what should i do in my logic? THANKS
//FORM1 CODE
private class ButtonHandler implements ActionListener,Serializable {
public void actionPerformed(ActionEvent e) {
Form1 form1 = new Form1();
String x = "";
File file = new File("client.txt");
/**
try {
RandomAccessFile Rfile = new RandomAccessFile("client.txt","rw");
long n = 10;
Rfile.seek(n);
} catch(FileNotFoundException j){}catch(IOException nb){}
*/
try {
FormLogic logic = new FormLogic();
PrintWriter out = new PrintWriter(new FileWriter(file));
logic.setName(nameText.getText());
String schooldata = (String) boxForSchoolsComboBox.getSelectedItem();
String graduatedata = (String)graduateDegreeProgramComboBox.getSelectedItem();
String statedata = (String) stateComboBox.getSelectedItem();
String addressdata = addressText.getText();
String citydata = cityText.getText();
String statdata = statetext.getText();
String zipcodedata = zipcodeText.getText();
String countrycode = countryText.getText();
String countrycodedata = countrycodeText.getText();
String areacodedata = areacodeText.getText();
String phonenodata = phonenumberText.getText();
String emaildata = emailaddressText.getText();
String datebatedata = dateofbirthText.getText();
String citizendata =(String) citizenstatusComboBox.getSelectedItem();
boolean radiodata = maleButton.isSelected();
out.println(schooldata);
out.println(graduatedata);
out.println(logic.getName());
out.println(addressdata);
out.println(citydata);
out.println(statdata);
out.println(zipcodedata);
out.println(countrycode);
out.println(countrycodedata);
out.println(areacodedata);
out.println(phonenodata);
out.println(emaildata);
out.println(datebatedata);
if(radiodata == true) {
out.println("MALE");
}
else {out.println("FEMALE");}
out.close();
/**
RandomAccessFile Rfile = new RandomAccessFile("client.txt","rws");
long n =30;
n++;
Rfile.seek(file.length());
Rfile.seek(n);
Rfile.writeBytes(addressdata);
long m =20;
m++;
Rfile.seek(file.lastModified());
Rfile.seek(file.length());
Rfile.writeBytes(citydata);
Rfile.seek(file.length());
Rfile.close();
*/
}catch (IOException e1){
System.out.print("error opening file");
}
//this.launch();
}
//FORM2 CODE....
public class Form1 extends JFrame implements ActionListener {
public void actionPerformed(ActionEvent ae){}
/** Creates a new instance of Form1 */
private JLabel qualificationFormLabel,schoolLabel;
private JLabel graduationdegreeLabel,universityLabel;
private JComboBox graduateDegreeProgramComboBox,boxForSchoolsComboBox;
private JLabel gradeLabel,grescoreLabel;
private JTextField gradeText,universityText;
private JLabel testdateLabel,scoreLabel,toeflscoreLabel,detailsLabel;
private JTextField testdateText,scoreText;
private JButton submitButton;
private JPanel qualificationFormPanel;
private JPanel graduateDegreeProgramPanel,schoolPanel;
private JPanel gradePanel;
private JPanel graduategradePanel;
private JPanel grePanel,testPanel,toeflPanel,detailsPanel,submitPanel;
private JPanel generalPanel;
private Font font, fontGDP;
private String graduateDegreePrograms[] = {"Aeronautics-Astonautics", "Earth Science","Applied Physics ", "Biochemistry", "Education", "Biosciences", "Humanities and Sciences", "Engineering and Applied Sciences", "Architecture", "Law", "Nursing", "Journalism"};
private String school[] = {"Engineering", "Medicine","Law", "Social Sciences", "Humanities", "Education","Sciences"};
public Form1() {
//Set the title of the frame.
super.setTitle("QUALIFICATION DETAILS.....");
font = new Font("Roman", Font.BOLD, 15);
fontGDP = new Font("Tahoma", Font.PLAIN,12);
//Initializing the qualificationFormLabel
qualificationFormLabel = new JLabel("QUALIFICATION DETAILS");
qualificationFormLabel.setFont(font);
qualificationFormLabel.setForeground(Color.black);
qualificationFormLabel.setVisible(true);
//Initializing the qualificationFormPanel
qualificationFormPanel = new JPanel();
qualificationFormPanel.add(qualificationFormLabel);
qualificationFormPanel.setVisible(true);
//Initializing the graduationdegreeLabel
graduationdegreeLabel = new JLabel("GRADUATION DEGREE" +
" PROGRAM:");
graduationdegreeLabel.setFont(fontGDP);
graduationdegreeLabel.setForeground(Color.black);
graduationdegreeLabel.setVisible(true);
//Initializing the graduateDegreeProgramComboBox
graduateDegreeProgramComboBox = new JComboBox();
for(int count1 = 0; count1 <= 11; count1++)
{
graduateDegreeProgramComboBox.addItem(graduateDegreePrograms[count1]);
}
graduateDegreeProgramComboBox.setMaximumRowCount(4);
graduateDegreeProgramComboBox.isEditable();
graduateDegreeProgramComboBox.setVisible(true);
graduateDegreeProgramComboBox.setVisible(true);
//Initializing the gradeLabel
gradeLabel = new JLabel(" GRADE:");
gradeLabel.setFont(fontGDP);
gradeLabel.setForeground(Color.black);
gradeLabel.setVisible(true);
//Initializing the gradeText
gradeText = new JTextField(8);
gradeText.setFont(fontGDP);
gradeText.setForeground(Color.BLACK);
gradeText.setVisible(true);
//Initializing the gradePanel
gradePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
gradePanel.add(gradeLabel);
gradePanel.add(gradeText);
//Initializing the graduateDegreeProgramPanel
graduateDegreeProgramPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
graduateDegreeProgramPanel.add(graduationdegreeLabel);
graduateDegreeProgramPanel.add(graduateDegreeProgramComboBox);
graduateDegreeProgramPanel.add(gradePanel);
graduateDegreeProgramPanel.setVisible(true);
// Initializing boxForSchoolsComboBox
boxForSchoolsComboBox = new JComboBox();
for(int count = 0; count <= 6; count++)
{
boxForSchoolsComboBox.addItem(school[count]);
}
boxForSchoolsComboBox.setMaximumRowCount(3);
boxForSchoolsComboBox.isEditable();
boxForSchoolsComboBox.setVisible(true);
// Initializing schoolLabel
schoolLabel = new JLabel("School:");
schoolLabel.setFont(fontGDP);
schoolLabel.setForeground(Color.BLACK);
schoolLabel.setVisible(true);
//Initializing the universityLabel
universityLabel = new JLabel(" UNIVERSITY:");
universityLabel.setFont(fontGDP);
universityLabel.setForeground(Color.BLACK);
universityLabel.setVisible(true);
//Initiallizing the universityText
universityText = new JTextField(15);
universityText.setFont(fontGDP);
universityText.setForeground(Color.BLACK);
universityText.setVisible(true);
// Initializing the schoolPanel
schoolPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
schoolPanel.add( schoolLabel);
schoolPanel.add(boxForSchoolsComboBox);
schoolPanel.add(universityLabel);
schoolPanel.add(universityText);
// Initializing grescoreLabel
grescoreLabel = new JLabel("GRADUATE RECORD EXAMINATION(GRE)SCORES:");
grescoreLabel.setFont(font);
grescoreLabel.setForeground(Color.BLACK);
grescoreLabel.setVisible(true);
// Initializing the grePanel
grePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
grePanel.add(grescoreLabel);
// Initializing testdateLabel
testdateLabel = new JLabel("TESTDATE:");
testdateLabel.setFont(fontGDP);
testdateLabel.setForeground(Color.BLACK);
testdateLabel.setVisible(true);
//Initiallizing the testdateText
testdateText = new JTextField(15);
testdateText.setFont(fontGDP);
testdateText.setForeground(Color.BLACK);
testdateText.setVisible(true);
// Initializing scoreLabel
scoreLabel = new JLabel(" SCORE(%):");
scoreLabel.setFont(fontGDP);
scoreLabel.setForeground(Color.BLACK);
scoreLabel.setVisible(true);
//Initiallizing the scoreText
scoreText = new JTextField(15);
scoreText.setFont(fontGDP);
scoreText.setForeground(Color.BLACK);
scoreText.setVisible(true);
// Initializing the testPanel
testPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
testPanel.add(testdateLabel);
testPanel.add(testdateText);
testPanel.add(scoreLabel);
testPanel.add(scoreText);
// Initializing toeflscoreLabel
toeflscoreLabel = new JLabel("TOEFL SCORE (IF REQUIRED):");
toeflscoreLabel.setFont(fontGDP);
toeflscoreLabel.setForeground(Color.BLACK);
toeflscoreLabel.setVisible(true);
//Initiallizing the scoreText
scoreText = new JTextField(35);
scoreText.setFont(fontGDP);
scoreText.setForeground(Color.BLACK);
scoreText.setVisible(true);
// Initializing the toeflPanel
toeflPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
toeflPanel.add(toeflscoreLabel);
toeflPanel.add(scoreText);
// Initializing detailsLabel
detailsLabel = new JLabel("DETAILS OF RECENT HONORS AND AWARDS:");
detailsLabel.setFont(fontGDP);
detailsLabel.setForeground(Color.BLACK);
detailsLabel.setVisible(true);
//Initiallizing the scoreText
scoreText = new JTextField(50);
scoreText.setFont(fontGDP);
scoreText.setForeground(Color.BLACK);
scoreText.setVisible(true);
// Initializing the detailsPanel
detailsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
detailsPanel.add(detailsLabel);
detailsPanel.add(scoreText);
//Initializing the submitButton
submitButton = new JButton("SUBMIT:");
submitButton.setVisible(true);
//Initializing the buttonHandler
ButtonHandler2 button = new ButtonHandler2();
submitButton.addActionListener(button);
//Initializing the submitPanel
submitPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
submitPanel.add(submitButton);
generalPanel = new JPanel(new GridLayout(8,7,0,0));
generalPanel.add(qualificationFormPanel);
generalPanel.add(graduateDegreeProgramPanel);
generalPanel.add(schoolPanel);
generalPanel.add(grePanel);
generalPanel.add(testPanel);
generalPanel.add(toeflPanel);
generalPanel.add(detailsPanel);
generalPanel.add(submitPanel);
generalPanel.setVisible(true);
add(generalPanel);
}
class ButtonHandler2 implements ActionListener,Serializable {
public void actionPerformed(ActionEvent e) {
File file = new File("client2.txt");
try {
PrintWriter out = new PrintWriter(new FileWriter(file));
String graduatedata = (String)graduateDegreeProgramComboBox.getSelectedItem();
String gradedata = gradeText.getText();
String universitydata = universityText.getText();
String boxForSchoolsdata = (String) boxForSchoolsComboBox.getSelectedItem();
String testdatedata = testdateText.getText();
String scoredata = scoreText.getText();
out.println(graduatedata);
out.println(gradedata);
out.println(universitydata);
out.println(boxForSchoolsdata);
out.println(testdatedata);
out.println(scoredata);
out.close();
}catch (IOException i) {
System.out.println("AN ERROR HAS OCCURRED!!!");
}
}
//FORM1 CODE
private class ButtonHandler implements ActionListener,Serializable {
public void actionPerformed(ActionEvent e) {
Form1 form1 = new Form1();
String x = "";
File file = new File("client.txt");
/**
try {
RandomAccessFile Rfile = new RandomAccessFile("client.txt","rw");
long n = 10;
Rfile.seek(n);
} catch(FileNotFoundException j){}catch(IOException nb){}
*/
try {
FormLogic logic = new FormLogic();
PrintWriter out = new PrintWriter(new FileWriter(file));
logic.setName(nameText.getText());
String schooldata = (String) boxForSchoolsComboBox.getSelectedItem();
String graduatedata = (String)graduateDegreeProgramComboBox.getSelectedItem();
String statedata = (String) stateComboBox.getSelectedItem();
String addressdata = addressText.getText();
String citydata = cityText.getText();
String statdata = statetext.getText();
String zipcodedata = zipcodeText.getText();
String countrycode = countryText.getText();
String countrycodedata = countrycodeText.getText();
String areacodedata = areacodeText.getText();
String phonenodata = phonenumberText.getText();
String emaildata = emailaddressText.getText();
String datebatedata = dateofbirthText.getText();
String citizendata =(String) citizenstatusComboBox.getSelectedItem();
boolean radiodata = maleButton.isSelected();
out.println(schooldata);
out.println(graduatedata);
out.println(logic.getName());
out.println(addressdata);
out.println(citydata);
out.println(statdata);
out.println(zipcodedata);
out.println(countrycode);
out.println(countrycodedata);
out.println(areacodedata);
out.println(phonenodata);
out.println(emaildata);
out.println(datebatedata);
if(radiodata == true) {
out.println("MALE");
}
else {out.println("FEMALE");}
out.close();
/**
RandomAccessFile Rfile = new RandomAccessFile("client.txt","rws");
long n =30;
n++;
Rfile.seek(file.length());
Rfile.seek(n);
Rfile.writeBytes(addressdata);
long m =20;
m++;
Rfile.seek(file.lastModified());
Rfile.seek(file.length());
Rfile.writeBytes(citydata);
Rfile.seek(file.length());
Rfile.close();
*/
}catch (IOException e1){
System.out.print("error opening file");
}
//this.launch();
}
//FORM2 CODE....
public class Form1 extends JFrame implements ActionListener {
public void actionPerformed(ActionEvent ae){}
/** Creates a new instance of Form1 */
private JLabel qualificationFormLabel,schoolLabel;
private JLabel graduationdegreeLabel,universityLabel;
private JComboBox graduateDegreeProgramComboBox,boxForSchoolsComboBox;
private JLabel gradeLabel,grescoreLabel;
private JTextField gradeText,universityText;
private JLabel testdateLabel,scoreLabel,toeflscoreLabel,detailsLabel;
private JTextField testdateText,scoreText;
private JButton submitButton;
private JPanel qualificationFormPanel;
private JPanel graduateDegreeProgramPanel,schoolPanel;
private JPanel gradePanel;
private JPanel graduategradePanel;
private JPanel grePanel,testPanel,toeflPanel,detailsPanel,submitPanel;
private JPanel generalPanel;
private Font font, fontGDP;
private String graduateDegreePrograms[] = {"Aeronautics-Astonautics", "Earth Science","Applied Physics ", "Biochemistry", "Education", "Biosciences", "Humanities and Sciences", "Engineering and Applied Sciences", "Architecture", "Law", "Nursing", "Journalism"};
private String school[] = {"Engineering", "Medicine","Law", "Social Sciences", "Humanities", "Education","Sciences"};
public Form1() {
//Set the title of the frame.
super.setTitle("QUALIFICATION DETAILS.....");
font = new Font("Roman", Font.BOLD, 15);
fontGDP = new Font("Tahoma", Font.PLAIN,12);
//Initializing the qualificationFormLabel
qualificationFormLabel = new JLabel("QUALIFICATION DETAILS");
qualificationFormLabel.setFont(font);
qualificationFormLabel.setForeground(Color.black);
qualificationFormLabel.setVisible(true);
//Initializing the qualificationFormPanel
qualificationFormPanel = new JPanel();
qualificationFormPanel.add(qualificationFormLabel);
qualificationFormPanel.setVisible(true);
//Initializing the graduationdegreeLabel
graduationdegreeLabel = new JLabel("GRADUATION DEGREE" +
" PROGRAM:");
graduationdegreeLabel.setFont(fontGDP);
graduationdegreeLabel.setForeground(Color.black);
graduationdegreeLabel.setVisible(true);
//Initializing the graduateDegreeProgramComboBox
graduateDegreeProgramComboBox = new JComboBox();
for(int count1 = 0; count1 <= 11; count1++)
{
graduateDegreeProgramComboBox.addItem(graduateDegreePrograms[count1]);
}
graduateDegreeProgramComboBox.setMaximumRowCount(4);
graduateDegreeProgramComboBox.isEditable();
graduateDegreeProgramComboBox.setVisible(true);
graduateDegreeProgramComboBox.setVisible(true);
//Initializing the gradeLabel
gradeLabel = new JLabel(" GRADE:");
gradeLabel.setFont(fontGDP);
gradeLabel.setForeground(Color.black);
gradeLabel.setVisible(true);
//Initializing the gradeText
gradeText = new JTextField(8);
gradeText.setFont(fontGDP);
gradeText.setForeground(Color.BLACK);
gradeText.setVisible(true);
//Initializing the gradePanel
gradePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
gradePanel.add(gradeLabel);
gradePanel.add(gradeText);
//Initializing the graduateDegreeProgramPanel
graduateDegreeProgramPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
graduateDegreeProgramPanel.add(graduationdegreeLabel);
graduateDegreeProgramPanel.add(graduateDegreeProgramComboBox);
graduateDegreeProgramPanel.add(gradePanel);
graduateDegreeProgramPanel.setVisible(true);
// Initializing boxForSchoolsComboBox
boxForSchoolsComboBox = new JComboBox();
for(int count = 0; count <= 6; count++)
{
boxForSchoolsComboBox.addItem(school[count]);
}
boxForSchoolsComboBox.setMaximumRowCount(3);
boxForSchoolsComboBox.isEditable();
boxForSchoolsComboBox.setVisible(true);
// Initializing schoolLabel
schoolLabel = new JLabel("School:");
schoolLabel.setFont(fontGDP);
schoolLabel.setForeground(Color.BLACK);
schoolLabel.setVisible(true);
//Initializing the universityLabel
universityLabel = new JLabel(" UNIVERSITY:");
universityLabel.setFont(fontGDP);
universityLabel.setForeground(Color.BLACK);
universityLabel.setVisible(true);
//Initiallizing the universityText
universityText = new JTextField(15);
universityText.setFont(fontGDP);
universityText.setForeground(Color.BLACK);
universityText.setVisible(true);
// Initializing the schoolPanel
schoolPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
schoolPanel.add( schoolLabel);
schoolPanel.add(boxForSchoolsComboBox);
schoolPanel.add(universityLabel);
schoolPanel.add(universityText);
// Initializing grescoreLabel
grescoreLabel = new JLabel("GRADUATE RECORD EXAMINATION(GRE)SCORES:");
grescoreLabel.setFont(font);
grescoreLabel.setForeground(Color.BLACK);
grescoreLabel.setVisible(true);
// Initializing the grePanel
grePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
grePanel.add(grescoreLabel);
// Initializing testdateLabel
testdateLabel = new JLabel("TESTDATE:");
testdateLabel.setFont(fontGDP);
testdateLabel.setForeground(Color.BLACK);
testdateLabel.setVisible(true);
//Initiallizing the testdateText
testdateText = new JTextField(15);
testdateText.setFont(fontGDP);
testdateText.setForeground(Color.BLACK);
testdateText.setVisible(true);
// Initializing scoreLabel
scoreLabel = new JLabel(" SCORE(%):");
scoreLabel.setFont(fontGDP);
scoreLabel.setForeground(Color.BLACK);
scoreLabel.setVisible(true);
//Initiallizing the scoreText
scoreText = new JTextField(15);
scoreText.setFont(fontGDP);
scoreText.setForeground(Color.BLACK);
scoreText.setVisible(true);
// Initializing the testPanel
testPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
testPanel.add(testdateLabel);
testPanel.add(testdateText);
testPanel.add(scoreLabel);
testPanel.add(scoreText);
// Initializing toeflscoreLabel
toeflscoreLabel = new JLabel("TOEFL SCORE (IF REQUIRED):");
toeflscoreLabel.setFont(fontGDP);
toeflscoreLabel.setForeground(Color.BLACK);
toeflscoreLabel.setVisible(true);
//Initiallizing the scoreText
scoreText = new JTextField(35);
scoreText.setFont(fontGDP);
scoreText.setForeground(Color.BLACK);
scoreText.setVisible(true);
// Initializing the toeflPanel
toeflPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
toeflPanel.add(toeflscoreLabel);
toeflPanel.add(scoreText);
// Initializing detailsLabel
detailsLabel = new JLabel("DETAILS OF RECENT HONORS AND AWARDS:");
detailsLabel.setFont(fontGDP);
detailsLabel.setForeground(Color.BLACK);
detailsLabel.setVisible(true);
//Initiallizing the scoreText
scoreText = new JTextField(50);
scoreText.setFont(fontGDP);
scoreText.setForeground(Color.BLACK);
scoreText.setVisible(true);
// Initializing the detailsPanel
detailsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
detailsPanel.add(detailsLabel);
detailsPanel.add(scoreText);
//Initializing the submitButton
submitButton = new JButton("SUBMIT:");
submitButton.setVisible(true);
//Initializing the buttonHandler
ButtonHandler2 button = new ButtonHandler2();
submitButton.addActionListener(button);
//Initializing the submitPanel
submitPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
submitPanel.add(submitButton);
generalPanel = new JPanel(new GridLayout(8,7,0,0));
generalPanel.add(qualificationFormPanel);
generalPanel.add(graduateDegreeProgramPanel);
generalPanel.add(schoolPanel);
generalPanel.add(grePanel);
generalPanel.add(testPanel);
generalPanel.add(toeflPanel);
generalPanel.add(detailsPanel);
generalPanel.add(submitPanel);
generalPanel.setVisible(true);
add(generalPanel);
}
class ButtonHandler2 implements ActionListener,Serializable {
public void actionPerformed(ActionEvent e) {
File file = new File("client2.txt");
try {
PrintWriter out = new PrintWriter(new FileWriter(file));
String graduatedata = (String)graduateDegreeProgramComboBox.getSelectedItem();
String gradedata = gradeText.getText();
String universitydata = universityText.getText();
String boxForSchoolsdata = (String) boxForSchoolsComboBox.getSelectedItem();
String testdatedata = testdateText.getText();
String scoredata = scoreText.getText();
out.println(graduatedata);
out.println(gradedata);
out.println(universitydata);
out.println(boxForSchoolsdata);
out.println(testdatedata);
out.println(scoredata);
out.close();
}catch (IOException i) {
System.out.println("AN ERROR HAS OCCURRED!!!");
}
}