user2179627
user2179627

Reputation: 381

To use Tooltip in showconfirmDialog

I am trying to use the Tooltip feature of JButton in a Dialogue Box. I am using the showconfirmDialog feature. The code is something like this

int optionSelection =  javax.swing.JOptionPane.showConfirmDialog(
    null,
    "you have selected XXX checkbox. This will edit YYY file.\n Do you wish to proceed?",
    null,
    javax.swing.JOptionPane.YES_NO_CANCEL_OPTION,
    javax.swing.JOptionPane.QUESTION_MESSAGE);
if (optionSelection == javax.swing.JOptionPane.YES_OPTION) {
    //Do something here
} else if (optionSelection == javax.swing.JOptionPane.NO_OPTION) {
    //do something else here
} else {
    //do something different from the above two
}

But how do I add the toolTip feature for each of the Buttons? Should I create the JOptionPane and Buttons and then create the toolTip or is there any other alternative?

Upvotes: 0

Views: 313

Answers (1)

Ordous
Ordous

Reputation: 3884

You cannot do this with a showConfirmDialog(), however if you use showOptionDialog you can pass Object[] as the last argument as the options. If those are instances of Component the JOptionPane will use them instead of creating its own buttons.

Upvotes: 1

Related Questions