1. Java / Говнокод #23592

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    
    public class Gitis implements ActionListener{
        JFrame frame;
    
        public static void main(String[] args) {
            Gitis gitis = new Gitis();
            gitis.go();
        }
    
        public void go(){
            frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            JButton button = new JButton("Next Color");
            button.addActionListener(this);
    
            MyDrawPanel panel = new MyDrawPanel();
    
            frame.getContentPane().add(BorderLayout.SOUTH, button);
            frame.getContentPane().add(BorderLayout.CENTER, panel);
            frame.setSize(500, 500);
            frame.setVisible(true);
            frame.setTitle("Paint Oval");
        }
        public void actionPerformed(ActionEvent event){
            frame.repaint();
        }
    }
    
    class MyDrawPanel extends JPanel{
        public void paintComponent(Graphics g){
    
            g.fillRect(0, 0, this.getWidth(),this.getHeight());
    
            int one = (int) (Math.random() * 255);
            int two = (int) (Math.random() * 255);
            int three = (int) (Math.random() * 255);
    
            Color color = new Color(one, two, three);
            g.setColor(color);
            g.fillOval(40, 70 , 50, 50);
        }
    }

    Смена цвета окружности по нажатию кнопки, Оцените код!

    Запостил: babushkaAntona, 16 Декабря 2017

    Комментарии (0) RSS

    Добавить комментарий

    Ошибка компиляции комментария:
    1. Гости могут высказаться только во вторник, пятницу или субботу
    ava Семь раз отмерь — один отрежь, guest!
    А не использовать ли нам bbcode?
    • [b]жирный[/b] — жирный
    • [i]курсив[/i] — курсив
    • [u]подчеркнутый[/u] — подчеркнутый
    • [s]перечеркнутый[/s] — перечеркнутый
    • [blink]мигающий[/blink] — мигающий
    • [color=red]цвет[/color] — цвет (подробнее)
    • [size=20]размер[/size] — размер (подробнее)
    • [code=<language>]some code[/code] (подробнее)
    Проверочный код