Question: import java.awt.*; import java.awt.event.*; import javax.swing.*; //creating public class for shape panel public class ShapePanel extends JPanel{ private Shape[]shapes; private DrawingPanel darwPanel; private JPanel controlPanel;
import java.awt.*; import java.awt.event.*; import javax.swing.*;
//creating public class for shape panel public class ShapePanel extends JPanel{ private Shape[]shapes; private DrawingPanel darwPanel; private JPanel controlPanel; private JButton addShape; private JTextField showNum; private JLabel countLabel; int count; public ShapePanel{ } public static void main(String[]args){ JFrame frame = new JFrame("ShapePanel"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//Default close button frame.setPack; frame.setVisible("true"); } }
on above program i need to add following things can any one help for this.
-write a shapepanel constructor which creates a new JPanel called controlPanel.Creates 3 data fields:a JButton(labelled "Add shape"),a JTextField with room for two digits,and JLabel showing "count".The JButton will need an actionListener added,so write an actionPerformed method,which can be an empty method for now.In the ShapePanel constructor,create a new instance of ButtonLinstener and add it to the button.
- Set the preferred size of the controlpanel to dimension 200 by 500 pixeles.
-Add button,label and text field to controlPAnel and add controlpanel to shapepanel.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
