下面的代码用于可视化JPanel上的分子,但当我在运行时更改JPanel的大小时,它不会重新缩放。化学开发工具包用于生成渲染图像。一个分子被传递给MoleculeViewer进行可视化。我做错了什么??
发布于 2011-10-27 10:08:53
Adding following resolved the not redrawing upon scaling problem
renderer.paint(molecule_, new AWTDrawVisitor(g2), new Rectangle2D.Double(0, 0, w, h), false);
g2.dispose();
}
else发布于 2011-10-02 03:53:53
What am I doing wrong??image = new BufferedImage(this.WIDTH, this.HEIGHT, BufferedImage.TYPE_INT_RGB);作为Icon添加到JLabel,然后您可以删除有关paintComponent()JLabel而不是JPanel,但默认情况下JLabel是半透明的,或者通过使用正确的< JLabel >C17>将代码放入JPanel在这种情况下,BorderLayout.CENTERMoleculeViewer,有什么LayoutManager使用了??,因为只有使用LayoutManager才能正确地使用Top-Level Container调整(或不调整)容器的子容器的大小,所以MoleculeViewer必须为其父重新运行PreferredSize
https://stackoverflow.com/questions/7622402
复制相似问题