Я хочу перенести контент из текстового файла в 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);
}