javaquestion.java

来自「< ProJavaProgrammingSecondEdition>」· Java 代码 · 共 26 行

JAVA
26
字号
import java.util.*;
import javax.swing.*;

public class JavaQuestion {

  protected static ResourceBundle resources =
      ResourceBundle.getBundle("MyResources");

  public static void main(String[] args) {
    ImageIcon flagIcon = (ImageIcon)(resources.getObject(
        "FlagIcon"));
    String[] options = 
      {resources.getString("LabelYes"), resources.getString("LabelNo")};
    JOptionPane pane = new JOptionPane(
        resources.getString("JavaIsLang"),
        JOptionPane.QUESTION_MESSAGE,
        0, flagIcon, options);
    JDialog dlg = pane.createDialog(null,
        resources.getString("WhatIsJava"));
    dlg.setModal(true);
    dlg.setVisible(true);
    String selection = (String)(pane.getValue());
    boolean selectedYes = (selection == options[0]);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?