Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java - IntelliJ Complete the tasks with the accompanied java class Fractals TODO: Add cantorPane and others to fractalCards, using the CANTOR, CIRCLE, etc. constants
Java - IntelliJ
Complete the tasks with the accompanied java class Fractals
TODO: Add cantorPane and others to fractalCards, using the CANTOR, CIRCLE, etc. constants // e.g., fractalCards.add(cantorPane, CANTOR); (4 lines)
TODO: Create fractalChooser combo box (field already declared above) with allFractals as its choices (1 line)
// TODO: Add a ComboListener to the fractalChooser combo box (listener class already defined below) (1 line)
Class: FractalDriver
package fractal; import java.awt.*; import java.awt.event.*; import javax.swing.*; /** */ public class FractalDriver { private static final int WIDTH = 350; private static final int HEIGHT = 300; private static final String CANTOR = "Cantor"; private static final String CIRCLE = "Circle"; private static final String MANDELBROT = "Mandelbrot"; private static final String SIERPINSKI = "Sierpinski"; private static final String[] allFractals = {CANTOR, CIRCLE, MANDELBROT, SIERPINSKI}; private JFrame frame; private CardLayout cardLayout; private JPanel fractalCards; private JComboBoxfractalChooser; /** * Create a FractalDriver */ public FractalDriver() { makeFrame(); } /** * Create the FractalDriver GUI */ private void makeFrame() { frame = new JFrame("Fractals!"); frame.setSize(WIDTH, HEIGHT); frame.setLayout(new BorderLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); createContents(); frame.setVisible(true); } /** * Create the contents of the main window * A combo box at the top controls selection of which fractal panel is displayed */ private void createContents() { JScrollPane cantorPane = new JScrollPane(new CantorPanel(6)); // TODO: Add cantorPane and others to fractalCards, using the CANTOR, CIRCLE, etc. constants // e.g., fractalCards.add(cantorPane, CANTOR); (4 lines) // TODO: Create fractalChooser combo box (field already declared above) with allFractals as its choices (1 line)
// TODO: Add a ComboListener to the fractalChooser combo box (listener class already defined below) (1 line)
frame.add(cantorPane, BorderLayout.CENTER); // TODO: Remove this line once the rest is set up } /** * Listen to the combo box and switch the displayed fractal when the selection changes */ private class ComboListener implements ActionListener { public void actionPerformed(ActionEvent e) { } } public static void main(String[] args) { new FractalDriver(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started