如何将if语句应用于我的java gui文本框

时间:2014-02-07 02:09:55

标签: java eclipse if-statement

我需要if语句,它将反转用户输入的内容以应用于我的jt文本字段,但无论我尝试什么,它都行不通!

public class MorseCodeFinch extends JFrame{

    private static final long serialVersionUID = 1L;

    JTextField jt = new JTextField(15);
    JButton jb = new JButton("Enter");
    JLabel jl = new JLabel();
    JPanel jp = new JPanel();

    @SuppressWarnings("unused")

    public MorseCodeFinch(){

        String s = "";
            if( s.contains(",") ) {
                s = s.replaceAll(",","");
                StringBuilder builder = new StringBuilder(s);
                builder.reverse();
                System.out.println(builder);
            }
            else {
                System.out.println(s);
            }
        }

0 个答案:

没有答案