help with variables please
I am doing a dossier for my IB computer Science Class (Standard level). My program helps the user to decide what type of dossier they should do if they are staying for the second year of the IB. It is very simple. Consists of only 3 combo boxes and 6 window frames. It is a GUI program. I need help making the selections on my combo boxes variables and then send them to another listener to make a multi-dimensional array and then print that onto my results frame. Here is my code, please help.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.Math;
public class Dosier {
JFrame frame1, frame2, frame3, frame4, frame5, frame6;
JPanel contentPane1,contentPane2, contentPane3, contentPane4, contentPane5, contentPane6;
JScrollPane scroll;
JTextArea area, res;
JComboBox subjects, hobbies, preference;
JLabel instruc, test2, prompt1, prompt2, que1, que2, par, d, result;
JTextField name, level;
JButton topic, test, finish, done, results, pic, next;
public Dosier() {
.............
...........
frame4 = new JFrame("Test");/*creates a new window for the test*/
frame4.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
contentPane4 = new JPanel();
contentPane4.setLayout(new GridLayout(0, 2, 10, 5));
contentPane4.setBorder(BorderFactory.createEmptyBo rder(10, 10, 10, 10));
test2 = new JLabel("subjects");
test2.setAlignmentX(JLabel.CENTER_ALIGNMENT);
test2.setBorder(BorderFactory.createEmptyBorder(20 , 50, 20, 50));
contentPane4.add(test2);
String [] subs = {"mathematics", "sciences", "languages", "arts"};/*creates arrays for the combo box*/
subjects = new JComboBox(subs);/*creates a combo box*/
subjects.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
subjects.setSelectedIndex(0);
subjects.addActionListener(new subjectsListener());/*creates a listener for combo box*/
contentPane4.add(subjects);
que1 = new JLabel("hobbies");
que1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
que1.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50));
contentPane4.add(que1);
String [] hobs = {"sports", "music", "drawing", "other"};
hobbies = new JComboBox(hobs);
hobbies.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
hobbies.setSelectedIndex(0);
hobbies.addActionListener(new hobbiesListener());
contentPane4.add(hobbies);
que2 = new JLabel("dossier general ideas");
que2.setAlignmentX(JLabel.CENTER_ALIGNMENT);
que2.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50));
contentPane4.add(que2);
String [] dos = {"data based", "educational", "games"};
preference = new JComboBox(dos);
preference.setAlignmentX(JComboBox.LEFT_ALIGNMENT) ;
preference.setSelectedIndex(0);
preference.addActionListener(new preferenceListener());
contentPane4.add(preference);
results = new JButton("My results");/*creates a button to direct the user to the4 results window*/
results.setAlignmentX(JButton.CENTER_ALIGNMENT);
results.addActionListener(new resultsListener());
contentPane4.add(results);
frame4.setContentPane(contentPane4);
frame4.pack();
frame4.setVisible(false);
.........
........
class subjectsListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
JComboBox cBox = (JComboBox)event.getSource();
String subjects = (String)cBox.getSelectedItem();
if(subjects.equals("mathematics")){
final String variable1 = subjects;
}else if(subjects.equals("sciences")){
final String variable1 = subjects;
}else if(subjects.equals("languages")){
final String variable1 = subjects;
}else if(subjects.equals("arts")){
final String variable1 = subjects;
}
}
}
class hobbiesListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
JComboBox hBox = (JComboBox)event.getSource();
String hobbies = (String)hBox.getSelectedItem();
if(hobbies.equals("sports")){
final String variable2 = hobbies;
}else if(hobbies.equals("music")){
final String variable2 = hobbies;
}else if(hobbies.equals("drawing")){
final String variable2 = hobbies;
}else if(hobbies.equals("other")){
final String variable2 = hobbies;
}
}
}
class preferenceListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
JComboBox pBox = (JComboBox)event.getSource();
String preference = (String)pBox.getSelectedItem();
if(preference.equals("data based")){
final String variable3 = preference;
}else if(preference.equals("educational")){
final String variable3 = preference;
}else if(preference.equals("games")){
final String variable3 = preference;
}
}
}
/*allows user to end the program*/
class doneListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
String done = event.getActionCommand();
if(done.equals("Done")){
frame3.setVisible(false);
frame4.setVisible(true);
}
}
}
class resultsListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
String results = event.getActionCommand();
//final String[][]dossiers = new String[12][4];
if(results.equals("My results")){
setLabel(result);
/*for (int i=0 ; i<12; i++){
if((variable1.equals(dossier[i][1]) || vairable2.equals(dossier[i][1])) && variable3.equals(dossier[i][1])){
results[next]= dossiers[i][0];
next ++;
}
//do search
//add results to results frame
*/
frame4.setVisible(false);
frame2.setVisible(true);
frame5.setVisible(true);
//}return results;
}
}
}