Homework Help Question & Answers

Task: Write a Java program to implement a simple graph editor that can be used to...

Task: Write a Java program to implement a simple graph editor that can be used to draw a circumcircle. The editor has a pull-

2.6. Write a program that draws the circumscribed circle (also known as the circumcircle) of a given triangle ABC; this circl

Task: Write a Java program to implement a simple graph editor that can be used to draw a circumcircle. The editor has a pull-down menu on top of the screen with 2 buttons: "Circumcircle" and "Quit". 1) When the user selects "Circumcircle", he/she can draw a circumcircle on the screen as described in Exercise 2.6 on page 59 of the textbook. 2) The editor terminates/quits execution if the user selects "Quit" from the pull- down menu. 3) The editor has a horizontal and a vertical sliding bar that when slided, moves the circumcircle on the canvas accordingly. (Bonus - 5 points)
2.6. Write a program that draws the circumscribed circle (also known as the circumcircle) of a given triangle ABC; this circle passes through the points A, B and C. These points will be specified by the user by clicking the mouse button. Remember, the three perpendicular bisectors of the three edges of a triangle all pass through one point, the circumcenter, which is the center of the circumscribed circle.
0 0
Add a comment
Answer #1

import java.awt.*;
import java.awt.event.*;
public class M extends MyFrame
{
public static void main(String args[])
{
MyFrame frame = new MyFrame();
frame.show();
}
}
class MyFrame extends Frame implements ActionListener, MouseListener
{
     Frame frame;
MenuItem exitItem;  
public MyFrame()
{
  
         MenuBar mb=new MenuBar();
         Menu menu=new Menu("Menu");
         MenuItem i1=new MenuItem("Circumcircle");
         MenuItem i2=new MenuItem("Exit");
        i2.addActionListener(this);
       menu.add(i1);
         menu.add(i2);
         mb.add(menu);
         setMenuBar(mb);
         setSize(400,400);
         setLayout(null);
         setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("Circumcircle"))
{
    repaint();
}
if(ae.getActionCommand().equals("Exit"))
{
   System.exit(0);
}}

    public void paint(Graphics g)
{

      int xPoints[] = {100,190,40,100};
      int yPoints[] = {60,110,110,60};
    
      g.setColor(Color.RED);
      g.drawPolygon(xPoints, yPoints, 4);

    g.drawOval(40,60,150,100);    
      g.setColor(Color.BLUE);
          }

public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mousePressed(MouseEvent e){}
}

Code:- Screenshot:-

M - Notepad Eile Edit Format View Help import java.awt.*; import java.awt.event.*; public class M extends MyFrame { public st

output:-

x Menu Circumcircle Exit


answered by: ANURANJAN SARSAM
Add a comment
Answer #2

import java.awt.*;
import java.awt.event.*;
public class M extends MyFrame
{
public static void main(String args[])
{
MyFrame frame = new MyFrame();
frame.show();
}
}
class MyFrame extends Frame implements ActionListener, MouseListener
{
     Frame frame;
MenuItem exitItem;  
public MyFrame()
{
  
         MenuBar mb=new MenuBar();
         Menu menu=new Menu("Menu");
         MenuItem i1=new MenuItem("Circumcircle");
         MenuItem i2=new MenuItem("Exit");
        i2.addActionListener(this);
       menu.add(i1);
         menu.add(i2);
         mb.add(menu);
         setMenuBar(mb);
         setSize(400,400);
         setLayout(null);
         setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("Circumcircle"))
{
    repaint();
}
if(ae.getActionCommand().equals("Exit"))
{
   System.exit(0);
}}

    public void paint(Graphics g)
{

      int xPoints[] = {100,190,40,100};
      int yPoints[] = {60,110,110,60};
    
      g.setColor(Color.RED);
      g.drawPolygon(xPoints, yPoints, 4);

    g.drawOval(40,60,150,100);    
      g.setColor(Color.BLUE);
          }

public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mousePressed(MouseEvent e){}
}

Code:- Screenshot:-

M - Notepad Eile Edit Format View Help import java.awt.*; import java.awt.event.*; public class M extends MyFrame { public st

output:-

x Menu Circumcircle Exit

Add a comment
Know the answer?
Add Answer to:
Task: Write a Java program to implement a simple graph editor that can be used to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coin

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

Free Homework App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.