Java编程技巧与常用知识点[待续]

  1. eclipse运行命令行参数

    run→run configuration→arguments→profile

  2. 汉字

    汉字的字符编码区间[\u4e00-\u9fa5],通过Pattern.matches(reg,"")方法判断

  3. frame全屏居中

    this.setLocation((this.getToolkit().getScreenSize().width-this.getWidth())/2, (this.getToolkit().getScreenSize().height-this.getHeight())/2);

  4. 不规则图形或透明窗口

    com.sun.awt.AWTUtilities.setWindowOpacity(w, 0.6f); 若报错:Window->Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API ->Forbidden reference -> 把 “error” 改为 “warning”

  5. 按钮可用

    setEnabled(boolean)

  6. 文本框获取焦点

    扫描二维码关注公众号,回复: 11644128 查看本文章

    requestFocus()

  7. 密码框

    setEchoChar()

  8. 文本域自动换行

    setLineWrap(boolean)

  9. 数组长度

    二维数组通过length方法返回的是行数,通过数组名[下标].length返回的是该行元素个数

  10. 分割字符串

    split分割字符串时 若分割字符为.,需使用转义字符

  11. 时间戳

    System.currentTimeMillis()

  12. 提示语

    setToolTipText();
    getToolTipText();

  13. 打开文件

    JFileChooser jf=new JFileChooser();
    jf.showOpenDialog(this); //打开
    jf.showSaveDialog(this); //保存
    getSelectedFile()//返回选取的文件名(File类的对象)

    JFileChooser jfc=new JFileChooser();
    int returnVal = jfc.showOpenDialog(this);

  14. 对话框

    JOptionPane jo=new JOptionPane();
    jo.showMessageDialog(this,“喜欢吗”);

猜你喜欢

转载自blog.csdn.net/Zeno_wrj/article/details/107163909