import java.awt.* import javax.swing.* fun main() { SwingUtilities.invokeLater { val panel = object: JPanel() { override fun paintComponent(g: Graphics) { super.paintComponent(g) val scale = 4; for (i in 0..63) { g.setColor( Color(i * 4, 0, 255 - i * 4)) g.fillRect(i * scale, 0, scale, 40) } } } panel.setPreferredSize(Dimension(256, 40)) val frame = JFrame("Gradation") frame.add(panel) frame.pack() frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE) frame.setVisible(true) } }