java - Creating a star shape implementing Icon and display in JOptionPane -


below assignment given:

write class implements icon interface , draw star using given coordinates. display star in joption pane

  • coordinates: (100,10) (125,75) (200,85) (150,125) (160,190) (100,150) (40,190) (50,125) (0,85) (75,75)

  • set width , height of icon 200x200

  • set line color blue

i have found need icon tester don't know go point have gotten far. code:

import java.awt.color; import java.awt.component; import java.awt.graphics; import java.awt.polygon; import javax.swing.icon;  public class star implements icon {     public staricon(){      }     public int getstarheight(){         return 200;     }     public int getstarwidth(){         return 200;     }      public void painticon(component c, graphics g, int x, int y){         g.setcolor(color.blue);         g.drawline(100, 10, 125, 75);         g.drawline(125, 75, 200, 85);         g.drawline(200, 85, 150, 125);         g.drawline(150, 125, 160, 190);         g.drawline(160, 190, 100, 150);         g.drawline(100, 150, 40, 190);         g.drawline(40, 190, 50, 125);         g.drawline(50, 125, 0, 85);         g.drawline(0, 85, 75, 75);         g.drawline(75, 75, 100, 10);     } } 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -