package graphtest; import javax.swing.*; import java.awt.*; import java.awt.Color; public class Panel extends JPanel { @Override // переозначення методу малювання public void paintComponent (Graphics g) { super.paintComponent(g); g.setColor(Color.yellow); Graphics2D g2 = (Graphics2D) g; float [] t ={0.0f, 0.167f, 0.333f, 0.5f, 0.667f, 0.833f, 1.0f}; Color [] c = {Color.red, Color.orange, Color.yellow, Color.green,Color.cyan, Color.blue, new Color(139, 0, 255)}; LinearGradientPaint gp = new LinearGradientPaint (200.f, 0.f, 400.f, 0.f, t, c, MultipleGradientPaint.CycleMethod.NO_CYCLE); g2.setPaint (gp); g2.fill (new Rectangle.Double (10, 10, 700, 50)); gp = new LinearGradientPaint (200.f, 0.f, 400.f, 0.f, t, c, MultipleGradientPaint.CycleMethod.REFLECT); g2.setPaint (gp); g2.fill (new Rectangle.Double (10, 70, 700, 50)); gp = new LinearGradientPaint (200.f, 0.f, 400.f, 0.f, t, c, MultipleGradientPaint.CycleMethod.REPEAT); g2.setPaint (gp); g2.fill (new Rectangle.Double (10, 130, 700, 50)); RadialGradientPaint gr = new RadialGradientPaint (110.f, 200.f, 50.f, t, c, MultipleGradientPaint.CycleMethod.NO_CYCLE); g2.setPaint (gr); g2.fill (new Rectangle.Double (10, 200, 200, 100)); gr = new RadialGradientPaint (330.f, 200.f, 50.f, t, c, MultipleGradientPaint.CycleMethod.REFLECT); g2.setPaint (gr); g2.fill (new Rectangle.Double (230, 200, 200, 100)); gr = new RadialGradientPaint (550.f, 200.f, 50.f, t, c, MultipleGradientPaint.CycleMethod.REPEAT); g2.setPaint (gr); g2.fill (new Rectangle.Double (450, 200, 200, 100)); } }