AddingIconsToOptionPopups.java Source code

Java tutorial

Introduction

Here is the source code for AddingIconsToOptionPopups.java

Source

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class AddingIconsToOptionPopups {

    public static void main(String[] a) {
        JFrame frame = new JFrame();
        Icon greenIcon = new ImageIcon("yourFile.gif");
        Icon redIcon = new ImageIcon("");
        Object iconArray[] = { greenIcon, redIcon };

        JOptionPane.showOptionDialog(frame, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, iconArray, iconArray[1]);

    }

}