Taking Input from User in Java Applet जावा एप्लेट में यूजर से इनपुट ग्रहण करना

Java Applets allow user input through components like TextFieldLabel, and Button.

जावा एप्लेट में यूजर इनपुट को प्राप्त करने के लिए TextFieldLabel, और Button जैसे कंपोनेंट्स का उपयोग किया जाता है।

To use them, we first create their objects and add them using the add() method.
इनका प्रयोग करने के लिए पहले इनके ऑब्जेक्ट बनाए जाते हैं और add() मेथड से एप्लेट में जोड़ा जाता है।

📌 Component Declaration Format कंपोनेंट डिक्लेरेशन प्रारूप:

TextField object_name = new TextField(size);  
Label label_object_name = new Label("label_name");  
Button button_object_name = new Button("button_name");

🔧 Example: Taking two inputs and displaying total दो इनपुट लेकर कुल मान प्रदर्शित करना

// File: ThreeControlApplet.java  
import java.awt.*;  
import java.applet.*;  

public class ThreeControlApplet extends Applet {  
    TextField txtBox1 = new TextField(10);  
    TextField txtBox2 = new TextField(10);  
    TextField txtTotal = new TextField(10);  

    Label lblLabel1 = new Label("First Value");  
    Label lblLabel2 = new Label("Second Value");  
    Label lblTotal = new Label("Total");  

    Button OKButton = new Button("Calculate");  

    public void init() {  
        add(lblLabel1);  
        add(txtBox1);  
        add(lblLabel2);  
        add(txtBox2);  
        add(lblTotal);  
        add(txtTotal);  
        add(OKButton);  
    }  
}

🧾 This applet displays input fields and a button, but you must add event handling using ActionListener for full interactivity.
🧾 यह एप्लेट इनपुट फील्ड्स और बटन तो दिखाता है, लेकिन पूरी इंटरैक्टिविटी हेतु ActionListener का प्रयोग आवश्यक है।

Comments

Popular posts from this blog

What is a Web Browser? वेब ब्राउज़र क्या है?

Java's Support System जावा का सहयोगी तंत्र

The Internet and Java इंटरनेट और जावा का सम्बन्ध