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 < NUM; ++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 JPanels and a GridLayout are used to achieve this effect.
Lex Mercatoria
Lex Mercatoria, also known as the law merchant, is a body of commercial law used by merchants throughout Europe during the medieval period, forming the basis of modern commercial law.
Commercial Money Market
A segment of the financial market where commercial banks and other institutions lend and borrow short-term, high-quality debt securities.
Unconditionally
Without any conditions or limitations; absolutely.
Draft
A preliminary version of a piece of writing or document that is open for discussion, modification, or approval.
Q3: You can use Java's _ class to
Q9: The Sapir-Whorf hypothesis (also called the principle
Q12: When you type "A", two _ key
Q15: You have a Student class with a
Q30: According to Karl Marx, how could a
Q46: Java provides a(n) _ class, which contains
Q49: The draw3DRect() method is used to draw
Q77: You're conducting research on violence in the
Q79: What are the goals of ethnography?<br>A) to
Q95: When researchers use a social networking site