Hey so I've been working on a lab for my intro to software developing class and have been trying to get my program to work for several days now. It's a real basic program, im sure someone will be able to figure out the issue im having. Hopefully once I learn what I'm doing I'll be able to return the favor, but until then thanks, heres the code.
Right now there are no errors indicated by Eclipse, is it only a syntax error then, i feel like im missing something.
package lab8;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
@SuppressWarnings("serial")
public class GUIMonthNames extends JFrame implements ActionListener {
private JLabel instructions;
private JTextField data;
public GUIMonthNames() {
super("Month Names: GUI version");
setSize(400,400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container myPane = getContentPane();
myPane.setLayout(new FlowLayout());
instructions = new JLabel("Enter a number (1-12) below");
data = new JTextField(20);
add(data);
data.addActionListener(this);
add(instructions);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent arg0) {
int monthNumber = new Integer(data.getText());
Scanner keyboard = new Scanner(System.in);
monthNumber = keyboard.nextInt();
final String MONTH_TABLE = "January February March April May June " +
"July August SeptemberOctober November December ";
int start = (monthNumber - 1) * 9;
int stop = start + 9;
String monthName = MONTH_TABLE.substring(start, stop);
data.setText(monthNumber + " is '" + monthName.trim() + "'.");
}
public static void main(String[] args) {
new GUIMonthNames();
}
}