Answered step by step
Verified Expert Solution
Link Copied!

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 JComboBox fractalChooser; /** * 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

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

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions