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


Java JOptionPane.YES_NO_OPTION属性代码示例

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


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

@Override
public void actionPerformed(ActionEvent e){
	System.out.println("Delete activated");
	if( gui.ft.lastClicked == null )
		return;
	int dialogButton = JOptionPane.YES_NO_OPTION;
	int dialogResult = JOptionPane.showConfirmDialog (null, "This will delete all folders and files under what you have selected. Continue?","Warning",dialogButton);
	if(dialogResult != JOptionPane.YES_OPTION)
		return;
	String path = gui.savePath;
	int c = gui.ft.lastClicked.getPath().length;
	for( int i = 1; i < c; i++ ){
		path += "/" + gui.ft.lastClicked.getPath()[i].toString();
	}
	System.out.println(path);
	deleteFiles(path);
	gui.ft.model.reload();
	System.out.println("Done");
}
 
开发者ID:KayDeeTee,项目名称:Hollow-Knight-SaveManager,代码行数:19,代码来源:Listeners.java

示例3: handle

public void handle(Throwable e) {
    e.printStackTrace();

    JTextArea area = new JTextArea(10, 40);
    StringWriter writer = new StringWriter();
    e.printStackTrace(new PrintWriter(writer));
    area.setText(writer.toString());
    area.setCaretPosition(0);
    String copyOption = resources.getString("dialog.error.copy");
    JOptionPane pane = new JOptionPane(new JScrollPane(area), JOptionPane.ERROR_MESSAGE,
            JOptionPane.YES_NO_OPTION, null, new String[]{copyOption, resources.getString("cancel")});
    pane.createDialog(WorldFrame.this, e.toString()).setVisible(true);
    if (copyOption.equals(pane.getValue())) {
        area.setSelectionStart(0);
        area.setSelectionEnd(area.getText().length());
        area.copy(); // copy to clipboard
    }
}
 
开发者ID:CBSkarmory,项目名称:AWGW,代码行数:18,代码来源:WorldFrame.java

示例4: 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

示例5: 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

示例6: 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

示例7: setCallback

void setCallback(ConfirmationCallback callback)
    throws UnsupportedCallbackException
{
    this.callback = callback;

    int confirmationOptionType = callback.getOptionType();
    switch (confirmationOptionType) {
    case ConfirmationCallback.YES_NO_OPTION:
        optionType = JOptionPane.YES_NO_OPTION;
        translations = new int[] {
            JOptionPane.YES_OPTION, ConfirmationCallback.YES,
            JOptionPane.NO_OPTION, ConfirmationCallback.NO,
            JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO
        };
        break;
    case ConfirmationCallback.YES_NO_CANCEL_OPTION:
        optionType = JOptionPane.YES_NO_CANCEL_OPTION;
        translations = new int[] {
            JOptionPane.YES_OPTION, ConfirmationCallback.YES,
            JOptionPane.NO_OPTION, ConfirmationCallback.NO,
            JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL,
            JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL
        };
        break;
    case ConfirmationCallback.OK_CANCEL_OPTION:
        optionType = JOptionPane.OK_CANCEL_OPTION;
        translations = new int[] {
            JOptionPane.OK_OPTION, ConfirmationCallback.OK,
            JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL,
            JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL
        };
        break;
    case ConfirmationCallback.UNSPECIFIED_OPTION:
        options = callback.getOptions();
        /*
         * There's no way to know if the default option means
         * to cancel the login, but there isn't a better way
         * to guess this.
         */
        translations = new int[] {
            JOptionPane.CLOSED_OPTION, callback.getDefaultOption()
        };
        break;
    default:
        throw new UnsupportedCallbackException(
            callback,
            "Unrecognized option type: " + confirmationOptionType);
    }

    int confirmationMessageType = callback.getMessageType();
    switch (confirmationMessageType) {
    case ConfirmationCallback.WARNING:
        messageType = JOptionPane.WARNING_MESSAGE;
        break;
    case ConfirmationCallback.ERROR:
        messageType = JOptionPane.ERROR_MESSAGE;
        break;
    case ConfirmationCallback.INFORMATION:
        messageType = JOptionPane.INFORMATION_MESSAGE;
        break;
    default:
        throw new UnsupportedCallbackException(
            callback,
            "Unrecognized message type: " + confirmationMessageType);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:66,代码来源:DialogCallbackHandler.java


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