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