🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / Java / PANELDEKİ TOPLAM COMPANENT SAYISINI BULUR

 

1-) Java - PANELDEKİ TOPLAM COMPANENT SAYISINI BULUR

 

public class C2 extends javax.swing.JFrame {

 

public C2() {

 

initComponents();

 

Component[] panel_comp = jPanel1.getComponents();

 

int num1 = 0, num2 = 0;

 

for (int i = 0; i < panel_comp.length; i++) {

 

if (panel_comp[i].getName().equals("T1")) {

 

num1 = Integer.valueOf(((JTextField) panel_comp[i]).getText()); }

 

if (panel_comp[i].getName().equals("T2")) {

 

num2 = Integer.valueOf(((JTextField) panel_comp[i]).getText()); } }

 

Component[] panel2_comp = jPanel2.getComponents();

 

for (int i = 0; i < panel2_comp.length; i++) {

 

if (panel2_comp[i].getName().equals("L1")) {

 

((JLabel) panel2_comp[i]).setText(String.valueOf(num1 + num2)); } } }

 2021 Ocak 18 Pazartesi
 369