import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.HashMap;

/* <applet code="ColorName.class" width="250" height="80">
   </applet> */

public class ColorName extends JApplet implements ActionListener {
        HashMap<String, Color> hm;
        JTextField input;

        @Override
        public void init() {
                // http://www.colordic.org/w/ æčē
                hm = new HashMap<String, Color>();
                hm.put("ž", new Color(0xf7acbc)); hm.put("Ô", new Color(0xed1941));
                hm.put("é", new Color(0xf26522)); hm.put("", new Color(0xf58f98));
                hm.put("ę", new Color(0xaa2116)); hm.put("§", new Color(0xfedcbd));
                hm.put("ō", new Color(0xf47920)); hm.put("", new Color(0x843900));
                hm.put("Đ", new Color(0xffd400)); hm.put("ęS", new Color(0xcbc547));
                hm.put("éō", new Color(0x87943b)); hm.put("Î", new Color(0x45b97c));
                hm.put("S", new Color(0x005344)); hm.put("", new Color(0xafdfe4));
                hm.put("Â", new Color(0x009ad6)); hm.put("", new Color(0x145b7d));
                hm.put("Ū", new Color(0x003a6c)); hm.put("äŋ", new Color(0x6ff0aa));
                hm.put("Ą", new Color(0xafb4db)); hm.put("", new Color(0x8552a1));
                hm.put("", new Color(0xfffffb)); hm.put("D", new Color(0x77787b));
                hm.put("", new Color(0x130c0e)); hm.put("g", new Color(0xd7003a));
                input = new JTextField("g", 8);
                input.addActionListener(this);
                setLayout(new FlowLayout());
                add(input);
        }

        @Override
        public void paint(Graphics g) {
                String text = input.getText();
                super.paint(g);
                g.setFont(new Font("SansSerif", Font.BOLD, 64));
                int i;
                for (i=0; i<text.length(); i++) {
                        String c = text.substring(i, i+1);
                        Color color = hm.get(c);
                        if (color==null) {
                                color = Color.BLACK;
                        }
                        g.setColor(color);
                        g.drawString(c, 64*i, 100);
                }
        }

        public void actionPerformed(ActionEvent e) {
                repaint();
        }
}
