下面是我要创建的基本界面的图片。除以下各项外,其他一切正常:-
这是我代码中解决第1点问题的部分
具有信息显示TextArea和JScrollPane的InfoPanel
String
这是我代码中解决第2点问题的部分
添加textPanel 3行,1列以封装3个TextAreas
String type = "groovy"; // or "kts"
String script = "..."; // code of DSL script
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByExtension(type);
Compilable compiler = (Compilable) engine;
CompiledScript code = compiler.compile(script);
Object result = code.eval();
TextArea1“ availableUnits” 2行2列,用于封装4个按钮
JPanel infoPanel = new JPanel();
infoPanel.setLayout(new BorderLayout());
JTextArea informationDisplay= new JTextArea();
JScrollPane scrollbar1 = new JScrollPane(informationDisplay, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollbar1.setSize( 20, 20 );
informationDisplay.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 20));
informationDisplay.setText("The \n" + "It\n "+ "The\n" +"A\n" + "About\n" + "\n" + "Cats\n" + "Cats\n" + "Cats\n" + "Cats\n");
informationDisplay.setPreferredSize(new Dimension(getWidth(), 200));
infoPanel.add(scrollbar1);
add(infoPanel, BorderLayout.SOUTH);
这是准备编译的完整代码:-
JPanel textPanel = new JPanel();
textPanel.setLayout(new GridLayout(3, 1, 4, 4));