Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Pinstripe-Display/Java/pinstripe-display.java
Normal file
38
Task/Pinstripe-Display/Java/pinstripe-display.java
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue