在绘制图形之前,如何放置在 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 对象相对便宜。任何帮助,将不胜感激!