(Solved) : Second Time Posting Question Anyone Explain Line Code Perfectly Runs Compiles Hard Time Un Q42772050 . . .

Second time posting this question.

can anyone explain what each line of this code does? itperfectly runs and compiles but I have a hard time understandingthe code itself. Comment on each line and explainplease.thanks

it is a java program BTW.

import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.geom.*;

class JOL extends JApplet
   {
   public void init()
      {
      getContentPane().setLayout(newBorderLayout());
      getContentPane().add(newJOLPanel());
      getContentPane().add(getLabel(),”Last”);
      }

   private JLabel getLabel()
      {
      JLabel label = newJLabel(“Mr.Pumpkin”, JLabel.CENTER);
      label.setFont(new Font(“dialog”,Font.ITALIC|Font.BOLD, 36));
      return label;
      }

   public static void main(String[] args)
      {
      JOL applet = new JOL();
      JFrame f = new JFrame();
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     f.getContentPane().add(applet);
      f.setSize(400,400);
      f.setLocation(200,200);
      applet.init();
      f.setVisible(true);
      }
   }

class JOLPanel extends JPanel
   {
   protected void paintComponent(Graphics g)
      {
      super.paintComponent(g);
      Graphics2D g2 = (Graphics2D)g;
     g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
      int w = getWidth();
      int h = getHeight();
      g2.setPaint(Color.orange);
      g2.fill(new Ellipse2D.Double(w/16,h/16, w*7/8, h*7/8));
      Ellipse2D.Double e = newEllipse2D.Double(w/4, h/3, w*3/16, h*3/32);
      double x = e.getCenterX();
      double y = e.getCenterY();
      AffineTransform at =AffineTransform.getRotateInstance(Math.PI/9, x, y);
      Shape leftEye =at.createTransformedShape(e);
      at.setToTranslation(w, 0);
      at.scale(-1, 1);
      Shape rightEye =at.createTransformedShape(leftEye);
      Area mouth = new Area(newEllipse2D.Double(w/4, h*8/16, w/2, h/3));
      Area a = new Area(newEllipse2D.Double(w/8, h/3, w*3/4, h*5/12));
      mouth.subtract(a);

      g2.setColor(Color.black);
      g2.fill(mouth);
      g2.setColor(Color.red);
      g2.fill(leftEye);
      g2.fill(rightEye);
      g2.setColor(Color.black);
      }
   }

Expert Answer


Answer to Second time posting this question. can anyone explain what each line of this code does? it perfectly runs and compiles b…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us