Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import javax.swing.JFrame;
- /**
- *
- *
- * @author Giacinto Di Santis
- * @version 02.04.2020
- */
- public class IdenticonFrame extends JFrame {
- public final int MARGIN = 50;
- public IdenticonFrame() {
- super("IdemticonFrame");
- this.setDefaultCloseOperation(EXIT_ON_CLOSE);
- this.setSize(300,300);
- }
- public boolean avatar[][]={
- {true, true, true, true, true},
- {false, false, false, false, false},
- {true, false, true, false, true},
- {true, false, false, false, true},
- {true, false, false, false, true}
- };
- public void paint(final Graphics g) {
- super.paint(g);
- int x;
- int y;
- for(x = 0; x < avatar.length; x++){
- for(y = 0; y < avatr[x].length; y++){
- if(avatar[x][y] == true){
- g.setColor(Color.BLACK);
- }else{
- g.setColor(Color.WITHE);
- }
- if(getHeight() > getWidth()){
- g.fillRect(0, 0, (getWidth() - (2 * MARGIN)) / 5, (getWidth() - (2 * MARGIN)) / 5);
- }else{
- g.fillRect(0, 0, (getHeigth() - (2 * MARGIN)) / 5, (getHeigth() - (2 * MARGIN)) / 5);
- }
- }
- }
- }
- public static void main(final String[] args) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new IdenticonFrame().setVisible(true);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement