0

agregue una clase para modificar el radio de un boton en java pero al momento de usarla provoca un desbordamiento de color que no se acomoda al radio sino al rectangulo normal. Esta es la clase que implemente para el boton

static class RoundedBorder implements Border {

    private int radius;

    RoundedBorder(int radius) {
        this.radius = radius;
    }

    public Insets getBorderInsets(Component c) {
        return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);
    }

    public boolean isBorderOpaque() {
        return true;
    }

    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        g.drawRoundRect(x, y, width-1, height-1, radius, radius);
    }
}

Asi cree el boton

JButton Boton_Registrar = new JButton("Entrar");
        Boton_Registrar.setForeground(Color.BLACK);
        Boton_Registrar.setBackground(new Color(149,213,178));
        Boton_Registrar.setBounds(210, 470, 150, 40);
        Boton_Registrar.setFont(new Font("montserrat", Font.BOLD, 16));
        Boton_Registrar.setBorder(new RoundedBorder(30));

Asi se muestra

3

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.