home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-03-26 | 1.2 KB | 49 lines |
- import java.awt.*;
- import java.applet.*;
-
- public class StringApplet extends Applet
- {
- TextField textField1;
- TextField textField2;
-
- public void init()
- {
- textField1 = new TextField(20);
- textField2 = new TextField(20);
-
- textField1.setText("STRING");
- textField2.setText("String");
-
- add(textField1);
- add(textField2);
- }
-
- public void paint(Graphics g)
- {
- String str1 = textField1.getText();
- String str2 = textField2.getText();
-
- boolean equal = str1.equalsIgnoreCase(str2);
- if (equal)
- g.drawString("The strings are equal.", 70, 100);
- else
- g.drawString("The strings are not equal.", 70, 100);
-
- String newStr = str1.concat(str2);
-
- g.drawString("JOINED STRINGS:", 70, 130);
- g.drawString(newStr, 80, 150);
-
- g.drawString("STRING LENGTH:", 70, 180);
- int length = newStr.length();
- String s = String.valueOf(length);
- g.drawString(s, 80, 200);
- }
-
- public boolean action(Event evt, Object arg)
- {
- repaint();
- return true;
- }
- }
-