当前位置: 首页>>代码示例>>Java>>正文


Java JOptionPane.QUESTION_MESSAGE属性代码示例

本文整理汇总了Java中javax.swing.JOptionPane.QUESTION_MESSAGE属性的典型用法代码示例。如果您正苦于以下问题:Java JOptionPane.QUESTION_MESSAGE属性的具体用法?Java JOptionPane.QUESTION_MESSAGE怎么用?Java JOptionPane.QUESTION_MESSAGE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.swing.JOptionPane的用法示例。


在下文中一共展示了JOptionPane.QUESTION_MESSAGE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showUpgradeDialog

private static boolean showUpgradeDialog (final File source, String note) {
       Util.setDefaultLookAndFeel();

JPanel panel = new JPanel(new BorderLayout());
panel.add(new AutoUpgradePanel (source.getAbsolutePath (), note), BorderLayout.CENTER);
JProgressBar progressBar = new JProgressBar(0, 100);
progressBar.setValue(0);
progressBar.setStringPainted(true);
progressBar.setIndeterminate(true);
panel.add(progressBar, BorderLayout.SOUTH);
progressBar.setVisible(false);

JButton bYES = new JButton("Yes");
bYES.setMnemonic(KeyEvent.VK_Y);
JButton bNO = new JButton("No");
bNO.setMnemonic(KeyEvent.VK_N);
JButton[] options = new JButton[] {bYES, bNO};
       JOptionPane p = new JOptionPane (panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, bYES);
       JDialog d = Util.createJOptionProgressDialog(p, NbBundle.getMessage (AutoUpgrade.class, "MSG_Confirmation_Title"), source, progressBar);
       d.setVisible (true);

       return new Integer (JOptionPane.YES_OPTION).equals (p.getValue ());
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AutoUpgrade.java

示例2: confirm

/**
 * Indicates if this option is confirmed. This can be either because its
 * value is {@link #ALWAYS}, or because the user has confirmed an
 * appropriate dialog.
 * @param owner the component on which the dialog is to be shown
 * @param question if not <code>null</code>, replaces the name of the
 *        option in the dialog
 * @return <code>true</code> if the option is confirmed.
 */
public boolean confirm(Component owner, String question) {
    if (this.value == ASK) {
        if (question == null) {
            question = getText();
        }
        List<String> options = getDialogOptions();
        JOptionPane pane =
            new JOptionPane(question, JOptionPane.QUESTION_MESSAGE,
                JOptionPane.YES_NO_CANCEL_OPTION, null, options.toArray());
        pane.createDialog(owner, DIALOG_TITLE).setVisible(true);
        int dialogValue = options.indexOf(pane.getValue());
        if (dialogValue > NO) {
            setValue(dialogValue - 1);
        }
        return dialogValue == YES || dialogValue - 1 == ALWAYS;
    } else {
        return this.value == ALWAYS;
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:28,代码来源:BehaviourOption.java

示例3: inputPassword

@Override
public String inputPassword(String messageText) {
	final JPasswordField passwordField = new JPasswordField();
	JOptionPane jop = new JOptionPane(new Object[] { messageText, passwordField }, JOptionPane.QUESTION_MESSAGE,
			JOptionPane.OK_CANCEL_OPTION);
	JDialog dialog = jop.createDialog("Auhtentication required");
	dialog.addComponentListener(new ComponentAdapter() {

		@Override
		public void componentShown(ComponentEvent e) {
			SwingUtilities.invokeLater(new Runnable() {

				@Override
				public void run() {
					passwordField.requestFocusInWindow();
					passwordField.requestFocus();
				}
			});
		}
	});
	dialog.setVisible(true);
	int result = (Integer) jop.getValue();
	if (result == JOptionPane.OK_OPTION) {
		return new String(passwordField.getPassword());
	} else {
		return null;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:GUIInputHandler.java

示例4: getOptionPane

private JOptionPane getOptionPane() {
    if (this.optionPane == null) {
        this.optionPane =
            new JOptionPane(getMessagePanel(), JOptionPane.QUESTION_MESSAGE,
                JOptionPane.OK_CANCEL_OPTION);
        this.optionPane.addPropertyChangeListener(this.listener);
    }
    return this.optionPane;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:9,代码来源:ExploreWarningDialog.java

示例5: CustomDialog

/** Creates the reusable dialog. */
public CustomDialog(Frame aFrame, String aWord, DialogDemo parent) {
    super(aFrame, true);
    dd = parent;

    magicWord = aWord.toUpperCase();
    setTitle("Quiz");

    textField = new JTextField(10);

    // Create an array of the text and components to be displayed.
    String msgString1 = "What was Dr. SEUSS's real last name?";
    String msgString2 = "(The answer is \"" + magicWord + "\".)";
    Object[] array = { msgString1, msgString2, textField };

    // Create an array specifying the number of dialog buttons
    // and their text.
    Object[] options = { btnString1, btnString2 };

    // Create the JOptionPane.
    optionPane = new JOptionPane(array, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]);

    // Make this dialog display it.
    setContentPane(optionPane);

    // Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            /*
             * Instead of directly closing the window, we're going to change
             * the JOptionPane's value property.
             */
            optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
        }
    });

    // Ensure the text field always gets the first focus.
    addComponentListener(new ComponentAdapter() {
        public void componentShown(ComponentEvent ce) {
            textField.requestFocusInWindow();
        }
    });

    // Register an event handler that puts the text into the option pane.
    textField.addActionListener(this);

    // Register an event handler that reacts to option pane state changes.
    optionPane.addPropertyChangeListener(this);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:50,代码来源:CustomDialog.java

示例6: readFromGUI

/**
 * Ask using a GUI for the username and password.
 */
private void readFromGUI() {
   // Create fields for user name.
   final JTextField usernameField = new JTextField(20);
   usernameField.setText(this.username);
   final JLabel usernameLabel = new JLabel("Username: ");
   usernameLabel.setLabelFor(usernameField);
   final JPanel usernamePane = new JPanel(new FlowLayout(FlowLayout.TRAILING));
   usernamePane.add(usernameLabel);
   usernamePane.add(usernameField);

   // Create fields for password.
   final JPasswordField passwordField = new JPasswordField(20);
   passwordField.setText(this.password);
   final JLabel passwordLabel = new JLabel("Password: ");
   passwordLabel.setLabelFor(passwordField);
   final JPanel passwordPane = new JPanel(new FlowLayout(FlowLayout.TRAILING));
   passwordPane.add(passwordLabel);
   passwordPane.add(passwordField);

   // Create panel
   final JPanel main = new JPanel();
   main.setLayout(new BoxLayout(main, BoxLayout.PAGE_AXIS));
   main.add(usernamePane);
   main.add(passwordPane);

   // Create and handle dialog
   final JOptionPane jop = new JOptionPane(main, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog = jop.createDialog("User name and password");
   dialog.addComponentListener(new ComponentAdapter() {
      
      public void componentShown(ComponentEvent e) {
         SwingUtilities.invokeLater(new Runnable() {
            
            public void run() {
               if (usernameField.getText().isEmpty())
               {
                  usernameField.requestFocusInWindow();
               }
               else
               {
                  passwordField.requestFocusInWindow();
               }
            }
         });
      }
   });
   dialog.setVisible(true);
   final Integer result = (Integer) jop.getValue();
   dialog.dispose();
   if (result.intValue() == JOptionPane.OK_OPTION) {
      this.username = usernameField.getText();

      final char[] pwd = passwordField.getPassword();
      this.password = new String(pwd);
   }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:59,代码来源:UsernamePassword.java

示例7: CustomOptionPane

public CustomOptionPane(String head, String inputRequest, String opt1, String opt2, String graph) {
	super(new JFrame(), true);
	this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	this.graph = graph;
	// setLocationRelativeTo(null);
	this.setTitle(head);
	this.setLayout(new FlowLayout());
	this.newGraph = new JRadioButton(opt1);
	this.newGraph.setActionCommand("new_graph");
	this.newGraph.addActionListener(this);
	this.newGraph.setSelected(true);

	this.exsitingGraph = new JRadioButton(opt2);
	this.exsitingGraph.setActionCommand("exsisting_graph");
	this.exsitingGraph.addActionListener(this);

	this.eventIDField = new HintTextField(inputRequest);

	this.graphIDField = new HintTextField("Please enter ID of the existing " + graph);
	this.graphIDField.setForeground(Color.gray);
	this.graphIDField.setEnabled(false);

	this.okButton = new JButton("Enter");
	this.okButton.addActionListener(this);

	this.cancelButton = new JButton("Cancel");
	this.cancelButton.addActionListener(this);

	Object[] array = { inputRequest, eventIDField, newGraph, exsitingGraph, graphIDField };
	Object[] options = { this.okButton, this.cancelButton };

	optionPane = new JOptionPane(array, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options,
			null);
	setContentPane(optionPane);

	label = new JLabel("Please select one of the options");
	this.label.setForeground(Color.red);
	this.label.setAlignmentX(RIGHT_ALIGNMENT);
	Border border = this.label.getBorder();
	Border margin = new EmptyBorder(10, 0, 0, 10);
	this.label.setBorder(new CompoundBorder(border, margin));
	this.label.setVisible(false);
	this.add(label);

	addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent we) {
			/*
			 * Instead of directly closing the window, we're going to change
			 * the JOptionPane's value property.
			 */
			optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
		}
	});

	this.pack();
	this.setVisible(true);

}
 
开发者ID:tslaats,项目名称:SE2017-Team2,代码行数:58,代码来源:CustomOptionPane.java

示例8: DeleteSubGraphOptionPane

public DeleteSubGraphOptionPane(String head, String opt1, String opt2) {
	super(new JFrame(), true);
	// setLocationRelativeTo(null);

	this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	this.newGraph = new JRadioButton(opt1);
	this.newGraph.setActionCommand("new_graph");
	this.newGraph.addActionListener(this);
	// this.newGraph.setSelected(true);

	this.exsitingGraph = new JRadioButton(opt2);
	this.exsitingGraph.setActionCommand("exsisting_graph");
	this.exsitingGraph.addActionListener(this);

	this.graphIDField = new HintTextField("Please enter ID of the existing graph   ");
	this.graphIDField.setForeground(Color.gray);
	// this.graphIDField.setEnabled(false);

	this.okButton = new JButton("Enter");
	this.okButton.addActionListener(this);

	this.cancelButton = new JButton("Cancel");
	this.cancelButton.addActionListener(this);

	Object[] array = { head, graphIDField, newGraph, exsitingGraph };
	Object[] options = { this.okButton, this.cancelButton };

	optionPane = new JOptionPane(array, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options,
			options[0]);
	setContentPane(optionPane);

	addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent we) {
			/*
			 * Instead of directly closing the window, we're going to change
			 * the JOptionPane's value property.
			 */
			optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
		}
	});

	label = new JLabel("Please select one of the options");
	this.label.setForeground(Color.red);
	this.label.setAlignmentX(RIGHT_ALIGNMENT);
	Border border = this.label.getBorder();
	Border margin = new EmptyBorder(10, 0, 0, 10);
	this.label.setBorder(new CompoundBorder(border, margin));
	this.label.setVisible(false);
	this.add(label);

	this.pack();
	this.setVisible(true);

}
 
开发者ID:tslaats,项目名称:SE2017-Team2,代码行数:54,代码来源:DeleteSubGraphOptionPane.java


注:本文中的javax.swing.JOptionPane.QUESTION_MESSAGE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。