www.erzenisma.com

FORUMI
 
HomeCalendarGalleryFAQSearchRegisterMemberlistUsergroupsLog in

Share | 
 

 Vizatimi Grafik i rrathve 2

View previous topic View next topic Go down 
AuthorMessage
Net $er$eri
Admin
Admin
avatar

Number of posts : 42
Age : 29
Registration date : 2006-11-11

PostSubject: Vizatimi Grafik i rrathve 2   Tue Nov 14, 2006 6:43 pm

import java.awt.*;
import java.awt.event.*;

public class Pie extends Frame implements ActionListener{
public int ndarja; // numri i ndarjeve
private int ngjyre_ndrruesi; // selektuesi i ngjyrave ne vargun ngjyrat
private int ndrruesi; // ndrruesi i vleres se ngjyre_ndrruesi
private TextField txt; // per vleren e ndarjes.
private Button butoni; // butoni
public Color[] ngjyrat = {Color.blue, Color.green, Color.pink, Color.cyan,
Color.red, Color.yellow, Color.magenta, Color.lightGray}; // 8 ngjyrat me te cilat do te ngjyrosen pjeset e Pie-s
private int x1; // x1 e Pie
private int y1; // y1 e Pie
private int x2; // x2 e Pie
private int y2; // y2 e Pie


public Pie() {
ndarja = 1; // inicimi i variablave...
ngjyre_ndrruesi = 0;
ndrruesi = 1;
x1 = 100;
y1 = 100;
x2 = 450;
y2 = 450;
txt = new TextField();
this.setLayout(new FlowLayout());
butoni = new Button("Vizato");
this.add(txt);
this.add(butoni);
butoni.addActionListener(this);
addWindowListener(new WindowAdapter() { // per nje mbyllje te rregullt te dritares
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
}

public void paint(Graphics g)
{
for (int i = 0; i < ndarja; i++)
{ int mbetja = 360 % ndarja; // mbetja
int shkallet = (360 - mbetja) / ndarja; // vlera e shkalleve
int kendi_fillues_i_ardhshem = i * shkallet; // pika ne te cilen do te filloj pjesa e ardhshme
ngjyre_ndrruesi = ngjyre_ndrruesi + ndrruesi; // percaktuesi i ngjyres ne varg
if (ngjyre_ndrruesi >= 7 || ngjyre_ndrruesi <= 0) // nese percaktuesi i ngj. del jashte numrit te elementeve te vargut
{ ndrruesi = -ndrruesi; } // ndrro drejtimin
g.setColor(ngjyrat[ngjyre_ndrruesi]); // ngjyra e percaktuar ne varg
g.fillArc(x1, y1, x2, y2, kendi_fillues_i_ardhshem, shkallet); // vizatimi i harkut
}
}

public void actionPerformed(ActionEvent evt)
{ String ndarjett = txt.getText();
ndarja = new Integer(ndarjett).intValue();
this.repaint();
}

public static void main(String args[]) {
System.out.println("Ne startim e siper Pie...");
Pie dritarja = new Pie();
dritarja.setSize(700, 700);
dritarja.setTitle("Pie");
dritarja.setVisible(true);
}
}
Back to top Go down
View user profile http://www.erzenisma.com
 
Vizatimi Grafik i rrathve 2
View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
www.erzenisma.com :: "PROGRAMIMI" :: JAVA-
Jump to: