EXPLAIN EACH OF THE FOLLOWING LINE. import java.awt.*; import java.awt.geom.*; 3 .import java.awt.font.*; 4. import javax.swing.*; public class Main extends JPanel{ 6. static int angdeg=0; 7. @Override 8. public void paint(Graphics g){ 9. Graphics2D g2d = (Graphics2D) g; 10.g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.V ALUE_ANTIALIAS_ON); 11. g2d.setColor(Color.white); 12. g2d.fillRect(0,0,getWidth(),getHeight()); 13. Font font = new Font("serif",Font.BOLD,50); 14. g2d.setFont(font); 15.FontRenderContext frc = g2d.getFontRenderContext(); 16.TextLayout layout = new TextLayout("JAVA", font, frc); 17. double sw = layout.getBounds().getWidth(); 18. double sh = layout.getBounds().getHeight(); 19. AffineTransform saveTransform=g2d.getTransform(); 20. g2d.setColor(Color.black); 21. Rectangle rect = this.getBounds(); 22. g2d.drawLine((int)(rect.width)/2,0,(int)(rect.width)/2,rect.height); 23. g2d.drawLine(0,(int)(rect.height)/2,rect.width,(int)(rect.height)/2); 24. AffineTransform affineTransform = new AffineTransform(); 25. affineTransform.setToTranslation((rect.width)/2,(rect.height)/2); 26. affineTransform.rotate(Math.toRadians(angdeg), 0, 0); 27. g2d.setTransform(affineTransform); 28. g2d.drawString("M",(int)-sw/2,(int)sh/2); 29. g2d.setTransform(saveTransform); } 30. public static void main(String[] args) throws Exception{ 31. JFrame frame = new JFrame("Rotated 360 Clockwise"); 32. Main rt=new Main(); 33. frame.add(rt); 34. frame.setSize(500, 500); 35. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 36. frame.setLocationRelativeTo(null); 37. frame.setVisible(true); 38. while(true){ 39. Thread.sleep(10); 40. angdeg=(angdeg>=360)?0:angdeg+5; 41. rt.repaint(); } } }
EXPLAIN EACH OF THE FOLLOWING LINE. import java.awt.*; import java.awt.geom.*; 3 .import java.awt.font.*; 4. import javax.swing.*; public class Main extends JPanel{ 6. static int angdeg=0; 7. @Override 8. public void paint(Graphics g){ 9. Graphics2D g2d = (Graphics2D) g; 10.g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.V ALUE_ANTIALIAS_ON); 11. g2d.setColor(Color.white); 12. g2d.fillRect(0,0,getWidth(),getHeight()); 13. Font font = new Font("serif",Font.BOLD,50); 14. g2d.setFont(font); 15.FontRenderContext frc = g2d.getFontRenderContext(); 16.TextLayout layout = new TextLayout("JAVA", font, frc); 17. double sw = layout.getBounds().getWidth(); 18. double sh = layout.getBounds().getHeight(); 19. AffineTransform saveTransform=g2d.getTransform(); 20. g2d.setColor(Color.black); 21. Rectangle rect = this.getBounds(); 22. g2d.drawLine((int)(rect.width)/2,0,(int)(rect.width)/2,rect.height); 23. g2d.drawLine(0,(int)(rect.height)/2,rect.width,(int)(rect.height)/2); 24. AffineTransform affineTransform = new AffineTransform(); 25. affineTransform.setToTranslation((rect.width)/2,(rect.height)/2); 26. affineTransform.rotate(Math.toRadians(angdeg), 0, 0); 27. g2d.setTransform(affineTransform); 28. g2d.drawString("M",(int)-sw/2,(int)sh/2); 29. g2d.setTransform(saveTransform); } 30. public static void main(String[] args) throws Exception{ 31. JFrame frame = new JFrame("Rotated 360 Clockwise"); 32. Main rt=new Main(); 33. frame.add(rt); 34. frame.setSize(500, 500); 35. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 36. frame.setLocationRelativeTo(null); 37. frame.setVisible(true); 38. while(true){ 39. Thread.sleep(10); 40. angdeg=(angdeg>=360)?0:angdeg+5; 41. rt.repaint(); } } }
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
EXPLAIN EACH OF THE FOLLOWING LINE.
- import java.awt.*;
- import java.awt.geom.*;
3 .import java.awt.font.*;
4. import javax.swing.*; - public class Main extends JPanel{
6. static int angdeg=0;
7. @Override
8. public void paint(Graphics g){
9. Graphics2D g2d = (Graphics2D) g;
10.g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.V ALUE_ANTIALIAS_ON);
11. g2d.setColor(Color.white);
12. g2d.fillRect(0,0,getWidth(),getHeight());
13. Font font = new Font("serif",Font.BOLD,50);
14. g2d.setFont(font);
15.FontRenderContext frc = g2d.getFontRenderContext();
16.TextLayout layout = new TextLayout("JAVA", font, frc);
17. double sw = layout.getBounds().getWidth();
18. double sh = layout.getBounds().getHeight();
19. AffineTransform saveTransform=g2d.getTransform();
20. g2d.setColor(Color.black);
21. Rectangle rect = this.getBounds();
22. g2d.drawLine((int)(rect.width)/2,0,(int)(rect.width)/2,rect.height);
23. g2d.drawLine(0,(int)(rect.height)/2,rect.width,(int)(rect.height)/2);
24. AffineTransform affineTransform = new AffineTransform();
25. affineTransform.setToTranslation((rect.width)/2,(rect.height)/2);
26. affineTransform.rotate(Math.toRadians(angdeg), 0, 0);
27. g2d.setTransform(affineTransform);
28. g2d.drawString("M",(int)-sw/2,(int)sh/2);
29. g2d.setTransform(saveTransform);
}
30. public static void main(String[] args) throws Exception{
31. JFrame frame = new JFrame("Rotated 360 Clockwise");
32. Main rt=new Main();
33. frame.add(rt);
34. frame.setSize(500, 500);
35. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
36. frame.setLocationRelativeTo(null);
37. frame.setVisible(true);
38. while(true){
39. Thread.sleep(10);
40. angdeg=(angdeg>=360)?0:angdeg+5;
41. rt.repaint();
}
}
}
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 6 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY