اهلا شطناوي .. كيف الحال
اهلا شطناوي .. كيف الحال
شكرا طوق الياسمين
انا مش ضايل عندي حرة الا الوطنية
اذا ما لقيت مواد احتمال كبير انزلها
hala ghassan
al7md lellah tmam
sho a7'bark?
t7maloni alyom ma fe 3arabic
ammar edha bedac code jaava katabroh qabel shwai
هلا عبادة .. انا تمام الحمدلله ... بنتحملك ياسيدي بالفرنسي اذا بدك ..
شكرا طوق الياسمين
/**
* AWT Sample application
*
* @Obadah M. Shatnawi
* @version 1.00 09/01/06
*/
import ****.awt.*;
import ****x.swing.*;
import ****.awt.event.*;
import ****.awt.event.ActionListener;
import ****.util.EventListener;
public class Final1 extends JFrame implements ActionListener{
Bord bord;
JTextField txt[ ];
JLabel title [ ];
JComboBox bColor;
JButton bRect,bLine,bCirc;
JCheckBox c1;
MyShape s1;
Color colors [ ]={ Color.black,Color.green,Color.orange,Color.white };
public static void main(String[] args) {
Final1 app=new Final1();
app.setSize(500,450);
app.setTitle("Final Exam");
app.set********(150,200);
app.setDefaultCloseOperation(3);
app.setVisible(true);
}
public Final1()
{
Container c=this.get*******Pane();
bord=new Bord();
c.add(bord,BorderLayout.NORTH);
txt=new JTextField[6];
title=new JLabel[6];
for(int i=0;i<6;i++)
{
txt[i]=new JTextField(10);
txt[i].setHorizontalAlignment(JTextField.CENTER);
title[i]=new JLabel();
title[i].setHorizontalAlignment(JLabel.CENTER);
}
title[0].setText("x1");
title[1].setText("y1");
title[2].setText("x2");
title[3].setText("y2");
title[4].setText("Radios");
title[5].setText("Color");
JPanel cp=new JPanel(new GridLayout(2,6));
for(int i=0;i<6;i++)
cp.add(title[i]);
for(int i=0;i<5;i++)
cp.add(txt[i]);
bColor=new JComboBox();
bColor.addItem("Black");
bColor.addItem("Green");
bColor.addItem("Orange");
bColor.addItem("White");
cp.add(bColor);
c.add(cp,"Center");
JPanel sp=new JPanel(new FlowLayout());
bRect=new JButton("Rectange");
bLine =new JButton("Line");
bCirc=new JButton("Circle");
sp.add(bRect);
sp.add(bLine);
sp.add(bCirc);
c.add(sp,"South");
c1=new JCheckBox("Filled");
c1.setSelected(true);
sp.add(c1);
s1=new MyShape();
bRect.addActionListener(this);
bLine.addActionListener(this);
bCirc.addActionListener(this);
}
/**
* Method actionPerformed
*
*
* @param e
*
*/
public void actionPerformed(ActionEvent e) {
// TODO: Add your code here
if(e.getSource()==bRect){
int indx=bColor.getSelectedIndex();
s1.c=colors[indx];
s1.x1=Integer.parseInt(txt[0].getText());
s1.y1=Integer.parseInt(txt[1].getText());
s1.x2=Integer.parseInt(txt[2].getText());
s1.y2=Integer.parseInt(txt[3].getText());
bord.drawRect(s1,c1);
}else if(e.getSource()==bLine){
int indx=bColor.getSelectedIndex();
s1.c=colors[indx];
s1.x1=Integer.parseInt(txt[0].getText());
s1.y1=Integer.parseInt(txt[1].getText());
s1.x2=Integer.parseInt(txt[2].getText());
s1.y2=Integer.parseInt(txt[3].getText());
bord.drawLine(s1);
}else if(e.getSource()==bCirc){
int indx=bColor.getSelectedIndex();
s1.c=colors[indx];
s1.x1=Integer.parseInt(txt[0].getText());
s1.y1=Integer.parseInt(txt[1].getText());
s1.r=Integer.parseInt(txt[4].getText());
bord.drawCirc(s1,c1);
}
}
}
class Bord extends Canvas{
public Bord(){
this.setBackground(Color.gray);
this.setPreferredSize(new Dimension(300,300));
}
public void paint(Graphics g){
this.setBackground(Color.blue);
}
public void drawRect(MyShape s,JCheckBox c1){
Graphics g=this.getGraphics();
g.setColor(s.c);
if(c1.isSelected())
g.drawRect(s.x1,s.y1,s.x2-s.x1,s.y2-s.y1);
else
g.drawRect(s.x1,s.y1,s.x2-s.x1,s.y2-s.y1);
}
public void drawLine(MyShape s){
Graphics g = this.getGraphics();
g.setColor(s.c);
g.drawLine(s.x1,s.y1,s.x2,s.y2);
}
public void drawCirc(MyShape s,JCheckBox c1)
{
Graphics g=this.getGraphics();
g.setColor(s.c);
if(c1.isSelected())
g.fillOval(s.x1-s.r,s.y1-s.r,s.r*2,s.r*2);
else
g.drawOval(s.x1-s.r,s.y1-s.r,s.r*2,s.r*2);
}
}
class MyShape{
public int x1,x2,y1,y2,r;
public Color c;
}
الذين يشاهدون الموضوع الآن: 48 (0 من الأعضاء و 48 زائر)
مواقع النشر (المفضلة)