└── scr /scr: -------------------------------------------------------------------------------- 1 | import javax.swing.SwingUtilities; 2 | 3 | public class SpaceViewJava extends JPanel { 4 | 5 | private static final long serialVersionUID = 1L; 6 | private Random random; 7 | private Ellipse2D sun; 8 | 9 | public SpaceViewJava() { 10 | setBackground(java.awt.Color.BLACK); 11 | random = new Random(); 12 | sun = new Ellipse2D.Double(getWidth() / 2 - 25, getHeight() / 2 - 25, 50, 50); 13 | } 14 | 15 | @Override 16 | protected void paintComponent(Graphics g) { 17 | super.paintComponent(g); 18 | Graphics2D g2d = (Graphics2D) g; 19 | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 20 | 21 | // Рисуем звездное небо 22 | for (int i = 0; i < 500; i++) { 23 | int x = random.nextInt(getWidth()); 24 | int y = random.nextInt(getHeight()); 25 | g2d.fillOval(x, y, 1, 1); 26 | } 27 | --------------------------------------------------------------------------------