CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
28
Task/Colour-bars-Display/Java/colour-bars-display.java
Normal file
28
Task/Colour-bars-Display/Java/colour-bars-display.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class ColorFrame extends JFrame {
|
||||
public ColorFrame(int width, int height) {
|
||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
this.setSize(width, height);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
Color[] colors = { Color.black, Color.red, Color.green, Color.blue,
|
||||
Color.pink, Color.CYAN, Color.yellow, Color.white };
|
||||
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
g.setColor(colors[i]);
|
||||
g.fillRect(this.getWidth() / colors.length * i, 0, this.getWidth()
|
||||
/ colors.length, this.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
new ColorFrame(200, 200);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue