我有一个问题,如图所示
我的添加过程如下:
JFrame -> 查看面板 -> JTabbedPane -> JPanel(我的画布)
我在paintComponent 中绘制我的绘图,并在最后调用revalidate()。帮助将不胜感激!
编辑:
油漆组件代码
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
//Obtain document size
double width = model.getWidth();
double height = model.getHeight();
canvasBounds = new Rectangle2D.Double(0, 0, width, height);
g2d.setColor(Color.WHITE);
g2d.fill(canvasBounds);
Dimension size = new Dimension();
size.setSize(canvasBounds.getWidth() * zoomFactor, canvasBounds.getHeight() * zoomFactor);
this.setPreferredSize(size);
g2d.setClip(canvasBounds);
List<DrawableShape> svgShapes = model.getDrawableShapes();
for(DrawableShape shape : shapeList) {
shape.draw(g2d);
}
revalidate();
}