1 year ago

#318894

test-img

ehuff

Center Button Option in JOptionPane Modal

I am wondering if there is anyway to center my "Overwrite" option/button within the JOptionPane call. Currently, the button automatically styles to the right side of the modal like so:

enter image description here

The code:

public String clearScansWarningModal() {
    Object[] options = {"Overwrite"};
    
    int selectedOption= JOptionPane.showOptionDialog(null,
            "You are attempting to open a scan file on top of an already existing one.\n"
            +"Choosing Overwrite will clear the workspace before opening the new file.\n",              
            "Warning!",
            JOptionPane.ERROR_MESSAGE,
            2, 
            null,
            options,  
            options[0]); 
    
    LOGGER.info("User selected " + options[selectedOption]);
    return (String)options[selectedOption];
} 

If not within the JOptionPane call, what would likely be the next best solution? Any help would be appreciated.

Thanks!

java

joptionpane

0 Answers

Your Answer

Accepted video resources