Displaying Numeric Values in Applet एप्लेट में संख्यात्मक मान प्रदर्शित करना
In Java applets, numeric values are displayed using the
drawString()
method from the Graphics class.
जावा एप्लेट्स में संख्यात्मक मानों को ग्राफ़िक्स क्लास की drawString()
मेथड का उपयोग करके प्रदर्शित किया जाता है।
To do this, the numeric value must first be converted into a string using the String.valueOf()
method.
इस कार्य को करने के लिए, संख्यात्मक मान को पहले String.valueOf()
मेथड की सहायता से स्ट्रिंग में बदला जाता है।
🧪 Example: Displaying sum of two numbers दो संख्याओं का योग दिखाना
// Java File: temp.java
import java.awt.*;
import java.applet.*;
public class temp extends Applet {
public void paint(Graphics g) {
int x = 10;
int y = 25;
int add = x + y;
String s = "add: " + String.valueOf(add);
g.drawString(s, 100, 100);
}
}
🖥️ HTML File to load applet एप्लेट लोड करने हेतु HTML फाइल:
<html>
<body>
<applet code="temp.class" width="600" height="400"></applet>
</body>
</html>
Comments
Post a Comment