java/JOptionPane(2)

java/JOpetionPane

public class JOptionPane
extends JComponent
implements Accessible
  • JOptionPaneによって、標準dialogをひゅーひゅー
  • 使い方はThe Java Tutrial の How to Make Dialogs を見よ
    • 英語は読む気になれぬ
  • メソドが多くてメンドーそうだが、普通はstatic methodのshowXxxDialogの呼び出しで使うのみ
    • showConfirmDialog yes/no/cancel等の確認
    • showInputDialog 入力プロプト
    • showMessageDialog 目に映る全てのことはメッセージ
    • showOptionDialog 上の3つを合わせた欲張りダイアログ
  • 全てモーダルくてだるくてしょうがない
  • Dialogの基本レイアウト
    iconメッセージ
    入力値
    option button
  • parameter
    • parentComponent Frameを指定→Frameの下に表示。null→画面中央に表示。
    • message Dialogに表示するString。Object[]とかComponentとかIconとかもJLabelにラップするとかして表示するらし。
    • messageType メッセジスタイルを定義
      • ERROR_MESSAGE, INFORMATION_MASSAGE, WARNING_MASSAGE, QUESTION_MASSAGE, PLAIN_MASSAGE
    • optionType Dialog下部牡丹を定義
      • DEFAULT_OPTION, YES_NO_OPTION, TES_NO_CANCEL_OPTION, OK_CANCEL_OPTION これらに限りません
    • option Dialog下部牡丹の詳細な説明。普通はStrin配列。
    • icon 表示されるicon。デフォルトはmessageTypeで決まる。
    • title Dialogの題目
    • initialValue デフォルト選択肢
  • 返り血は整数で次のどれかになる。YES_OPTION, NO_OPTION, CANCEL_OPTION, OK_OPTION, CLOSED_OPTION

field

  • public static final Object UNINITIALIZED_VALUE
    • まだ値が選択されない
  • public static final int DEFALUT_OPTION
    • ???

・showConfirmDialogで使用される型

  • public static final int YES_NO_OPTION
  • public static final int YES_NO_CANCEL_OPTION
  • public static final int OK_CANCEL_OPTION

・選択されて返えされる値

  • public static final int YES_OPTION
  • public static final int NO_OPTION
  • public static final int CANCEL_OPTION
  • public static final int OK_OPTION
  • public static final int CLOSED_OPTION
    • 何も選択せずにdialogを閉じたときに返される

  • public static final int ERROR_MESSAGE
  • public static final int INFORMATION_MESSAGE
  • public static final int WARNING_MESSAGE
  • public static final int QUESTION_MESSAGE
  • public static final int PLAIN_MESSGAE

・バウンドプロパティ名

  • public static final String ICON_PROPERTY
  • public static final String MESSAGE_PROPERTY
  • public static final String VALUE_PROPERTY
  • public static final String OPTIONS_PROPERTY
  • public static final String INITIAL_VALUE_PROPERTY
  • public static final String MESSAGE_TYPE_PROPERTY
  • public static final String OPTION_TYPE_PROPERTY
  • public static final String SELECTION_VALUES_PROPERTY
  • public static final String INITIAL_SELECTION_VALUE_PROPERTY
  • public static final String INPUT_VALUE_PROPERTY
  • public static final String WANTS_INPUT_PROPERTY

  • protected transient Icon icon
  • protected transient Object message
  • protected transient Object[] options
  • protected transient Object initialValue
  • protected int messageType
  • protected int optionType
  • protected transient Object value
  • protected transient Object[] selectionValues
  • protected transient Object inputValue
  • protected transient Object intialSelectionValue
  • protected boolean wantsInput

constructor

  • JOptionPane()
  • JOptionPane(Object message)
  • JOptionPane(Object message, int messageType)
  • JOptionPane(Object message, int messageType, int optionType)
  • JOptionPane(Object message, int messageType, int optionType, Icon icon)
  • JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options)
  • JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue)

