السلام عليكم
عندى برنامج كتبه والحمد الله صحيح وهو عبره عن أدخل عددين بحيث يختر عمليه جمع أوضرب وتخرج النتيجه بس فى شىء مانى عارفه الكود الا أستخدمه في تغير الون وفى أضافه الصوت والخط اليوم ضرورى
شكرا.
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
هذى هوى البرنامج
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();
}
}