簡體   English   中英

如何刪除JOptionPane中的問號?

[英]How to remove question mark in a JOptionPane?

如何擺脫JOptionPane左上角的任何標記?

int result = JOptionPane.showConfirmDialog(null, myPanel, 
                   "Please Enter X and Y Values", JOptionPane.OK_CANCEL_OPTION);

這工作正常,但我想刪除討厭的? 在左上角。

使用PLAIN_MESSAGE消息類型

JOptionPane.showConfirmDialog(null, "Help",
    "Please Enter X and Y Values", 
    JOptionPane.OK_CANCEL_OPTION, 
    JOptionPane.PLAIN_MESSAGE);

在此輸入圖像描述

有一個重寫方法showConfirmDialog()如下所示

/**
 * Brings up a dialog where the number of choices is determined
 * by the <code>optionType</code> parameter, where the
 * <code>messageType</code>
 * parameter determines the icon to display.
 * The <code>messageType</code> parameter is primarily used to supply
 * a default icon from the Look and Feel.
 *
 * @param parentComponent determines the <code>Frame</code> in
 *                  which the dialog is displayed; if <code>null</code>,
 *                  or if the <code>parentComponent</code> has no
 *                  <code>Frame</code>, a
 *                  default <code>Frame</code> is used.
 * @param message   the <code>Object</code> to display
 * @param title     the title string for the dialog
 * @param optionType an integer designating the options available
 *                   on the dialog: <code>YES_NO_OPTION</code>,
 *                  <code>YES_NO_CANCEL_OPTION</code>,
 *                  or <code>OK_CANCEL_OPTION</code>
 * @param messageType an integer designating the kind of message this is;
 *                  primarily used to determine the icon from the pluggable
 *                  Look and Feel: <code>ERROR_MESSAGE</code>,
 *                  <code>INFORMATION_MESSAGE</code>,
 *                  <code>WARNING_MESSAGE</code>,
 *                  <code>QUESTION_MESSAGE</code>,
 *                  or <code>PLAIN_MESSAGE</code>
 * @return an integer indicating the option selected by the user
 * @exception HeadlessException if
 *   <code>GraphicsEnvironment.isHeadless</code> returns
 *   <code>true</code>
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public static int showConfirmDialog(Component parentComponent,
    Object message, String title, int optionType, int messageType)
    throws HeadlessException {
    return showConfirmDialog(parentComponent, message, title, optionType,
                            messageType, null);
}

如您所見,第5個參數是您可以設置的int messageType 有各種各樣的消息類型

  1. 錯誤信息
  2. INFORMATION_MESSAGE
  3. 警告信息
  4. QUESTION_MESSAGE
  5. PLAIN_MESSAGE

您可以選擇符合要求的那個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM