This activity looks at fonts and colours.
In the window below colours of the words don't match the colour names. Try to go quickly from top left to bottom right saying aloud what the colours of the words are (not what the words are, i.e. the first thing you should say is 'red'). It's very difficult!

This is known as the Stroop effect, after its discoverer. Your task is to write a Java program to display such a window.
We want you to write the program so that each word occupies a separate panel of its own and the panels are then arranged on the content pane of a frame, in a grid layout.
A panel will have two attributes, colour and word, and when it is made visible it will display the given word using the given colour.
When the enclosing frame is made visible the panels it holds will automatically be displayed as well, and so the coloured words will appear.
Create a new project MyEx7_4 in the Unit 7 folder, naming the main class myex7_4.CrazyColorsTest.
Add a class ColorPanel to the current project. This class should have two instance variables to represent the colour and the word, and a two-argument constructor ColorPanel(Color c, String s) that sets these attributes. The paint method in ColorPanel should set the current graphics colour using the colour attribute of the panel, set the current font to 18-point bold serif, then use the method drawString(String,int,int)to display the word. The two int arguments determine where on the panel the word will be displayed; you will probably need to experiment with the numbers to get the position right.
Next add a class CrazyColors that extends JFrame. Its constructor should set the title, size and so on in the usual way, then get the content pane and set it to a grid layout.
The constructor should then create 12 instances of ColorPanel, with suitable colours and words for demonstrating the Stroop effect, and add them to the content pane. However for testing purposes we suggest you create only one panel to start with, adding the others later once you know a panel displays correctly.
Finally complete CrazyColorsTest so it creates an instance of CrazyColors and makes it visible. Run your program to test it.
For our sample solutions see classes ColorPanel, CrazyColors and CrazyColorsTest in the Solution file.