I am new to java and have been given a task of designing an applet that places the input string into a charcheter array and displays it. Also every letter "l" that appears must be displayed in red, and every letter "y" must be displayed in green. I have the following code but it doesn't work
Another thing I have to do is to be able to position the drawing point of the string with the mouse. I have no idea how to do any of this and any help will be appreciated. Thanksimport java.awt.*; import java.applet.*; import java.awt.event.*; import java.awt.Graphics; public class mix extends Applet implements ActionListener { Button okButton; String text1; public void paint(Graphics g) { g.setFont (new Font ("Helvetica", Font.BOLD, 20)); g.setColor (Color.black); g.drawString(text1,20,100); if(text1.equals("l")) g.setColor (Color.red); if(text1.equals("y")) g.setColor (Color.green); } public void init() { setLayout(new FlowLayout()); okButton = new Button("Enter Text"); text1 = new String("",30); add(okButton); String(text1); okButton.addActionListener(this); } public void actionPerformed(ActionEvent evt) { if (evt.getSource() == okButton) repaint(); } }