14.10. The JOptionPane Component

Static methods in the JOptionPane class let you easily create modal dialogs to show messages (JOptionPane.showMessageDialog), to ask for confirmation (JOptionPane.showConfirmDialog), to let the user enter text or to choose among predefined options (JOptionPane.showInputDialog), or to choose among a variety of buttons (JOptionPane.showOptionDialog). Each of these methods either returns an int specifying which button was pressed or returns a String specifying the option selected.

Useful JOptionPane Methods

JOptionPane is a robust class defining 26 constants, 7 constructors, and 59 methods. We only present five static methods for creating messages and input dialogs. All five methods define the same first three arguments ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.