小编Chi*_*ani的帖子

为什么尝试和捕获不起作用?

我正在尝试制作一个程序,告诉他们是否可以乘坐过山车.只要输入有效,它就可以工作,但我希望它显示一条消息,说明如果用户输入其他内容则重试.我尝试使用try和catch,但它仍然显示错误(NumberFormat异常).任何帮助表示赞赏,谢谢.

private void btnCalculateActionPerformed(java.awt.event.ActionEvent evt) {                                             
    String strHeight, strBackTrouble, strHeartTrouble;
    int intHeight;

    strHeight = txtInputHeight.getText();
    strBackTrouble = txtInputBackTrouble.getText();
    strHeartTrouble = txtInputHeartTrouble.getText();

    intHeight = Integer.parseInt(strHeight);

    try {
        if (intHeight < 188 || intHeight > 122) {
            if (strBackTrouble.equals("N") || strBackTrouble.equals("n") || strHeartTrouble.equals("N") || strHeartTrouble.equals("n")) {
                    txtOutput.setText("It is OK for you to ride this roller coaster. Have fun!");
            }
        } else  if (strBackTrouble.equals("Y") || strBackTrouble.equals("y") || strHeartTrouble.equals("Y") || strHeartTrouble.equals("y")) {
                txtOutput.setText("Sorry, it is not safe for you to ride this rollercoaster");
            } …
Run Code Online (Sandbox Code Playgroud)

java try-catch

0
推荐指数
1
解决办法
118
查看次数

如何让背景图像不重复?

我试图让图像在背景中显示为一个统一的图像.我究竟做错了什么?谢谢.

.content{
    background-color: gray;
    top: 0;
    position: relative;
    background-size: cover;
    left: 0;
    right: 0;
    bottom: 0;
    background:url(cropped.jpg);
    background-repeat: no repeat; 
}
Run Code Online (Sandbox Code Playgroud)

html css html5 background-image css3

-3
推荐指数
1
解决办法
60
查看次数

标签 统计

background-image ×1

css ×1

css3 ×1

html ×1

html5 ×1

java ×1

try-catch ×1