Changing the colors of my JMenu and JMenuItems

Use setForeground and setBackground. You can change the default selection colors using the UIManager.

Main.java:

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
    
public class Main extends JFrame {
   public Main() {
      getContentPane().setLayout(new FlowLayout());
  
      // change default selection colors
      UIManager.put("Menu.selectionBackground", 
             new javax.swing.plaf.ColorUIResource(Color.blue));
      UIManager.put("MenuItem.selectionBackground", 
             new javax.swing.plaf.ColorUIResource(Color.green));
 
      JMenuBar menuBar = new JMenuBar();
      JMenu menu = new JMenu("Sex");
      JMenuItem menuItem1 = new JMenuItem("male");
      JMenuItem menuItem2 = new JMenuItem("female");
      JMenuItem menuItem3 = new JMenuItem("androgyne");
 
      menuItem1.setBackground(Color.red);
      menuItem1.setForeground(Color.yellow);
      menuItem2.setBackground(Color.red);
      menuItem2.setForeground(Color.yellow);
      menuItem3.setBackground(Color.red);
      menuItem3.setForeground(Color.yellow);
  
      menu.setBackground(Color.white);
      menu.setForeground(Color.blue);
 
      // add the MenuItems to the Menu 
      menu.add(menuItem1);
      menu.add(menuItem2);
      menu.add(menuItem3);
  
      menuBar.add(menu);
  
      this.setJMenuBar(menuBar); 
  
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
            System.exit(0);   
         }      
      });
  
      setSize(400, 400);
   }
  
   public static void main(String[] args) {
      (new Main()).show();
   }
}