Issue
I would like to increase the button size of a JOptionePane. The code for the JOptionPane of the button is:
addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent evt) {
if (JOptionPane.showConfirmDialog(rootPane, "¿Desea salir de la aplicación?",
"Gestor de clientes", JOptionPane.ERROR_MESSAGE) == JOptionPane.ERROR_MESSAGE) {
dispose();
Login login = new Login();
login.setVisible(true);
}
}
});
How can I increase the font of the text and the size of the button?
Solution
This code can help you with showOptionDialog :
import java.awt.Color;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class CustomizedJOption {
public static void main(String[] args) {
//Confirm button
JButton btnYes = new JButton ( " OK ");
btnYes.setFont(new Font("young circle", Font.BOLD, 30));
btnYes.setForeground(Color.MAGENTA);
//Negative button
JButton btnNo = new JButton ( " No ");
btnNo.setFont(new Font("young circle", Font.ITALIC, 30));
btnNo.setForeground(Color.blue);
//Add button options to the array
Object [] options = {btnYes, btnNo} ;
//text content
JLabel label = new JLabel ( "\"¿Desea salir de la aplicación?\"");
label.setForeground(Color.BLUE);
label.setFont(new Font("young circle", Font.ITALIC, 30));
//Display Dialog
JOptionPane .showOptionDialog(null, label, "Title", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, options[0]);
}
}
Answered By - Oussama ZAGHDOUD


0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.