假设我们有以下情况:
JPanel panelp=new JPanel();
paintSomething(panelp.getGraphics();
在不同对象的其他地方,方法:
void paintSomething(Graphics g){ /*code*/ }
我不想覆盖paintComponent. panelp我怎样才能使用ofpanelp的方法绘制一些东西? paintSomethingGraphicspanelp
假设我们有以下情况:
JPanel panelp=new JPanel();
paintSomething(panelp.getGraphics();
在不同对象的其他地方,方法:
void paintSomething(Graphics g){ /*code*/ }
我不想覆盖paintComponent. panelp我怎样才能使用ofpanelp的方法绘制一些东西? paintSomethingGraphicspanelp
whatever.getGraphics()is snapshot 是在什么时候消失的快照
第一次重绘后
JComponetsMouse从or内部重新绘制Key Events,这些事件在具体实现JComponets API
使用的简单示例whatever.getGraphics()是打印到打印机或将当前 GUI 作为打印屏幕保存到例如 JPEG 或 PGN 文件
基本的东西在2D Graphics中描述
You could draw your stuff in the paintSomething into a BufferedImage which you can then draw to the panel by overriding paintComponent