JOptionPane

Anuncio
Class JOptionPane
.
Method Name
.
.
showConfirmDialog
showMessageDialog
Description
Asks a confirming question, like
yes/no/cancel
showInputDialog
Prompt for some input
showMessageDialog
Tell the user about something
that has happened
showOptionDialog
The Grand Unification of the
above three.
showMessageDialog
MessageType: define el estilo del mensaje
ERROR_MESSAGE
INFORMATION_MESSAGE
WARNING_MESSAGE
QUESTION_MESSAGE
PLAIN_MESSAGE
public static void showMessageDialog(Component parentComponent,
Object message) throws HeadlessException
Brings up an information-message dialog titled "Message".
public static void showMessageDialog(Component parentComponent,
Object message, String title, int messageType) throws
HeadlessException
Brings up a dialog that displays a message using a default icon
determined by the messageType parameter.
showMessageDialog
Ejemplos
JOptionPane.showMessageDialog(
null, result, "Comparison Results",
JOptionPane.INFORMATION_MESSAGE );
Null Frame Parent
El diálogo se centra en la
pantalla.
showConfirmDialog
public static int showConfirmDialog(Component parentComponent,
Object message) throws HeadlessException
Brings up a dialog with the options Yes, No and Cancel; with the title,
Select an Option.
showConfirmDialog
optionType: Define los botones que aparecerán en el diálogo
DEFAULT_OPTION
YES_NO_OPTION
YES_NO_CANCEL_OPTION
OK_CANCEL_OPTION
showConfirmDialog
public static int showConfirmDialog(Component parentComponent,
Object message, String title, int optionType) throws
HeadlessException
Brings up a dialog where the number of choices is determined
by the optionType parameter.
showInputDialog
public static String showInputDialog(Object message) throws
HeadlessException
Muestra una pregunta que debe ser contestada por el usuario en un textbox.
showOptionDialog
showOptionDialog
public static int showOptionDialog(Component parentComponent,
Object message, String title, int optionType, int messageType, Icon icon,
Object[] options, Object initialValue) throws HeadlessException
showOptionDialog
String[] choices = {"Democratic", "Republican", "None of your business", "Quit"};
int response = JOptionPane.showOptionDialog(
null // Center in window.
, "How did you vote?" // Message
, "Party Poll" // Title in titlebar
, JOptionPane.YES_NO_OPTION // Option type
, JOptionPane.PLAIN_MESSAGE // messageType
, null // Icon (none)
, choices // Button text as above.
, "None of your business" // Default button's label
);
Descargar