method ・

  • public static String showInputDialog(Object message) throws HeadlessException
  • public static String showInputDialog(Object message, Object initSelect)
  • public static String showInputDialog(Component parent, Object message) throws HeadlessException
  • public static String showInputDialog(Component parent, Object message, Object initSelect)
  • public static String showInputDialog(Component parent, Object message, String title, int messageType) throws HeadlessException
  • public static String showInputDialog(Component parent, Object message, String title, int messageType, Icon icon, Object[] selectValue, Object initselect) throws HeadlessException

  • public static void showMessageDialog(Component parent, Object message) throws HeadlessException
  • public static void showMessageDialog(Component parent, Object message, String title, int messageType) throws HeadlessException
    • messageType=ERROR_MESSAGE|INFOMATION_MESSAGE|WARNING_MESSAGE|QUESTION_MESSAGE|PLAIN_MESSAGE でiconを選ぶ。
  • public static void showMessageDialog(Component parent, Object message, String title, int messageType, Icon icon) throws HeadlessException

  • public static int showConfirmDialog(Component parent, Object message) throws HeadlessException
  • public static int showConfirmDialog(Component parent, Object message, String title, int optionType) throws HeadlessException
    • optionType=YES_NO_OPTION|YES_NO_CANCEL_OPTION|OK_CANCEL_OPTION で下部ボタンを選ぶ。
  • public static int showConfirmDialog(Component parent, Object message, String title, int optionType, int messageType) throws HeadlessException
  • public static int showConfirmDialog(Component parent, Object message, String title, int optionType, int messageType, Icon icon) throws HeadlessException
  • public static int showConfirmDialog(Component parent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initVal) throws HeadlessException

  • public JDialog createDialog(Component parent, String title) throws HeadlessException
  • public JDialog createDialog(String title) throws HeadlessException

  • public static void showInternalMessageDialog(Component parent, Object message)
  • public static void showInternalMessageDialog(Component parent, Object message, String title, int messageType)
  • public static void showInternalMessageDialog(Component parent, Object message, String title, int messageType, Icon icon)

  • public static int showInternalConfirmDialog(Component parent, Object message)
  • public static int showInternalConfirmDialog(Component parent, Object message, String title, int optionType)
  • public static int showInternalConfirmDialog(Component parent, Object message, String title, int optionType, int messageType)
  • public static int showInternalConfirmDialog(Component parent, Object message, String title, int optionType, int messageType, Icon icon)

  • public static int showInternalOptionDialog(Component parent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initVal)

  • public static String showInternalInputDialog(Component parent, Object message)
  • public static String showInternalInputDialog(Component parent, Object message, String title, int messageType)
  • public static String showInternalInputDialog(Component parent, Object message, String title, int messageType, Icon icon, Object[] selectVals, Object initVal)

  • public JInternalFrame createInternalFrame(Component parent, String title)
  • public static Frame getFrameForComponent(Component parent) throws HeadlessException
    • parentのFrameが返る
  • public static JDesktopPane getDesktopPaneForComponent(Component parent)
    • parentのDesktop区画を返す
  • public static void setRootFrame(Frame newRootFrame)
  • public static Frame getRootFrame() throws HeadlessException
  • public void setUI(OptionPaneUI ui)
    • componentのL&Fを実装するUIを指定する
  • public OptionPaneUI getUI()
  • public void updateUI()
  • public String getUIClassID()

  • public void setMessage(Object newMessage)
  • public Object getMessage()
  • public void setIcon(Icon newIcon)
  • public Icon getIcon()
  • public void setValue(Object newValue)
  • public Object getValue()
  • public void setOptions(Object[] newOptions)
  • public Object[] getOptions()
  • public void setInitialValue(Object newInitVal)
  • public Object getInitialValue()
  • public void setMessageType(int newType)
  • public int getMessageType()
  • public void setOptionType(int newType)
  • public int getOptionType()
  • public void setSelectionValues(Object[] newValues)
  • public Object[] getSelectionValues()
  • public void setInitalSelectionValue(Object newValue)
  • public Object getInitalSelectionValue()
  • public void setInputValue(Object newValue)
  • public Object getInputValue()
  • public int getMaxCharacterPerLineCount()
    • messageの1行の最大文字数
  • public void setWantsInput(boolean newValue)
  • public boolean getWantsInput()
  • public void selectiInitialValue()
  • protected String paramString()
  • public AccessibleContext getAccessibleContext()