fork download
  1. import javax.swing.*;
  2. import java.awt.*;
  3.  
  4. public class Gradation extends JFrame {
  5.  
  6. public static void main(String[] args) {
  7. Gradation gradation = new Gradation("グラデーション");
  8. gradation.setVisible(true);
  9. }
  10.  
  11. Gradation(String title) {
  12. setTitle(title);
  13. setSize(450, 450);
  14. setLocationRelativeTo(null);
  15. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  16.  
  17. JPanel panel = new JPanel();
  18. GridLayout layout = new GridLayout(16, 16, 2, 2);
  19. panel.setLayout(layout);
  20.  
  21. for (int i = 0; i < 16 * 16; i++) {
  22. JLabel label = new JLabel();
  23. label.setBackground(new Color(0, 0, i));
  24. label.setOpaque(true);
  25. panel.add(label);
  26. }
  27.  
  28. getContentPane().add(panel, BorderLayout.CENTER);
  29. }
  30.  
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: class Gradation is public, should be declared in a file named Gradation.java
public class Gradation extends JFrame {
       ^
1 error
stdout
Standard output is empty