package myframemain;
import java.awt.*;
import javax.swing.*;
public class MyFrame extends JFrame {
JLabel lblOval;
JLabel lblX;
JLabel lblY;
JLabel lblWidth;
JLabel lblHeight;
JLabel lblRectangle;
JLabel lblX1;
JLabel lblY1;
JLabel lblX2;
JLabel lblY2;
JLabel lblColor;
JLabel lblNumberOfShapes;
JTextField txtX;
JTextField txtY;
JTextField txtWidth;
JTextField txtHeight;
JTextField txtX1;
JTextField txtY1;
JTextField txtX2;
JTextField txtY2;
JButton btnAddOval;
JButton btnAddRectangle;
JButton btnAddBoth;
JButton btnClear;
JButton btnExit;
JRadioButton radRed;
JRadioButton radGreen;
JRadioButton radBlue;
JComboBox cboNumber;
JPanel northPanel;
JPanel centrePanel;
JPanel southPanel;
public MyFrame()
{
setSize(700, 500);
setTitle("Welcome");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(5,5,5,5);
lblOval = new JLabel("Oval");
lblX = new JLabel("X");
lblY = new JLabel("Y");
lblWidth = new JLabel("Width");
lblHeight = new JLabel("Height");
lblRectangle = new JLabel("Rectangle");
lblX1 = new JLabel("X1");
lblY1 = new JLabel("Y1");
lblX2 = new JLabel("X2");
lblY2 = new JLabel("Y2");
lblColor = new JLabel("Color");
lblNumberOfShapes = new JLabel("Number of shapes");
txtX = new JTextField("",5);
txtY = new JTextField("",5);
txtWidth = new JTextField("",5);
txtHeight = new JTextField("",5);
txtX1 = new JTextField("",5);
txtY1 = new JTextField("",5);
txtX2 = new JTextField("",5);
txtY2 = new JTextField("",5);
btnAddOval = new JButton("Add Oval");
btnAddRectangle = new JButton("Add Rectangle");
btnAddBoth = new JButton("Add Both");
btnClear = new JButton("Clear");
btnExit = new JButton("Exit");
radRed = new JRadioButton("RED");
radGreen = new JRadioButton("GREEN");
radBlue = new JRadioButton("BLUE");
cboNumber = new JComboBox();
northPanel = new JPanel(new GridBagLayout());
centrePanel = new JPanel();
southPanel = new JPanel();
cboNumber.addItem("1");
cboNumber.addItem("2");
cboNumber.addItem("3");
cboNumber.addItem("4");
cboNumber.addItem("5");
cboNumber.addItem("6");
cboNumber.addItem("7");
cboNumber.addItem("8");
cboNumber.addItem("9");
cboNumber.addItem("10");
cboNumber.setSelectedItem("1");
northPanel.add(lblOval, gbc);
gbc.gridx = 0;
gbc.gridy = 0;
northPanel.add(lblX, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
northPanel.add(txtX, gbc);
gbc.gridx = 2;
gbc.gridy = 0;
northPanel.add(lblY, gbc);
gbc.gridx = 3;
gbc.gridy = 0;
northPanel.add(txtY, gbc);
gbc.gridx = 4;
gbc.gridy = 0;
northPanel.add(lblWidth, gbc);
gbc.gridx = 5;
gbc.gridy = 0;
northPanel.add(txtWidth, gbc);
gbc.gridx = 6;
gbc.gridy = 0;
northPanel.add(lblHeight, gbc);
gbc.gridx = 7;
gbc.gridy = 0;
northPanel.add(txtHeight, gbc);
gbc.gridx = 8;
gbc.gridy = 0;
northPanel.add(btnAddOval, gbc);
gbc.gridx = 9;
gbc.gridy = 0;
northPanel.add(lblRectangle, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
northPanel.add(lblX1, gbc);
gbc.gridx = 1;
gbc.gridy = 1;
northPanel.add(txtX1, gbc);
gbc.gridx = 2;
gbc.gridy = 1;
northPanel.add(lblY1, gbc);
gbc.gridx = 3;
gbc.gridy = 1;
northPanel.add(txtY1, gbc);
gbc.gridx = 4;
gbc.gridy = 1;
northPanel.add(lblX2, gbc);
gbc.gridx = 5;
gbc.gridy = 1;
northPanel.add(txtX2, gbc);
gbc.gridx = 6;
gbc.gridy = 1;
northPanel.add(lblY2, gbc);
gbc.gridx = 7;
gbc.gridy = 1;
northPanel.add(txtY2, gbc);
gbc.gridx = 8;
gbc.gridy = 1;
northPanel.add(btnAddRectangle, gbc);
gbc.gridx = 9;
gbc.gridy = 1;
northPanel.add(lblColor, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
northPanel.add(radRed, gbc);
gbc.gridx = 1;
gbc.gridy = 2;
northPanel.add(radGreen, gbc);
gbc.gridx = 2;
gbc.gridy = 2;
northPanel.add(radBlue, gbc);
gbc.gridx = 3;
gbc.gridy = 2;
northPanel.add(lblNumberOfShapes, gbc);
gbc.gridx = 4;
gbc.gridy = 2;
northPanel.add(cboNumber, gbc);
gbc.gridx = 5;
gbc.gridy = 2;
northPanel.add(btnAddBoth, gbc);
gbc.gridx = 6;
gbc.gridy = 2;
getContentPane().add(northPanel, BorderLayout.NORTH);
centrePanel.setBackground(Color.BLUE);
add(centrePanel, BorderLayout.CENTER);
southPanel.add(btnClear);
southPanel.add(btnExit);
add(southPanel, BorderLayout.SOUTH);
}
}