我想放大和缩小JPanel ..我做了一些代码,但我无法完成它 这就是我所做的,而center_panel是我想要缩放的面板
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
double x = (getWidth() - scale*center_panel.getWidth())/2;
double y = (getHeight() - scale*center_panel.getHeight())/2;
AffineTransform at = AffineTransform.getTranslateInstance(x,y);
at.scale(scale, scale);
}