开发者

compare jTextField - java

It is possible compare the value (string) of JTextField? I have some blocks of code similar to the bellow, so my ideia is compare (!= or ==) this - pn50.setText(play4b) with, for example, pn50.setText(play5b);

I want avoid compare the string play5b or play4b, the reason is that pn50 is overwritten according to button pressed

        //card2
    ActionListener two = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (gr.getCounter1() < 1) {
                gr.setCounter1(gr.getCounter1() + 2);
                test1.setIcon(play1b);
                pn1.setText("Value of card: " + play2b);
                pn5.setText(play3b);
                pn50.setText(play4b);
                arraybtn[2].setText("no Card");
                arraybtn[2].setBackground(Color.lightGray);
            } else {
                pn5.setText("Only one Card");
      开发者_JAVA百科      }
        }
    };

thanks


The getText() method will return the text of a JTextBox. Use .equals or .compareTo to compare the Strings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