Search code examples
javaswingresizejpanelgraphics2d

Java JPanel Paint Scaling


Following code work for visualizing a molecule on a JPanel except it does not rescale when I change the size of JPanel at runtime. The Chemistry Development Kit is used for generating rendered Image. A molecule is passed to MoleculeViewer for visualizing. What am I doing wrong??


Solution

  • 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