How would I complete the WholePanel? I am very confused on what more I need to a
ID: 3652595 • Letter: H
Question
How would I complete the WholePanel? I am very confused on what more I need to add.import java.awt.*;
import javax.swing.*;
import java.awt.event.*; // to use listener interfaces
import javax.swing.JPanel;
public class WholePanel extends JPanel
{
private Color currentColor;
private int currentWidth, currentHeight;
private CanvasPanel canvas;
private JPanel menuPanel;
private JCheckBox fillCheck;
private int x1, y1;
public WholePanel()
{
//white is the default color
currentColor = Color.WHITE;
//default x-y cooridnate, width, and height of a rectangle
currentWidth = currentHeight = 100;
x1 = 100; y1 = 100;
fillCheck = new JCheckBox("Filled");
menuPanel = new JPanel();
menuPanel.add(fillCheck);
canvas = new CanvasPanel();
JSplitPane sPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, menuPanel, canvas);
setLayout(new BorderLayout());
add(sPane, BorderLayout.CENTER);
//to be completed
}
Explanation / Answer
I think the best way to go is by using a paint() method. Paint is called whenever the program is run and u can call it again whenever u want by using repaint(). After creating all the required objects(panels,checkboxes),write the paint method and call whatever object u want to use.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.