shikharana 0 Newbie Poster

Hi. I'm having alot of trouble completing this part of my assignment. can u please help me with it

the ques is :
Implement the following buttons: Rect, Oval, Image, Colour, and Clear. You do not need to have the Text button or its associated textField.

Your Rect, Oval, and Image buttons only need to work when the user drags from the top-left corner to the bottom-right corner, and the Rect and Oval only should only draw solid shapes.
Make the Rect, Oval, and Image buttons work when the user drags from any corner. (Hint: given the two points, work out the values of left, top, width, and height.)

Make the Fill/NoFill button work, so that drawing rectangles and ovals will be filled or outline, depending on the Fill/NoFill button.

Implement the Text button and its associated textfield.

Add a Bubbles button which, when the user clicks at a point, draws a stream of bubbles, rising from that point to the top of the screen. The bubbles should increase in size as they go up.

Could you please complete this.

import java.util.*;
import comp100.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.io.*;

public class MiniPaint implements ActionListener, MouseListener{

    private JFrame frame = new JFrame("MiniPaint");
    private DrawingCanvas canvas = new DrawingCanvas();
    private JTextArea textOutput = new JTextArea(30, 15);
    private JTextField textBox;



    // fields to remember the current shape, whether filled or not
    // the position the mouse was pressed, and the JTextField
    // YOUR CODE HERE

    public MiniPaint(){
    frame.setSize(800,600);
    frame.getContentPane().add(canvas, BorderLayout.CENTER);
    canvas.addMouseListener(this);
    frame.getContentPane().add(textOutput, BorderLayout.EAST);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel, BorderLayout.NORTH);

    but.addActionListener(this);
    panel.add(but);
    this.textBox = new JTextBox();
    panel.add(this.textBox());
    // YOUR CODE HERE
    frame.setVisible(true);
    }

    private JButton addButton(String name, JPanel panel){
    JButton button = new JButton(name);
    button.addActionListener(this);  
    panel.add(button);
    return button;
    }


    /* Respond to button presses */
    public void actionPerformed(ActionEvent e){
    String cmd = e.getActionCommand();
    // YOUR CODE HERE
    else if (cmd.equals("Quit") ){
        frame.dispose();
    }
    }

    // Respond to mouse events
    public void mousePressed(MouseEvent e) {
    // YOUR CODE HERE
    }

    public void mouseReleased(MouseEvent e) {
    // YOUR CODE HERE
    }

    public void mouseClicked(MouseEvent e) {}//needed to satisfy interface
    public void mouseEntered(MouseEvent e) {}  //needed to satisfy interface
    public void mouseExited(MouseEvent e) {}   //needed to satisfy interface


    /* Helper methods for drawing the shapes, if you choose to define them */
    // YOUR CODE HERE

  // Main:  constructs new MiniPaint object
  public static void main(String[] arguments){
    MiniPaint ob = new MiniPaint();
  } 


}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.