我想将文本文件中的内容传输到JTextarea。我想我的代码只需要很小的调整,但即使通过研究。我无法找出,出了什么问题。到目前为止,它只显示一个空JFrame文本而不是文件的文本。this.setSize(this.width, this.height);this.setVisible(true);this.jScrollPane = new JScrollPane(this.jTextArea);
this.jPanel = new JPanel();this.jPanel.setOpaque(true);this.jTextArea.setVisible(true);try {
this.jTextArea = new JTextArea();
this.jTextArea.read(new InputStreamReader(
getClass().getResourceAsStream("C:\\wrk\\SapCommerceCloud\\src\\SwingUni\\name")),
null);} // catch
this.add(this.jScrollPane);用法:public static void main(String[] args) {
new TextFrame(new File("C:\\wrk\\SapCommerceCloud\\src\\SwingUni\\name"), 500, 500);}
添加回答
举报
0/150
提交
取消