0
Ich soll eine Polygon-Orange-Nase und einen Polygon-schwarzen Hut hinzufügen, sowie schriftlich zu seinem Schal, aber kann es nicht herausfinden. das ist was ich bisher habe. Ich kann nicht scheinen, unsere, wenn ich das fillpolygon oder was verwenden muss.Probleme beim Hinzufügen eines Polygons und Schreiben zu meinem Schneemann in Java
import java.applet.Applet;
import java.awt.*;
public class SnowMan extends Applet
{
public void paint (Graphics frame)
{
// set up some constants
final int MID = 150; // middle of the snowman
final int TOP = 50; // top of the snowman
// need to set the background colors
setBackground (Color.cyan);
// color the ground
frame.setColor (Color.lightGray);
// the ground is a blue rectangle
frame.fillRect (1, 175, 500, 150) ;
// draw three large snowballs to make up snowman
frame.setColor (Color.white);
// draw head
frame.fillOval (MID - 20, TOP, 40, 40);
// draw middle (upper torso)
frame.fillOval (MID - 35, TOP + 35, 70, 50);
// draw base (lower torso)
frame.fillOval (MID - 50, TOP + 80, 100, 60);
// draw in features of snowman
frame.setColor (Color.black);
// draw eyes
// draw left eye
frame.fillOval (MID - 10, TOP + 10, 5, 5);
// draw right eye
frame.fillOval (MID + 5, TOP + 10, 5, 5);
//Draw Buttons
frame.fillOval (MID -2, TOP + 50, 5, 5);
frame.fillOval (MID -2, TOP + 60, 5, 5);
frame.fillOval (MID -2, TOP + 70, 5, 5);
// draw arms
// draw left arm
frame.drawLine (MID - 25, TOP + 60, MID - 50, TOP + 40);
// draw right arm
frame.drawLine (MID + 25, TOP + 60, MID + 55, TOP + 60);
// draw hat
// draw brim of hat
frame.drawLine (MID - 20, TOP + 5, MID + 20, TOP + 5);
frame.fillRect (MID - 20, TOP + 35, 40, 10);
// draw top of hat
frame.fillRect (MID - 15, TOP - 20, 30, 25);
frame.setColor (Color.red);
// draw mouth
frame.drawArc (MID - 10, TOP + 20, 20, 10, 190, 160);
}
}
Mögliche Duplikat [Einen Schneemann mit jframe erstellen?] (Https://stackoverflow.com/questions/45446382/creating-a-snowman-with-jframe) – Lexi
1) Warum ein Applet codieren? Wenn es aufgrund der Angabe des Lehrers geschieht, verweisen Sie bitte auf [Warum CS-Lehrer ** aufhören sollten ** Java-Applets zu unterrichten] (http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should -stop-teaching-Java-Applets /). 2) Siehe [Java Plugin-Unterstützung nicht mehr unterstützt] (http://www.gizmodo.com.au/2016/01/rest-in-hell-java-plug-in/) und [Wechsel zu einem Plugin-freien Web] (https://blogs.oracle.com/java-platform-group/moving-to-a-plugin-free-web). 3) Warum AWT verwenden? .. –
.. Siehe [diese Antwort] (http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) aus vielen guten Gründen, AWT-Komponenten zugunsten von Swing zu verlassen. –