グラフが描画されるまでJavaアプレットに表示されるロード画面を配置するにはどうすればよいですか?私のコード:
public class Test extends JApplet
{
GrappaPanel gp = null;
JPanel jpanel = null;
JEditorPane dataDisplayer = null;
Graph graph = null;
JProgressBar progressBar = null;
public void init() {
Parser program =null;
InputStream input;
String sgraph = getGraph();
try {
input = new ByteArrayInputStream(sgraph.getBytes("UTF-8"));
program = new Parser(input);
program.parse();
} catch (Exception e) {
e.printStackTrace();
}
graph = program.getGraph();
gp = new GrappaPanel(graph);
JScrollPane jspg = new JScrollPane(gp,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
GridBagLayout gb = new GridBagLayout();
jpanel = new JPanel(gb);
setContentPane(jpanel);
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gb.setConstraints(jspg,gbc);
jpanel.add(jspg);
}
private String getGraph(){
...
}
}
アプレットでグラフを描画すると、読み込み時間の大部分を占めます。グラフを表す文字列を取得し、それをGraphオブジェクトに解析するのは比較的安価です。どんな助けでもいただければ幸いです!