Hello, I'm in a pickle.
(Please observe the code) In the actionPerformed method, I don't know how I can get the value of the variable 'minutes'.
I can get 'hours' by e.getActionCommand(), but can't do minutes that way. I need to get both 'hours' and 'minutes' at the same action.
Please help.
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JLabel;
public class OuterClass extends JFrame{
private JLabel hours;
private JLabel minutes;
public OuterClass(){
hours = new JLabel("Hours?");
minutes = new JLabel("Minutes?");
add(hours);
add(minutes);
InnerClass actionHandler = new InnerClass();
hours.addActionListener(actionHandler);
minutes.addActionListener(actionHandler);
}
private class InnerClass implements ActionListener{
public void actionPerformed(ActionEvent e){
String output = "";
String minutes = "";
if(e.getSource() == hours){
output = e.getActionCommand();
minutes = // ??????? How do I get the minutes here??
}
}
}
}