I am creating a little combobox menu for my ap comp sci project. This is my first time working with GUI so I am still familiarizing myself with it. I have a menu class and a few other classes that run mostly void methods to do simple things like calculate GPA, etc. My menu is working fine (at least I think so). However, when I select my first item in the menu (I only have one actionlistener at the moment but I will add more after) the actionlistener runs the void method (run()) and it opens the window. But after that nothing happens. I have user input in that method to type in grade percentages, etc, and it works when i run the method directly from the class. But I can't type or seem to have any input when the actionlistener runs it. Thank you for your time and help!
package First_Semester_Project;
import java.awt.Color;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Menu extends GradeCalculator
{
String [] info = {"Grade Calculator", "Spanish Conjugator", "Period Table of Elements", "Sentence Compiler"};
JLabel l= new JLabel("Welcome to the Resource Library!");
JComboBox c = new JComboBox(info);
JButton b = new JButton ("Select Resource");
public Menu ()
{
frame();
}
public void frame ()
{
JFrame f = new JFrame ("Resource Library");
l.setForeground(Color.white);
l.setFont(new Font("Arial", Font.BOLD, 16));
f.setSize(600,90);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.setBackground(Color.gray);
p.add(c);
p.add(b);
p.add(l);
f.add(p);
b.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e ){
String s = c.getSelectedItem().toString();
//l.setText(s);
if (s.equals("Grade Calculator"))
{
run();
}
else if (s.equals("travel time"))
{
l.setText(s);
}
}
});
}