I've created a gui for the day of the week program. The problem that I'm having is adding functionality to this program. I would like this program to allows a user to select a month and day from choice menus, and enter a year in a text field. Whenever the user chooses a month, then a day choice from each choice menu and presses Enter in the year field, the program will attempt to calculate the day of the week. If the year field contains a valid integer, the program will display the day of the week in the lower part of the frame. An error should appear in the lower part of the frame if the year is not a valid integer. Notify the user if they make an invalid month and day choice, such as February 30.

I know to use this:
Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25);
int dayOfWeek = xmas.get(Calendar.DAY_OF_WEEK); // 6=Friday

import java.awt.*;
import javax.swing.*;

public class DayOfWeek {
	//Instance variables
	private JTextField field;
	private JFrame frame;
	private JComboBox box1;
	private JComboBox box2;
	private JLabel month;
	private JLabel day;
	private JLabel year;
	private String[] months = {"January", "February", "March", "April",
			"May", "June", "July", "August", "September", "October", 
			"November", "December"};
	private String[] days = {"Sunday", "Monday", "Tuesday", "Wednesday", 
							"Thursday", "Friday", "Saturday"};
	private FlowLayout flowLayout;
	public DayOfWeek()
	 * This method knows where to put everything in the panel.
	private void layoutComponents()
		Container container = frame.getContentPane();
		flowLayout = new FlowLayout();
		container.add(setsPanel(), "Day Of Week");
	 * This method adds everything to the panel.
	private JPanel setsPanel()
		JPanel container = new JPanel(new FlowLayout());
		return container;
	 * Shows the frame.
	public void setVisible(boolean vis)
	 * This method puts together the
	 * month, day, and year label for the frame.
	 * It also ties the comboboxes with the arrays
	 * of string, and sets up the text field.
	private void makeComponents()
		frame = new JFrame("Day of Week");
		month = new JLabel("Month: ");
		box1 = new JComboBox(months);
		day = new JLabel("Day: ");
		box2 = new JComboBox(days);
		year = new JLabel("Year: ");
		field = new JTextField(10);
	public static void main(String[] args)
		DayOfWeek dow = new DayOfWeek();

Where is the "Day of the Week" value to be displayed?
Your current GUI doesn't have anywhere to display it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.