Hello,
I tried to use CircleButton instead of JButton. It works fine except when I want to color these buttons. Maybe there is something I have missed ?
Below if my code. As you can seen my original JButton are colored in green and red. However I have no color when changing JButton by CircleButton.
Thanks
Gerard
import java.awt.Color;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JButton;
public class OuiNon extends javax.swing.JDialog
{
/*--------------------------------------------------------------------------------------------------------*/
/* Variables et constantes */
/*--------------------------------------------------------------------------------------------------------*/
private static final long serialVersionUID = 6525398796677379148L;
private JButton Non = null,
Oui = null;
private JPanel monPanneau = null;
private JEditorPane montexte = null;
public boolean reponse = false;
private JScrollPane scroll = null;
/*---------------------------Fin des déclaratives-----------------------------------------------è---------*/
public OuiNon()
{
super();
créerBoites();
}
public OuiNon(java.awt.Frame owner, String msg, boolean modal)
{
super(owner,"Répondre par Oui ou Non", modal);
initialize(msg);
}
private void créerBoites()
{
setName("YesNo");
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setSize(503, 357);
montexte = new JEditorPane();
montexte.setName("montexte");
montexte.setText(" ");
montexte.setBounds(11, 5, 462, 220);
montexte.setContentType("text/html");
scroll = new JScrollPane(montexte);
scroll.setBounds(11, 5, 462, 220);
Non = new JButton("");
Non.setName("ExecNon");
Non.setText("Non");
Non.setOpaque(true);
Non.setBackground(new Color(255,0,0));
Non.setBounds(337, 256, 89, 23);
Non.addActionListener(e -> { reponse = false;setVisible(false);});
Oui = new JButton("");
Oui.setName("ExecOui");
Oui.setText("Oui");
Oui.setOpaque(true);
Oui.setBackground(new java.awt.Color(0,255,0));
Oui.setBounds(67, 256, 89, 23);
Oui.addActionListener(e -> { reponse = true;setVisible(false);});
monPanneau = new JPanel();
monPanneau.setName("monPanneau");
monPanneau.setLayout(null);
monPanneau.add(Oui);
monPanneau.add(Non);
monPanneau.add(scroll);
setContentPane(monPanneau );
this.setLocationRelativeTo (null);
}
private void initialize(String msg)
{
créerBoites();
if (! msg.startsWith("<html>"))
{
montexte.setText("<html><font size=-1 color=black><b>" + msg + "</b></font></html>");
}
else
{
montexte.setText( msg);
}
setVisible(true);
}
public static void main(java.lang.String[] args)
{
new OuiNon(null,"Ceci est mon texte", false);
}
}