2-topshiriq: Java dasturlash tilining Swing moduli yordamida murakkab kalkulyator yaratish. Nazariy qism
Download 0.65 Mb.
|
Deadline-2 ruziyeva
2-topshiriq: Java dasturlash tilining Swing moduli yordamida murakkab kalkulyator yaratish. Nazariy qism: Java Swing Java Foundation Classes (JFC) ning bir qismi bo'lib, Javada ish stoli ilovalarini yaratish uchun GUI komponentlari va vositalari to'plamini taqdim etadi. Bu ishlab chiquvchilarga boy va interaktiv grafik foydalanuvchi interfeyslarini yaratishga imkon beruvchi kuchli ramka. Java Swing bilan bog'liq ba'zi asosiy xususiyatlar va tushunchalar: Yengil: Swing komponentlari butunlay Java-da amalga oshiriladi, bu ularni platformadan mustaqil va engil qiladi. Ular asosiy operatsion tizimning oyna tizimiga bog'liq emas. MVC arxitekturasi: Swing Model-View-Controller (MVC) arxitektura naqshiga amal qiladi. U UI komponentlarini (Ko‘rish) ilova mantig‘idan (Model) ajratadi va ular orasidagi o‘zaro aloqalarni boshqarish uchun kontrollerlarni taqdim etadi. Komponentlarning boy to'plami: Swing GUI ilovalarini yaratish uchun keng ko'lamli komponentlarni taklif etadi, jumladan tugmalar, teglar, matn maydonlari, tasdiqlash qutilari, radio tugmalar, ro'yxatlar, jadvallar, menyular va boshqalar. Ushbu komponentlar maxsus talablarni qondirish uchun sozlanishi va kengaytirilishi mumkin. Layout menejerlari: Swing konteyner ichidagi tarkibiy qismlarni tartibga solish va joylashtirish uchun turli xil tartib menejerlarini taqdim etadi. Layout menejerlari mavjud bo'sh joy va belgilangan qoidalar asosida komponentlarning avtomatik o'lchamlarini va joylashishini boshqaradi. Voqealarga asoslangan dasturlash: Swing ilovalari voqealarga asoslangan, ya'ni ular tegishli kodni bajarish orqali foydalanuvchi harakatlariga yoki tizim hodisalariga javob beradi. Tugmalarni bosish, sichqoncha harakati va tugmachalarni bosish kabi hodisalar voqealar tinglovchilari va qayta qo'ng'iroqlar yordamida boshqarilishi mumkin. Qarang va his eting: Swing turli xil UI mavzularini qo'llash orqali ilovangizning ko'rinishini va hissiyotini o'zgartirishga imkon beradi. U standart Java koʻrinishi va hissiyotini (Metal), shuningdek, Windows, macOS va GTK kabi boshqa koʻrinish va his qilish imkoniyatlarini qoʻllab-quvvatlaydi. Xalqarolashtirish va qulaylik: Swing xalqarolashtirish (i18n) va mahalliylashtirish (l10n) uchun yordam beradi, bu ilovalarni turli tillarga osongina tarjima qilish imkonini beradi. Shuningdek, u GUI ilovalarini nogironlar foydalanishi uchun qulaylik xususiyatlarini o'z ichiga oladi. Umuman olganda, Java Swing Java-da ish stoli ilovalarini yaratish uchun ko'p qirrali va keng qo'llaniladigan GUI asboblar to'plamidir. Zamonaviy Java UI rivojlanishi uchun u asosan JavaFX bilan almashtirilgan bo'lsa-da, Swing hali ham eski ilovalar va muayyan foydalanish holatlari uchun to'g'ri tanlov bo'lib qolmoqda. /*
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template */ package com.mycompany.scientificcalc; /** * * @author HP */ public class NewJFrame extends javax.swing.JFrame { double memory = 0; /** * Creates new form NewJFrame */ public NewJFrame() { initComponents(); } double num1, num2, result; String opr; public void enable() { jTextField1.setEnabled(true); jButton1.setEnabled(true); btnMC.setEnabled(true); jButton40.setEnabled(true); jButton73.setEnabled(true); jButton60.setEnabled(true); jButton65.setEnabled(true); jButton82.setEnabled(true); jButton88.setEnabled(true); jButton39.setEnabled(true); jButton36.setEnabled(true); jButton41.setEnabled(true); jButton45.setEnabled(true); jButton66.setEnabled(true); jButton83.setEnabled(true); jButton89.setEnabled(true); jButton44.setEnabled(true); jButton37.setEnabled(true); jButton42.setEnabled(true); jButton46.setEnabled(true); jButton62.setEnabled(true); jButton67.setEnabled(true); jButton84.setEnabled(true); jButton90.setEnabled(true); jButton49.setEnabled(true); jButton38.setEnabled(true); jButton43.setEnabled(true); jButton47.setEnabled(true); jButton63.setEnabled(true); jButton68.setEnabled(true); jButton85.setEnabled(true); jButton75.setEnabled(true); jButton74.setEnabled(true); jButton72.setEnabled(true); jButton48.setEnabled(true); jButton64.setEnabled(true); jButton91.setEnabled(true); jButton80.setEnabled(true); jButton69.setEnabled(true); } public void disenable() { jTextField1.setEnabled(false); jButton1.setEnabled(false); btnMC.setEnabled(false); jButton40.setEnabled(false); jButton73.setEnabled(false); jButton60.setEnabled(false); jButton65.setEnabled(false); jButton82.setEnabled(false); jButton88.setEnabled(false); jButton39.setEnabled(false); jButton36.setEnabled(false); jButton41.setEnabled(false); jButton45.setEnabled(false); jButton66.setEnabled(false); jButton83.setEnabled(false); jButton89.setEnabled(false); jButton44.setEnabled(false); jButton37.setEnabled(false); jButton42.setEnabled(false); jButton46.setEnabled(false); jButton62.setEnabled(false); jButton67.setEnabled(false); jButton84.setEnabled(false); jButton90.setEnabled(false); jButton49.setEnabled(false); jButton38.setEnabled(false); jButton43.setEnabled(false); jButton47.setEnabled(false); jButton63.setEnabled(false); jButton68.setEnabled(false); jButton85.setEnabled(false); jButton75.setEnabled(false); jButton74.setEnabled(false); jButton72.setEnabled(false); jButton48.setEnabled(false); jButton64.setEnabled(false); jButton91.setEnabled(false); jButton80.setEnabled(false); jButton69.setEnabled(false); }
* This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // private void initComponents() { jTextField1 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton36 = new javax.swing.JButton(); jButton37 = new javax.swing.JButton(); jButton38 = new javax.swing.JButton(); jButton60 = new javax.swing.JButton(); jButton61 = new javax.swing.JButton(); jButton62 = new javax.swing.JButton(); jButton63 = new javax.swing.JButton(); jButton64 = new javax.swing.JButton(); jButton40 = new javax.swing.JButton(); jButton41 = new javax.swing.JButton(); jButton42 = new javax.swing.JButton(); jButton43 = new javax.swing.JButton(); jButton45 = new javax.swing.JButton(); jButton46 = new javax.swing.JButton(); jButton47 = new javax.swing.JButton(); jButton48 = new javax.swing.JButton(); jButton65 = new javax.swing.JButton(); jButton66 = new javax.swing.JButton(); jButton67 = new javax.swing.JButton(); jButton68 = new javax.swing.JButton(); jButton69 = new javax.swing.JButton(); jButton72 = new javax.swing.JButton(); jButton73 = new javax.swing.JButton(); jButton74 = new javax.swing.JButton(); jButton80 = new javax.swing.JButton(); jButton82 = new javax.swing.JButton(); jButton83 = new javax.swing.JButton(); jButton84 = new javax.swing.JButton(); jButton85 = new javax.swing.JButton(); jButton88 = new javax.swing.JButton(); jButton89 = new javax.swing.JButton(); jButton90 = new javax.swing.JButton(); jButton91 = new javax.swing.JButton(); jButton75 = new javax.swing.JButton(); btnMC = new javax.swing.JButton(); jButton39 = new javax.swing.JButton(); jButton44 = new javax.swing.JButton(); jButton49 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Scientific Calc"); setType(java.awt.Window.Type.UTILITY); jTextField1.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT); jTextField1.setText("0"); jButton1.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton1.setText("sqrt"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton36.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton36.setText("exp"); jButton36.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton36ActionPerformed(evt); } }); jButton37.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton37.setText("sin"); jButton37.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton37ActionPerformed(evt); } }); jButton38.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton38.setText("cos"); jButton38.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton38ActionPerformed(evt); } }); jButton60.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton60.setText("x^2"); jButton60.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton60ActionPerformed(evt); } }); jButton61.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton61.setText("7"); jButton61.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton61ActionPerformed(evt); } }); jButton62.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton62.setText("8"); jButton62.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton62ActionPerformed(evt); } }); jButton63.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton63.setText("9"); jButton63.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton63ActionPerformed(evt); } }); jButton64.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton64.setText("-"); jButton64.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton64ActionPerformed(evt); } }); jButton40.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton40.setText("1/x"); jButton40.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton40ActionPerformed(evt); } }); jButton41.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton41.setText("log"); jButton41.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton41ActionPerformed(evt); } }); jButton42.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton42.setText("sinh"); jButton42.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton42ActionPerformed(evt); } }); jButton43.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton43.setText("cosh"); jButton43.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton43ActionPerformed(evt); } }); jButton45.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton45.setText("%"); jButton45.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton45ActionPerformed(evt); } }); jButton46.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton46.setText("Clr"); jButton46.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton46ActionPerformed(evt); } }); jButton47.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton47.setText("<-"); jButton47.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton47ActionPerformed(evt); } }); jButton48.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton48.setText("+"); jButton48.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton48ActionPerformed(evt); } }); jButton65.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton65.setText("x^3"); jButton65.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton65ActionPerformed(evt); } }); jButton66.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton66.setText("4"); jButton66.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton66ActionPerformed(evt); } }); jButton67.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton67.setText("5"); jButton67.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton67ActionPerformed(evt); } }); jButton68.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton68.setText("6"); jButton68.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton68ActionPerformed(evt); } }); jButton69.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton69.setText("*"); jButton69.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton69ActionPerformed(evt); } }); jButton72.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton72.setText("tanh"); jButton72.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton72ActionPerformed(evt); } }); jButton73.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton73.setText("x^y"); jButton73.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton73ActionPerformed(evt); } }); jButton74.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton74.setText("tan"); jButton74.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton74ActionPerformed(evt); } }); jButton80.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton80.setText("/"); jButton80.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton80ActionPerformed(evt); } }); jButton82.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton82.setText("n!"); jButton82.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton82ActionPerformed(evt); } }); jButton83.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton83.setText("1"); jButton83.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton83ActionPerformed(evt); } }); jButton84.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton84.setText("2"); jButton84.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton84ActionPerformed(evt); } }); jButton85.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton85.setText("3"); jButton85.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton85ActionPerformed(evt); } }); jButton88.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton88.setText("+/-"); jButton88.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton88ActionPerformed(evt); } }); jButton89.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton89.setText("0"); jButton89.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton89ActionPerformed(evt); } }); jButton90.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton90.setText("."); jButton90.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton90ActionPerformed(evt); } }); jButton91.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton91.setText("="); jButton91.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton91ActionPerformed(evt); } }); jButton75.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton75.setText("M-"); jButton75.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton75ActionPerformed(evt); } }); btnMC.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N btnMC.setText("MC"); btnMC.setToolTipText(""); btnMC.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnMCActionPerformed(evt); } }); jButton39.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton39.setText("MR"); jButton39.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton39ActionPerformed(evt); } }); jButton44.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton44.setText("MS"); jButton44.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton44ActionPerformed(evt); } }); jButton49.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jButton49.setText("M+"); jButton49.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton49ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(22, 22, 22) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(jButton65, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton66, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton67, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton68, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton69, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton60, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton61, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton62, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton63, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton64, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton40, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton41, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton42, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton43, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton72, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton73, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton45, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton46, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton47, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton48, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jButton88, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton89, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton90, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton91, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton82, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton83, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton84, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton85, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton80, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(btnMC, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton39, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton44, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton49, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton75, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton36, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton37, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton38, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton74, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jTextField1)) .addContainerGap(22, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnMC, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton39, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton44, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton49, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton75, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton36, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton37, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton38, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton74, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton40, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton41, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton42, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton43, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton72, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton45, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton46, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton47, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton48, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton73, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton60, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton61, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton62, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton63, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton64, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton65, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton66, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton67, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton68, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton69, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton82, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton83, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton84, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton85, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton80, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton88, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton89, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton90, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton91, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(26, Short.MAX_VALUE)) ); pack();
private void jButton74ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton74ActionPerformed
}//GEN-LAST:event_jButton74ActionPerformed private void jButton89ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton89ActionPerformed
}//GEN-LAST:event_jButton89ActionPerformed private void jButton75ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton75ActionPerformed
}//GEN-LAST:event_jButton75ActionPerformed private void jButton83ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton83ActionPerformed
private void jButton84ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton84ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "2"); }//GEN-LAST:event_jButton84ActionPerformed private void jButton85ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton85ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "3"); }//GEN-LAST:event_jButton85ActionPerformed private void jButton66ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton66ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "4"); }//GEN-LAST:event_jButton66ActionPerformed private void jButton67ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton67ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "5"); }//GEN-LAST:event_jButton67ActionPerformed private void jButton68ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton68ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "6"); }//GEN-LAST:event_jButton68ActionPerformed private void jButton61ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton61ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "7"); }//GEN-LAST:event_jButton61ActionPerformed private void jButton62ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton62ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "8"); }//GEN-LAST:event_jButton62ActionPerformed private void jButton63ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton63ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "9"); }//GEN-LAST:event_jButton63ActionPerformed private void jButton90ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton90ActionPerformed // TODO add your handling code here: jTextField1.setText(jTextField1.getText() + "."); }//GEN-LAST:event_jButton90ActionPerformed private void jButton46ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton46ActionPerformed // TODO add your handling code here: jTextField1.setText(""); }//GEN-LAST:event_jButton46ActionPerformed private void jButton47ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton47ActionPerformed // TODO add your handling code here: String backSpace = null; if(jTextField1.getText().length()>0) { StringBuilder s = new StringBuilder(jTextField1.getText()); s.deleteCharAt(jTextField1.getText().length()-1); backSpace=s.toString(); jTextField1.setText(backSpace); } }//GEN-LAST:event_jButton47ActionPerformed private void jButton48ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton48ActionPerformed // TODO add your handling code here: num1 = Double.parseDouble(jTextField1.getText()); jTextField1.setText(""); opr="+"; }//GEN-LAST:event_jButton48ActionPerformed private void jButton64ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton64ActionPerformed // TODO add your handling code here: num1 = Double.parseDouble(jTextField1.getText()); jTextField1.setText(""); opr="-"; }//GEN-LAST:event_jButton64ActionPerformed private void jButton69ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton69ActionPerformed // TODO add your handling code here: num1 = Double.parseDouble(jTextField1.getText()); jTextField1.setText(""); opr="*"; }//GEN-LAST:event_jButton69ActionPerformed private void jButton80ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton80ActionPerformed // TODO add your handling code here: num1 = Double.parseDouble(jTextField1.getText()); jTextField1.setText(""); opr="/"; }//GEN-LAST:event_jButton80ActionPerformed private void jButton45ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton45ActionPerformed // TODO add your handling code here: num1 = Double.parseDouble(jTextField1.getText()); jTextField1.setText(""); opr="%"; }//GEN-LAST:event_jButton45ActionPerformed private void jButton91ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton91ActionPerformed // TODO add your handling code here: num2 = Double.parseDouble(jTextField1.getText()); if (opr == "+") { result = num1+num2; jTextField1.setText(Double.toString(result)); } else if (opr=="-") { result=num1-num2; jTextField1.setText(Double.toString(result)); } else if (opr=="*") { result=num1*num2; jTextField1.setText(Double.toString(result)); } else if (opr=="/") { result=num1/num2; jTextField1.setText(Double.toString(result)); } else if (opr=="%") { result=num1%num2; jTextField1.setText(Double.toString(result)); } else if (opr == "x^y") { for (int i=0; i private void jButton42ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton42ActionPerformed }//GEN-LAST:event_jButton42ActionPerformed private void jButton37ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton37ActionPerformed
}//GEN-LAST:event_jButton37ActionPerformed private void jButton38ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton38ActionPerformed
}//GEN-LAST:event_jButton38ActionPerformed private void jButton43ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton43ActionPerformed
}//GEN-LAST:event_jButton43ActionPerformed private void jButton72ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton72ActionPerformed
}//GEN-LAST:event_jButton72ActionPerformed private void jButton41ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton41ActionPerformed
}//GEN-LAST:event_jButton41ActionPerformed private void jButton36ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton36ActionPerformed
}//GEN-LAST:event_jButton36ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
}//GEN-LAST:event_jButton1ActionPerformed private void jButton40ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton40ActionPerformed
}//GEN-LAST:event_jButton40ActionPerformed private void jButton60ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton60ActionPerformed
private void jButton65ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton65ActionPerformed private void jButton73ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton73ActionPerformed private void jButton82ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton82ActionPerformed private void jButton88ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton88ActionPerformed private void btnMCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMCActionPerformed }//GEN-LAST:event_btnMCActionPerformed private void jButton39ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton39ActionPerformed
private void jButton49ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton49ActionPerformed }//GEN-LAST:event_jButton49ActionPerformed private void jButton44ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton44ActionPerformed
|
ma'muriyatiga murojaat qiling