作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我已经尝试了几乎所有的方法,但我仍然无法正常运行这个该死的代码
public void Action(ActionEvent event)
{
//We get the text from the textfield
String fromUser = textfield1.getText();
if (fromUser != null) {
if(x<1)
{
if(fromUser.length() <= 10)
{
USERNAME = fromUser;
x++;
textfield1.setText("");
}
else
{
textarea1.setText("Username Surpasses Size Limit Please Try Again\nUsername Must Be 10 Characters Or Less");
textfield1.setText("");
}
}
else
{
if(x==1)
{
textarea1.setText("");
x++;
}
//We append the text from the user
textarea1.append(USERNAME+"> " + fromUser + "\n");
//The pane auto-scrolls with each new response added
textarea1.setCaretPosition(textarea1.getDocument().getLength());
//We reset our text field to "" each time the user presses Enter
textfield1.setText("");
//This is Where my code should work
if(fromUser == "n")
{
InitiateText("North");
}
else if(fromUser == "s")
{
InitiateText("South");
}
else if(fromUser == "w")
{
InitiateText("West");
}
else if(fromUser == "e")
{
InitiateText("East");
}
else
{
InitiateText("I don't comprehend");
}
}
}
}
public void InitiateText(String Where) //Where are you on the map
{
//We append the text from the user
textarea1.append("Map > " + Where + "\n");
//The pane auto-scrolls with each new response added
textarea1.setCaretPosition(textarea1.getDocument().getLength());
//We reset our text field to "" each time the user presses Enter
textfield1.setText("");
}
这是我最近的尝试,添加文本的方法工作正常,但 if 语句不起作用,我将输入“n”,它不会识别我输入的“n”。我做错了什么??
我是一名优秀的程序员,十分优秀!