I’m currently trying to create what I thought was going to be an easy Java program. I want to create a GUI that prompts the user to enter the day of the week and will spit out the chores they have to do that day. I also wanted check boxes next to the chores to be able to mark off what is completed. I can get the code to run fine in the console window (minus the check boxes obviously) but I don’t know how to make my code run on the JFrame I created. I know there is also a way to add labels, buttons, textboxes, etc. without actually writing the code and just plotting them on the JFrame, but I can’t get my frame to appear without running the code, so it’s not editable.

This is where my code sits so far:
/**

  • @author AMoore
  • @date 4/4/24
  • The purpose of this program is to prompt a user to enter a day of the week, give them the daily chores, and allow them to check them off.

*/

import java.util.Scanner;
import javax.swing.JFrame;

public class ChoreChartBuilder {

JFrame frame;

public ChoreChartBuilder() {
    initComponenent();
}

public void initComponenent() {
    frame = new JFrame("Daily Chore Chart");
    frame.setSize(600,600);
    frame.setVisible(true);
}

public static void main(String[] args) {
    new ChoreChartBuilder();
    
    Scanner input = new Scanner(System.in);
    
    String mon = "Monday";
    String tue = "Tuesday";
    String wed = "Wednesday";
    String thu = "Thursday";
    String fri = "Friday";
    String sat = "Saturday";
    String sun = "Sunday";
    
    System.out.println("");
    System.out.println("Please enter the day of the week: ");
    
    String day = input.nextLine();
    
    input.close();
    
    if (day.equalsIgnoreCase(mon)) {
        System.out.println("Monday Chores: ");
    }
    else if (day.equalsIgnoreCase(tue)) {
        System.out.println("Tuesday Chores: ");
    }
    else if (day.equalsIgnoreCase(wed)) {
        System.out.println("Wednesday Chores: ");
    }
    else if (day.equalsIgnoreCase(thu)) {
        System.out.println("Thursday Chores: ");
    }
    else if (day.equalsIgnoreCase(fri)) {
        System.out.println("Friday Chores: ");
    }
    else if (day.equalsIgnoreCase(sat)) {
        System.out.println("Saturday Chores: ");
    }
    else if (day.equalsIgnoreCase(sun)) {
        System.out.println("Sunday Chores: ");
    }
    else {
        System.out.println("A day of the week was not entered. Goodbye.");
    }


}

}

New contributor

abbey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.