Java'da Line2D ile üçgen ve dörtgen çizdirme - Draw triangle and ractangle with Line2D function in java



import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class FrameDemo extends JFrame{
        //Kurucu fonksiyon
public FrameDemo(){
JPanel panel = new JPanel();
getContentPane().add(panel);
setSize(500, 500);
setTitle("Title");
}

public void paint(Graphics g){
super.paint(g);
Graphics2D g2 = (Graphics2D) g;

//ilk parametre doğrunun x eksenindeki başlangıç noktasını,ikinci paremetre y eksenindeki başlangıç noktasını
//üçüncü parametre x eksenindeki bitiş noktasını, dördüncü parametre ise y eksenindeki bitiş noktasını gösterir.

               //first parameter is x coordinate of the start point,
               //second parameter is y coordinate of the start point,
               //third parameter is x coordinate of the end point,
               // fourth parameter is y coordinate of the end point

                //üçgen - triangle
g2.draw(new Line2D.Double(50,150,150,150)); //üçgenin tabanı - bottom
g2.draw(new Line2D.Double(100,100,50,150)); //sol taraf - left line
g2.draw(new Line2D.Double(100,100,150,150));//sağ taraf - right line

                //dörtgen - rectangle
g2.draw(new Line2D.Double(50,150,150,150)); // üst taban - top
g2.draw(new Line2D.Double(50,150,50,250));//sağ kenar - right line
g2.draw(new Line2D.Double(150,150,150,250)); //sol kenar - left line
g2.draw(new Line2D.Double(50,250,150,250)); //alt taban - bottom
}

public static void main(String args[]){
FrameDemo f = new FrameDemo();
f.setVisible(true);
}
}

1 Response to "Java'da Line2D ile üçgen ve dörtgen çizdirme - Draw triangle and ractangle with Line2D function in java "

  1. Blog27999 7 Mart 2020 21:37
    If you're attempting to lose kilograms then you absolutely have to start using this totally brand new custom keto plan.

    To create this keto diet service, certified nutritionists, fitness trainers, and cooks united to develop keto meal plans that are useful, convenient, price-efficient, and fun.

    Since their first launch in January 2019, thousands of individuals have already remodeled their figure and well-being with the benefits a proper keto plan can provide.

    Speaking of benefits: in this link, you'll discover 8 scientifically-certified ones provided by the keto plan.

Yorum Gönder