I\'m trying to get the PayPal logo come up when you click the \'rightbutton\' is clicked. Unfortunately, all that shows is the default Java logo with the cup of coffee and a
I think you have your parameters around the wrong way
try {
final ImageIcon icon = new ImageIcon(ImageIO.read(new File("paypalicon.gif")));
JOptionPane.showOptionDialog(
null,
"Congratulations, you clicked the button.",
"Congrats",
JOptionPane.OK_OPTION,
JOptionPane.PLAIN_MESSAGE,
icon,
new Object[]{"Okay"},
"Okay");
} catch (IOException exp) {
exp.printStackTrace();
}
JOptionPane
declares showOptionDialog as having the following parameters (in order)
Component
, the parent component associated with the dialogObject
, the message to be displayedString
, the dialog titleint
, the type of options (if not specified), such as JOptionPane.OKAY_CANCEL_OPTION
int
, the message type, such as JOptionPane.INFORMATION_MESSAGE
, which can define the icon that the dialog will useIcon
, the icon to be displayed on the dialogObject[]
, the options to be made available to the user (buttons)Object
, the initial option which is given focusYou seem to be passing...
null
as the parent, okay."Congratulations, you clicked the button."
, okay"Congrats"
, okayJOptionPane.DEFAULT_OPTION
, okayJOptionPane.INFORMATION_MESSAGE
probably okay, I'd use JOptionPane.PLAIN_MESSAGE
, but that's menull
...no icon?new Object[] { panel }
, not sure if this is okay, but at least it's in the right placeicon
...this isn't even a value i the option parameters you passed ... think this is missed place.The problem with the buttons comes down to the fact that they are disconnected from the dialog. The dialog has absolutely no way to know that the buttons are been clicked, you'd have to provide that functionality via some kind of ActionListener
...to be honest, it'd just pass String
values as the options
parameter and let JOptionPane
render them as buttons, as it will then deal with closing the dialog, otherwise it gets real messy, real quick...