我有一个自动生成的报告文件,其中包含乳胶代码。现在我想构建一个小应用程序,为每个节及其标题创建一个表单字段。该文档仅包含几百行,并且应该执行以下操作:
\section{ This is were the header text should go inside the document }
\normalsize{ This is where the normal text should go}
编辑:
这是我的第一次尝试。我想我应该使用明文文件而不是直接发送,但我´我会弄明白的,因为我在编辑器/文本组件链接方面得到了垃圾神的大量帮助。主要问题是从\section{}和\normalsize{}内容中挑出内容。也许我会在这里买些regexp。每次出现我都需要一个新的文本区域。
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileReader;
import javax.swing.*;
public class basicFrame extends JFrame {
// Declare Variables
JScrollPane bildlauf = new JScrollPane();
JTextArea txtfeld = new JTextArea();
public basicFrame() {
super();
// Main window
setTitle("ReportEditor");
setBackground(Color.LIGHT_GRAY);
// components
try {
File datei = new File("report.Rnw");
FileReader in = new FileReader(datei);
txtfeld.read(in, datei);
in.close();
} catch (Exception e) {
System.out.println("Error !");
}
// setLayout(new GridLayout(2,2));
// Scroll Shizzle
bildlauf.getViewport().add(txtfeld, null);
getContentPane().add(bildlauf, BorderLayout.CENTER);
//txtfeld.setSize(500,680);
//add(txtfeld);
//this.getContentPane().add(txtfeld);
// close
addWindowListener(new WindowLauscher());
}
// event handlers...
protected static final class WindowLauscher extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
public static void main(String[] args) {
//Fesnter erzeugen und anzeigen, die main Sache halt
basicFrame hf = new basicFrame();
hf.setSize(500, 700);
hf.setLocation(100, 100);
hf.setVisible(true);
}
}