Q:

Highlight selected value in JList

I write a java program to draw a rectangle and fill it with selected color from colors in the java list and its work very well, except that the selected value doesn't highlight when I click it. 
However, I can use the arrow keys to move up and down but I don't know where I am. 
My Java code:
import java.awt. Color;
import java.awt. Dimension;
import java.awt. FlowLayout;
import java.awt. Graphics;
import java.awt. Graphics2D;
import java.awt.event. WindowAdapter;
import java.awt.event. WindowEvent;
import java.awt.geom. Rectangle2D;
import java.util. HashMap;
import javax.swing.*; 

import javax.swing.event. ListSelectionListener;

public class Test extends JApplet {

    private JList list;
    private String[] colors = {"pink","lightGreen","orange","lightRed"}
    private HashMap<String, Color> colorsMap= new HashMap<>();

    public Test(){

     setLayout(new FlowLayout());

     colorsMap.put("pink",Color. PINK);
     colorsMap.put("lightGreen",new Color(202,230,147));
     colorsMap.put("orange",Color. ORANGE);
     colorsMap.put("lightRed",new Color(255,144,133));

    list = new JList(colors);
    list.setVisibleRowCount(2);
    list.setSelectionMode(ListSelectionModel. SINGLE_SELECTION);
    add(new JScrollPane(list));

    list.addListSelectionListener(
        new ListSelectionListener(){
         public void valueChanged(ListSelectionEvent event){
             getContentPane().setFocusable(true);
             repaint();
         }  
        }
        );

    }

    public void paint(Graphics g) {

      Graphics2D g2 = (Graphics2D) g;

      int x = 5;
      int y = 110;

      g2.setPaint(colorsMap.get(list.getSelectedValue()));
      g2.fill(new Rectangle2D.Double(x, y, 490, 360));

  }

  public static void main(String s[]) {
    JFrame f = new JFrame("Colors");
    f.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);

    JApplet applet = new Test();
    f.add(applet);
    f.pack();
    f.setSize(new Dimension(500, 500));
    f.setVisible(true);

  }
}

A:

public void paint(Graphics g) {
    // ..

Should be: 
public void paint(Graphics g) {
    super.paint(g);
    // ..

Doing the call to super method is the proper way to implement the paint chain in a custom painted component.