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:-
output:-
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:-
output:-
Task: Write a Java program to implement a simple graph editor that can be used to...
Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor. Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...
This is python3. Please help me out. Develop the following GUI interface to allow the user to specify the number of rows and number of columns of cards to be shown to the user. Show default values 2 and 2 for number of rows and number of columns. The buttons "New Game" and "Turn Over" span two column-cells each. Fig 1. The GUI when the program first starts. When the user clicks the "New Game" button, the program will read...
JAVA Primitive Editor (Please help, I am stuck on this assignment which is worth a lot of points. Make sure that the program works because I had someone answer this incorrectly!) The primary goal of the assignment is to develop a Java based primitive editor. We all know what an editor of a text file is. Notepad, Wordpad, TextWrangler, Pages, and Word are all text editors, where you can type text, correct the text in various places by moving the...
One example of computer-aided design (CAD) is building geometric structures inter- actively. In Chapter 4, we will look at ways in which we can model geometric objects comprised of polygons. Here, we want to examine the interactive part. Let’s start by writing an application that will let the user specify a series of axis- aligned rectangles interactively. Each rectangle can be defined by two mouse positions at diagonally opposite corners. Consider the event listener canvas.addEventListener("mousedown", function() { gl.bindBuffer(gl.ARRAY_BUFFER, vBuffer); if...
Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.) 2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...
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...