Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA - Write a program that draws a Sudoku board with buttons, combobox on the side, and a text area at the bottom for output

JAVA - Write a program that draws a Sudoku board with buttons, combobox on the side, and a text area at the bottom for output messages. The board is a 9 x 9 square, (9 3x3 squares.) Each smaller square is set off by a heavier border than the regular intersquare borders. Each square is a text field. The user is able to type an integer number (range from 0-9). First level panel implemented as the Frame: embeds SudokuLavout class (a panel) Reset (button buttonPanel: gridPanel: GridLayaut(3, 0) Text Area (embeds to SudokuLayout directly) Requirements 1.) Use two classes to implement the application: an application class named TestSudoku and a work class named SudokuLayout. The SudokuLayout class (itself is a child of panel) is the first layer panel. Dimension for this panel should be (450, 350). At the bottom of the Sudoku, there is a text area. This gadget has certain size. Use... txtArea = new JTextArea(4, 20); add(txtArea, BorderLayout.SOUTH); The frame embeds this panel as the first level organizer. The layout managers used by each panel should be the ones indicated in the diagram. Set borders for some containers as indicated in diagram. Use two for loops to draw the text fields instead of brute-force of listing 81 text fields. It should be something like: for (int k = 1; k <= 9; k++){ JPanel level2 = new JPanel(); . for (int i = 1; i <= 9; i++){ JTextField text = new JTextField(); } gridPanel.add(level2); } For the Combobox, set Hard as its initial selected item (using program code). 2.) Add the following visual gadgets and write listeners for them. These gadgets are... ***Button Reset---when the button is clicked, the program will clear the text area, then output the string Reset button clicked! to the text area. ***Button Hint---when the button is clicked, the program will clear the text area, then output the string Hint button clicked! to the text area. Use a text area as an output gadget. Use a titled border to single out the gadget. The caption text is Output Area. The code shows how to do this and use the text area to display a message. JTextArea jtxtar = new JTextArea(30, 20); Jtxtar.setBorder(BorderFactory.creatTitledBOrder(Output Area)); jtxtar.setText(Hello world!); ***Combobox Difficulty---when an item is selected, the program will clear the text area, then output the selected item name to the text area. use the setSelectedIndex() method String[] difficulties = { Easy, Medium, Hard }; //Create the combo box, select item at index 1. //Indices start at 0, so 1 specifies Medium. JComboBox difficultyBox = new JComboBox(difficulties); difficultyBox.setSelectedIndex(1); To add items to the combobox, you can do one at a time, like: JComboBox jCmb = new JComboBox(); jCmb.addItem(Hat); Or in a batch mode String[] difficulties = { Easy, Medium, Hard }; JComboBox difficultyBox = new JComboBox(difficulties); 3.) Add the listeners using loosely coupled methods (private listener class or private adapter class). The borders around the game board, around the 3x3 sections, and around each individual square, are important. Follow the requirement. Show transcribed image text

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

=+b) Discuss whether the display is appropriate for the data.

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago