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

[ تمت الإجابة ]كود التنسيق

بدأه دنية القوى في 23 مايو 2011 · 2 رد · 493 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

عندى برنامج كتبه والحمد الله صحيح وهو عبره عن أدخل عددين بحيث يختر عمليه جمع أوضرب وتخرج النتيجه بس فى شىء مانى عارفه الكود الا أستخدمه كى تكون أم كل مدخل كلمه تدل عليه أنه المدخل الآول أو الثانى أو النتجه أنا حولات بس تطلع كلها فى السطر واحد والمربعاتالادخل تكون تحت

أريد منكم التوضيح

وشكرا .

وهذا الكود

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package myprj;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author PSYCHO_ MANTIS
 */
public class Main extends JFrame {

    private JButton button;
    private JButton button2;
    private JTextField field1;
    private JTextField field2;
    private JTextField field3;

    public Main() {

        button = new JButton("+");
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                field3.setText(Integer.toString(Integer.parseInt(field1.getText()) + Integer.parseInt(field2.getText())));
            }
        });
        button2 = new JButton("*");
        button2.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                field3.setText(Integer.toString(Integer.parseInt(field1.getText()) * Integer.parseInt(field2.getText())));
            }
        });
        JPanel p1 = new JPanel();
       field1 = new JTextField();
       field2 = new JTextField();
       field3 = new JTextField();
       field1.setColumns(20);
       field2.setColumns(20); 
       field3.setColumns(25);
       p1.add(new JLabel("First Number"));
       p1.add(new JLabel("Second Number"));
       p1.add(new JLabel("Result"));
       getContentPane().add(p1, BorderLayout.WEST);
               getContentPane().add(p1, BorderLayout.EAST);
               getContentPane().add(p1, BorderLayout.SOUTH);


       setLayout(new FlowLayout());
       add(field1);
       add(field2);
       add(field3);
       add(button);
       add(button2);
       setVisible(true);
       setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
       setSize(300,200);
       setResizable(false);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Main app = new Main();
    }
}
#2

تفضلى

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author PSYCHO_ MANTIS
 */
public class Main extends JFrame {

	private JButton button;
	private JButton button2;
	private JTextField field1;
	private JTextField field2;
	private JTextField field3;

	public Main() {

    	button = new JButton("+");
    	button.addActionListener(new ActionListener() {

        	public void actionPerformed(ActionEvent e) {
            	field3.setText(Integer.toString(Integer.parseInt(field1.getText()) + Integer.parseInt(field2.getText())));
        	}
    	});
    	button2 = new JButton("*");
    	button2.addActionListener(new ActionListener() {

        	public void actionPerformed(ActionEvent e) {
            	field3.setText(Integer.toString(Integer.parseInt(field1.getText()) * Integer.parseInt(field2.getText())));
        	}
    	});
    	JPanel p1 = new JPanel(new GridLayout(3, 3));
    	field1 = new JTextField();
    	field2 = new JTextField();
    	field3 = new JTextField();
    	field1.setColumns(20);
    	field2.setColumns(20);
    	field3.setColumns(25);
    	p1.add(new JLabel("First Number"));
    	p1.add(field1);

    	p1.add(new JLabel("Second Number"));
    	p1.add(field2);

    	p1.add(new JLabel("Result"));

    	p1.add(field3);

    	JPanel buttonPanel = new JPanel();
    	buttonPanel.add(button);
    	buttonPanel.add(button2);

    	add(p1, BorderLayout.NORTH);
    	add(buttonPanel, BorderLayout.SOUTH);
    	setVisible(true);
    	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    	setSize(300, 200);
    	setResizable(false);
	}

	/**
 	* @param args the command line arguments
 	*/
	public static void main(String[] args) {
    	Main app = new Main();
	}
}

Software Developer
Mahmoudkelany.com


 

#3

ممكن مساعده ماهى الكود المستخدم في تغير الون وفى أضافه الصوت

can add few bells and whistles to the calculator.
Be creative here, for example
• Make the fonts bigger
• Make the background different for the result and the operands (the
two numbers).
• Fonts, colors, ... but keep the basic functionality

وشكرا.

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