import java.awt.*; import javax.swing.*; public class PinstripeDisplay extends JPanel { final int bands = 4; public PinstripeDisplay() { setPreferredSize(new Dimension(900, 600)); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); int h = getHeight(); for (int b = 1; b <= bands; b++) { for (int x = 0, colIndex = 0; x < getWidth(); x += b, colIndex++) { g.setColor(colIndex % 2 == 0 ? Color.white : Color.black); g.fillRect(x, (b - 1) * (h / bands), x + b, b * (h / bands)); } } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setTitle("PinstripeDisplay"); f.add(new PinstripeDisplay(), BorderLayout.CENTER); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); } }); } }