问题1:我想在菜单里实现剪切,复制,粘贴。在事件处理时,用什么命令阿?
必须知道cursor所在位置,然后必须有getSelectedText函数。Eclipse SWT有,Swing AWT我不熟悉。
   问题2:我想在菜单里实现像Windows记事本那样添加时间和日期,又要咋办阿?
看看java.text.SimpleDateFormat类,必须有一个默认的pattern.可以让用户自定pattern.
   问题3:我想实现自动换行功能,要用到那些命令?
最土的是判断,加'\n'character.或许,TextArea类已经有方法了或许已经实现了。
   问题4:我想问一下保存的事件处理方法和另存为的方法有啥不同吗?
save就直接save,save as should open a File Dialog Box.然后判断是否与原文件同名,必要时,overwriting confirmation message box should be displayed.
   问题5:我编的记事本为啥实现不了打开和保存的功能,要咋改阿?
好的记事本,像Ultra Editor,还应该判断text file encoding type.但是,只能判断是不是UTF8,UTF16,Unicode.

解决方案 »

  1.   

    sun的web start好像已经有这个notepad sample了。
      

  2.   

    using public JTextArea(Document doc,
                     String text,
                     int rows,
                     int columns)
    by specifying the column number, has it actually set the maximum number of characters in each row?