Question: I've tried writing the code for this question and keep on getting stuck. I need some help. Thank you! 5. The program Boxes (JMCh16Exercises Boxes
I've tried writing the code for this question and keep on getting stuck. I need some help. Thank you!




5." The program Boxes (JM\\Ch16\\Exercises \\Boxes . java) can display different types of boxes (rectangles) in different colors. The user chooses the color of the box from a "combo box" that shows all 13 predefined colors from the Color class. The user sets the box type by checking option boxes for filled, rounded, and 3-D rectangles. The box type is represented as an integer in which individual bits, when set to 1, indicate the attributes: bit 0 for filled, bit 1 for rounded, and bit 2 for 3-D. For example, the value 3 (binary 011) indicates a filled rounded box with no 3-D effect. The Boxes program relies on a BoxDrawer class derived from JPanel. It has the additional methods setBoxType (int boxType) , nolog setBoxColor (Color color), and drawBox (Graphics g). BoxDrawer also redefines the paintComponent method to repaint the background and call drawBox. Write the BoxDrawer class. Set the background to gray or black in paintComponent if the white color is chosen. Display an error message instead of a box if both rounded and 3-D attributes are selected. : Hint: use a switch on the box type in drawBox. :import java. awt. Color; import java. awt . Container; import java. awt . BorderLayout; 6 import java. awt . event . ActionListener; import java. awt . event . ActionEvent; 8 import javax. swing . JFrame; 19 import javax. swing. JPanel; 10 import javax. swing. JComboBox; import javax. swing . JCheckBox; public class Boxes extends JFrame implements ActionListener 5 6 private BoxDrawer canvas; private JComboBox
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
