How to make only one jbutton in java frame have a gradient (3 colors) and be rounded?

26 Views Asked by At

JButton with gradient:

https://i.stack.imgur.com/NZ3gC.gif

Title is self-explanatory. I'm using jforms for this. I only want to edit the jbuttons of my existing jform. I also used this video as a guide

private Color color1 Color.decode("#32162C");
private Color color2 Color.decode("#824678");
private Color color3 Color.decode("#A96CE6");
 
//these 3 lines errors for me`


 private void paintComponent (Graphics grphcs){
 
 int width = getWidth();
 int height = getHeight();
 BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
         //the video used Graphics2d but mine errors
 Graphics g2 = img.createGraphics();
 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
         //setRenderingHint errors for me ("cannot find symbol")
 
 
         //GRADIENT COLOR
 GradientPaint gra = new GradientPaint(0, 0, color1, width,0,color2, 0, color3);
         //GradientPaint line errors for me ("no suitable constructor found)
 g2.setPaint(gra);
         //setPaint errors for me
 g2.fillRoundRect(0,0, width, height, height, height);
 grphcs.drawImage(img, width, width, null);
 super.paintComponents(grphcs);
     }
0

There are 0 best solutions below