Examlex
import java.awt.*;
import javax.swing.*;
import java.awt.Color;
public class Checkerboard extends JFrame
{
private final int ROWS = 8;
private final int COLS = 8;
private final int GAP = 2;
private final int NUM = ROWS * COLS;
private int x;
private JPanel pane = new JPanel
(new GridLayout(ROWS, COLS, GAP, GAP));
private JPanel[] panel = new JPanel[NUM];
private Color color1 = Color.WHITE;
private Color color2 = Color.BLUE;
private Color tempColor;
public Checkerboard()
{
super("Checkerboard");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(pane);
for(x = 0; x
{
panel[x] = new JPanel();
pane.add(panel[x]);
if(x % COLS == 0)
{
tempColor = color1;
color1 = color2;
color2 = tempColor;
}
if(x % 2 == 0)
panel[x].setBackground(color1);
else
panel[x].setBackground(color2);
}
}
public static void main(String[] args)
{
Checkerboard frame = new Checkerboard();
final int SIZE = 300;
frame.setSize(SIZE, SIZE);
frame.setVisible(true);
}
}
The above code creates a loop to fill even-positioned squares with one color and odd-positioned squares with another color, resulting in a checkerboard pattern. Describe how JPanel s and a GridLayout are used to achieve this effect.
Chinese
Relating to China, its people, languages, or culture, including aspects of its history, traditions, and socioeconomic development.
Demand Deposits
Bank accounts from which deposited funds can be withdrawn at any time without any notice to the institution.
Federal Reserve District Bank
One of the 12 regional banks in the Federal Reserve System of the United States, each responsible for implementing the country's monetary policy within its specific district.
Reserve
A portion of funds or resources set aside for specific future use, often related to monetary or commodity resources within financial institutions or government reserves.
Q2: What is meant by saying that non-human
Q3: How could one be an objectivist or
Q10: If a woman says she has a
Q12: The _ option must be used when
Q14: How could a particular society play a
Q15: How many people in the world are
Q21: Label the following as examples of Utilitarian
Q27: Pointing to the liability to abuse of
Q51: BasicStroke class variables determine the endcap and
Q54: The _ method can be used when