25 1 Complete case for problem 1 in paint method to draw the following shape based on current

Java, Please help with my code, Need my draw lines to be exact like in pictureimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.JOptionPane; public class Homework2 extends Frame implements ActionListener { String command = ""; public static void main(String[] args) { Frame frame = new Homework2(); frame.setResizable(true); frame.setSize(900,800); frame.setVisible(true); } public Homework2() { setTitle("Homework2 - CSC 229 - Seyed"); // Create Menu MenuBar mb = new MenuBar(); setMenuBar(mb); Menu fileMenu = new Menu("File"); mb.add(fileMenu); MenuItem miAbout = new MenuItem("About"); miAbout.addActionListener(this); fileMenu.add(miAbout); MenuItem miExit = new MenuItem("Exit"); miExit.addActionListener(this); fileMenu.add(miExit); Menu actionMenu = new Menu("Shapes"); mb.add(actionMenu); MenuItem miP1 = new MenuItem("Problem 1"); miP1.addActionListener(this); actionMenu.add(miP1); MenuItem miP2 = new MenuItem("Problem 2"); miP2.addActionListener(this); actionMenu.add(miP2); // End program when window is closed WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } public void windowActivated(WindowEvent ev) { repaint(); } public void windowStateChanged(WindowEvent ev) { repaint(); } }; ComponentListener k = new ComponentAdapter() { public void componentResized(ComponentEvent e) { repaint(); } }; // register listeners this.addWindowListener(l); this.addComponentListener(k); } //****************************************************************************** // called by windows manager whenever the application window performs an action // (select a menu item, close, resize, .... //****************************************************************************** public void actionPerformed (ActionEvent ev) { // figure out which command was issued command = ev.getActionCommand(); // take action accordingly switch(command) { case "About": { repaint(); break; } case "Exit": { System.exit(0); } case "Problem 1": { repaint(); break; } case "Problem 2": { repaint(); break; } } } //******************************************************** // called by repaint() to redraw the screen //******************************************************** public void paint(Graphics g) { int ww = (int) this.getWidth(); // current width of the window int wh = (int) this.getHeight(); // current height of the window int s = 40; // Check Command issued, take action accordingly switch(command) { case "About": { break; } case "Exit": { System.exit(0); } case "Problem 1": { break; } case "Problem 2": { break; } } } }

Java, Please help with my code, Need my draw lines to be exact like in pictureimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JOptionPane;

public class Homework2 extends Frame implements ActionListener
{

String command = “”;

public static void main(String[] args)
{
Frame frame = new Homework2();

frame.setResizable(true);
frame.setSize(900,800);
frame.setVisible(true);

}

public Homework2()
{
setTitle(“Homework2 – CSC 229 – Seyed”);

// Create Menu

MenuBar mb = new MenuBar();
setMenuBar(mb);

Menu fileMenu = new Menu(“File”);
mb.add(fileMenu);

MenuItem miAbout = new MenuItem(“About”);
miAbout.addActionListener(this);
fileMenu.add(miAbout);

MenuItem miExit = new MenuItem(“Exit”);
miExit.addActionListener(this);
fileMenu.add(miExit);

Menu actionMenu = new Menu(“Shapes”);
mb.add(actionMenu);

MenuItem miP1 = new MenuItem(“Problem 1”);
miP1.addActionListener(this);
actionMenu.add(miP1);

MenuItem miP2 = new MenuItem(“Problem 2”);
miP2.addActionListener(this);
actionMenu.add(miP2);

// End program when window is closed

WindowListener l = new WindowAdapter()
{

public void windowClosing(WindowEvent ev)
{
System.exit(0);
}

public void windowActivated(WindowEvent ev)
{
repaint();
}

public void windowStateChanged(WindowEvent ev)
{
repaint();
}

};

ComponentListener k = new ComponentAdapter()
{
public void componentResized(ComponentEvent e)
{
repaint();
}
};

// register listeners

this.addWindowListener(l);
this.addComponentListener(k);
}

//******************************************************************************
// called by windows manager whenever the application window performs an action
// (select a menu item, close, resize, ….
//******************************************************************************

public void actionPerformed (ActionEvent ev)
{
// figure out which command was issued

command = ev.getActionCommand();

// take action accordingly
switch(command)
{
case “About”:
{
repaint();
break;
}
case “Exit”:
{
System.exit(0);
}
case “Problem 1”:
{
repaint();
break;
}
case “Problem 2”:
{
repaint();
break;
}
}

}
//********************************************************
// called by repaint() to redraw the screen
//********************************************************

public void paint(Graphics g)
{
int ww = (int) this.getWidth(); // current width of the window
int wh = (int) this.getHeight(); // current height of the window
int s = 40;
// Check Command issued, take action accordingly
switch(command)
{
case “About”:
{

break;
}
case “Exit”:
{
System.exit(0);
}
case “Problem 1”:
{

break;
}
case “Problem 2”:
{

break;
}
}
}

}


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (6 ratings) 6 out of 6 people found this solution helpful.