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.
Standard Labor Rate
A predetermined rate used to allocate labor costs to products or services, based on the expected or average wage rate for labor.
Employment Taxes
Taxes that employers are required to pay on behalf of their employees, such as social security and Medicare taxes.
Variable Overhead Efficiency Variance
A measure of the efficiency with which variable overhead resources are utilized, calculated by comparing the actual usage against the budgeted or standard usage.
Standard Price
A predetermined cost assigned to materials, labor, and overhead used in budgeting and variance analysis.
Q4: Use the _ applet method to perform
Q6: If a superclass contains only constructors that
Q19: Java's Object class contains a public method
Q24: Ruth Behar, in her book The Vulnerable
Q47: Surrounded by angle brackets<br>A)current version of HTML<br>B)init()<br>C)start()<br>D)HTML<br>E)Applet
Q51: When you use BorderLayout, you are required
Q53: How do you change the font of
Q61: _ is an abstract class used in
Q64: Create a class named Account that contains
Q66: Provide an example of batch processing.