الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

العمليات الحسابية

بدأه raja2 في 13 أبريل 2008 · 2 رد · 595 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

مساء الخير جميعـــا

أريد أن أتعلم كيف نكتب اكواد العمليات الحسابية و اكواد Buttons

لكتابة الأرقــام

تماما كالالة الحاسبــة

أعتذر سلفا اذا كان الموضوع مكرر و لكني صراحة لا اجيد البحث بالمواضيع

ارجوا قبول اعتذراي

كذلك ارجو تعليمي الطريقة

سأكون شاكرة للجميع

تحياتي

#2

السلامعليكم

أختي هل بامكانك ان توضحي أكثر عما تريدينه لانني لم افهم قصدك

تحياتي

حياكي الله

#3

مثال بسيط

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

public class Cal extends JFrame {


public TextField Text3;
public Button Button1,Button2,Button3,Button4;
String Calc = "";

public Cal (){
  super("Cal");


  Container container = getContentPane();
  container.setLayout(new FlowLayout());

Text3= new TextField(10);
Text3.setEditable(false);
container.add(Text3);


  Button1 = new Button("0");
  container.add(Button1);

  Button1.addActionListener(new ActionListener() {
  public void actionPerformed (ActionEvent event){
	Calc+= 0;
	Text3.setText(Calc);
	}  
   }
  );

  Button2 = new Button("1");
  container.add(Button2);

  Button2.addActionListener(new ActionListener() {
  public void actionPerformed (ActionEvent event){
	Calc+= 1;
	Text3.setText(Calc);
	}  
   }
  );


  Button3 = new Button("2");
  container.add(Button3);

  Button3.addActionListener(new ActionListener() {
  public void actionPerformed (ActionEvent event){
	Calc+= 2;
	Text3.setText(Calc);
	}  
   }
  );

  Button4 = new Button("3");
  container.add(Button4);

  Button4.addActionListener(new ActionListener() {
  public void actionPerformed (ActionEvent event){
	Calc+= 3;
	Text3.setText(Calc);
	}  
   }
  ); 


  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}
public static void main (String[] args) {
Cal cal = new Cal ();
cal.setSize(100,100);
cal.setVisible(true);
}   

}

اما عن باقي الكود وصناعة الحاسبة ... فضعي الشكل كما تريين والعمليات التي تريدين

تم تعديل هذه المشاركة بواسطة Jsp في 19 أبريل 2008 في 03:36

مواضيع مشابهة