Java dasurlash tilining Swing moduli yordamida Sodda Kalkulyator


Download 36.22 Kb.
Sana18.06.2023
Hajmi36.22 Kb.
#1591579
Bog'liq
1-dedline(Sodda kalkulyator)


F.I.O

Temiraliyev Mujibali

Guruhi

650-22

Java dasurlash tilining Swing moduli yordamida “Sodda Kalkulyator” yaratish.

Men o’zimga qulay bo’lganligi uchun Java dasurlash tilining Swing moduli yordamida “ Apache Netbeans IDE” muhitidan foydalanaman.


Kerakli jihozlar: JFrame , JTextField, JButton;



JFrame - klassi java-ni meros qilib olgan konteyner turidir. awt. Ramka sinfi. JFrame GUI yaratish uchun teglar, tugmalar, matn maydonlari kabi komponentlar qo'shiladigan asosiy oyna kabi ishlaydi.


JTextField - bu bir qator matnni tahrirlash imkonini beruvchi engil komponent. Matn maydonlari haqida ma'lumot va ulardan foydalanish misollari uchun Java o'quv qo'llanmasida matn maydonlaridan qanday foydalanishga qarang. JTextField Java bilan manbaga mos kelishi uchun mo'ljallangan.


JButton - klassi platformadan mustaqil amalga oshiriladigan etiketli tugmani yaratish uchun ishlatiladi. Ilova tugma bosilganda ba'zi harakatlarni amalga oshiradi. U AbstractButton sinfini meros qilib oladi.

private void initComponents() {


oyna_1 = new javax.swing.JTextField();


jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
oyna_2 = new javax.swing.JTextField();
qushish = new javax.swing.JButton();
ayirish = new javax.swing.JButton();
kopaytirish = new javax.swing.JButton();
bolish = new javax.swing.JButton();
natija = new javax.swing.JLabel();
tozalash = new javax.swing.JButton();
double a,b,c;
private void qushishActionPerformed(java.awt.event.ActionEvent evt) {
a = Double.parseDouble(oyna_1.getText());
b = Double.parseDouble(oyna_2.getText());
c = a+b;
natija.setText("Natija: " + String.valueOf(c));
oyna_1.requestFocus }

private void ayirishActionPerformed(java.awt.event.ActionEvent evt) {


a = Double.parseDouble(oyna_1.getText());
b = Double.parseDouble(oyna_2.getText());
c = a-b;
natija.setText("Natija: " + String.valueOf(c));
oyna_1.requestFocus();
}

private void kopaytirishActionPerformed(java.awt.event.ActionEvent evt) {


a = Double.parseDouble(oyna_1.getText());
b = Double.parseDouble(oyna_2.getText());
c = a*b;
natija.setText("Natija: " + String.valueOf(c));
oyna_1.requestFocus();
}

private void bolishActionPerformed(java.awt.event.ActionEvent evt) {


a = Double.parseDouble(oyna_1.getText());
b = Double.parseDouble(oyna_2.getText());
c = a/b;
natija.setText("Natija: " + String.valueOf(c));
oyna_1.requestFocus();
}

private void oyna_1ActionPerformed(java.awt.event.ActionEvent evt) {


}

private void tozalashActionPerformed(java.awt.event.ActionEvent evt) {


oyna_1.setText(" ");
oyna_2.setText(" ");
natija.setText(" ");
oyna_1.requestFocus(); }
private javax.swing.JButton ayirish;
private javax.swing.JButton bolish;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JButton kopaytirish;
private javax.swing.JLabel natija;
private javax.swing.JTextField oyna_1;
private javax.swing.JTextField oyna_2;
private javax.swing.JButton qushish;
private javax.swing.JButton tozalash;
}

Download 36.22 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling