如何检查GUI中的文本字段是否包含某些内容?

时间:2016-05-24 01:13:10

标签: java user-interface

我试图检查用户在文本字段中的输入是否包含某些字母,如果有,则让它增加一个计数器。

//this is the code for the button
//tfYourName is the name of the text field
//below is what I've tried already
private void btnResultsMouseClicked(java.awt.event.MouseEvent evt) {   
    if (tfYourName.getSelectedItems.toString.toUpperCase().contains("T"))
}   

1 个答案:

答案 0 :(得分:0)

if (tfYourName.getText().toUpperCase().contains("T"))
    counter++;
相关问题