DONUT
package donut;
import javax.swing.JFrame; import javax.swing.SwingUtilities;
public class Donut extends JFrame{ public Donut() {
initUI(); }
private void initUI() { //Interface grafica
setTitle("Donut"); // Coloca o titulo da interface
add(new Surface()); //coloca superfice
setSize(370, 320); // tamano da Superfice setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // fecha o programa ao clicar no x setLocationRelativeTo(null); }
public static void main(String[] args) { // programa main
SwingUtilities.invokeLater(new Runnable() { // metodo para chamar função
@Override //anotação de que o metodo e rreescrito public void run() {
Donut dn = new Donut();// Declara novo objeto dn.setVisible(true); // faz o dounut vizivel } }); } } /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
package donut;
import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt.geom.Ellipse2D; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities;
public class Surface extends JPanel{ private void doDrawing(Graphics g) {
Graphics2D g2 = (Graphics2D) g;//gera um novo objeto que da controle as formas geometricas
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING,//A classe