Descripción
Sintaxis
@JavaBean(defaultProperty="UI", description="A component which implements standard dialog box controls.") public class JOptionPane extends JComponent implements Accessible
Constructores
Campos
- CANCEL_OPTION
- CLOSED_OPTION
- DEFAULT_OPTION
- ERROR_MESSAGE
- icon
- ICON_PROPERTY
- INFORMATION_MESSAGE
- INITIAL_SELECTION_VALUE_PROPERTY
- INITIAL_VALUE_PROPERTY
- initialSelectionValue
- initialValue
- INPUT_VALUE_PROPERTY
- inputValue
- message
- MESSAGE_PROPERTY
- MESSAGE_TYPE_PROPERTY
- messageType
- NO_OPTION
- OK_CANCEL_OPTION
- OK_OPTION
- OPTION_TYPE_PROPERTY
- options
- OPTIONS_PROPERTY
- optionType
- PLAIN_MESSAGE
- QUESTION_MESSAGE
- SELECTION_VALUES_PROPERTY
- selectionValues
- UNINITIALIZED_VALUE
- value
- VALUE_PROPERTY
- WANTS_INPUT_PROPERTY
- wantsInput
- WARNING_MESSAGE
- YES_NO_CANCEL_OPTION
- YES_NO_OPTION
- YES_OPTION
Métodos
- createDialog()
- createInternalFrame()
- getAccessibleContext()
- getDesktopPaneForComponent()
- getFrameForComponent()
- getIcon()
- getInitialSelectionValue()
- getInitialValue()
- getInputValue()
- getMaxCharactersPerLineCount()
- getMessage()
- getMessageType()
- getOptions()
- getOptionType()
- getRootFrame()
- getSelectionValues()
- getUI()
- getUIClassID()
- getValue()
- getWantsInput()
- paramString()
- selectInitialValue()
- setIcon()
- setInitialSelectionValue()
- setInitialValue()
- setInputValue()
- setMessage()
- setMessageType()
- setOptions()
- setOptionType()
- setRootFrame()
- setSelectionValues()
- setUI()
- setValue()
- setWantsInput()
- showConfirmDialog()
- showInputDialog()
- showInternalConfirmDialog()
- showInternalInputDialog()
- showInternalMessageDialog()
- showInternalOptionDialog()
- showMessageDialog()
- showOptionDialog()
- updateUI()
Ejemplo
import javax.swing.*;
public class VolumenCono {
public static double volumen(double r,double h){
return (Math.PI*(r*r)*h)/3;
}
public static void main(String[] args) {
try {
double radio = Double.parseDouble(JOptionPane
.showInputDialog("Introduce radio:"));
double altura = Double.parseDouble(JOptionPane
.showInputDialog("Introduce altura:"));
JOptionPane.showMessageDialog(
null,
"Volumen obtenido\n"
+ String.valueOf(volumen(radio, altura)), "Aviso",
JOptionPane.PLAIN_MESSAGE, new ImageIcon("imagen.jpg"));
System.exit(0);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.getCause().toString(),
"Aviso", JOptionPane.ERROR_MESSAGE, new ImageIcon(
"ferd.jpg"));
}
}
}
Artículos
Vídeos Java
Disfruta también de nuestros artículos sobre Java en formato vídeo. Aprovecha y suscribete a nuestro canal.