-2

I want to set my JButton background color with half red and half blue. Can I do that in java swing without using graphics 2D? Please help me!

Alonepmk
  • 13
  • 3

1 Answers1

0

You can do it by making it gradient.

   buttonGraphics.setPaint(new GradientPaint(
                        new Point(0, 0), 
                        Color.RED, 
                        new Point(0, getWidth()), 
                        Color.BLUE()));
                buttonGraphics.fillRect(0, 0, getWidth(), getHeight());
                buttonGraphics.dispose()
O. Collins
  • 38
  • 3