最初にいくつかの機能を実行するいくつかのクラスがあり、csis.txt に書き込みます。csis.txt WITH フォーマットの内容を表示するためのウィンドウがポップアップ表示された後。ただし、正しくフォーマットされていません。ここに私が持っているものがあります:
import java.io.*;
import java.awt.*;
import java.util.Scanner;
public class Driver extends Canvas {
public Driver(){
setSize(200, 200);
setBackground(Color.white);
}
public static void main(String[] args) throws IOException {
PrintWriter pw = new PrintWriter(new FileWriter("csis.txt"));
MFQ mfq = new MFQ(pw);
mfq.getJobs();
mfq.outputHeader();
mfq.runSimulation();
mfq.outStats();
pw.close();
Driver GP = new Driver();
Frame aFrame = new Frame();
aFrame.setSize(1000, 1000);
aFrame.add(GP);
aFrame.setVisible(true);
}
public void paint(Graphics g) {
try {
Scanner fileScan = new Scanner(new File("csis.txt"));
String s = fileScan.nextLine();
for (int i = 20; fileScan.hasNext(); i += 20) {
g.drawString(fileScan.nextLine(), 0, i);
}
}
catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
csis.txt:
csis.txt のサイドバイ側とグラフィックス ウィンドウが正しくフォーマットされない: