如题,看到window里面有这样的控件,特来讨教。
谢谢!

解决方案 »

  1.   

    没有的,我也在用到过ip输入这问题。这还是要你自己尽兴判断,是不是合法的ip。实现起来还是比较简单的
      

  2.   

    建议用4个JTextField,用正则表达式保证每个输入框最多只能输入3个数字,并且在输完3个数字时自动跳到下一个JTextField(设置Focus)
    我没试过,估计可以做到:)
      

  3.   

    这个也许对你有帮助
    JFrame f = new JFrame("JFormattedTextField Sample");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = f.getContentPane();
        content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));
        // Four-digit year, followed by month name and day of month,
        // each separated by two dashes (--)
        DateFormat format = 
          new SimpleDateFormat("yyyy--MMMM--dd");
        DateFormatter df = new DateFormatter(format);
        JFormattedTextField ftf1 = new 
          JFormattedTextField(df);
        ftf1.setValue(new Date());
        content.add(ftf1);
        // US Social Security number
        MaskFormatter mf1 = 
          new MaskFormatter("###-##-####");
        mf1.setPlaceholderCharacter('_');
        JFormattedTextField ftf2 = new 
          JFormattedTextField(mf1);
        content.add(ftf2);
        // US telephone number
        MaskFormatter mf2 = 
          new MaskFormatter("(###) ###-####");
        JFormattedTextField ftf3 = new 
          JFormattedTextField(mf2);
        content.add(ftf3);
        f.setSize(300, 100);
        f.show();
      

  4.   

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.util.*;
    import java.text.*;