import com.codename1.ui.Component; //导入方法依赖的package包/类
private void paint(Graphics g, Component cmp, int x, int y, boolean background) {
boolean b = cmp.isVisible();
cmp.setVisible(true);
int cx = g.getClipX();
int cy = g.getClipY();
int cw = g.getClipWidth();
int ch = g.getClipHeight();
if (cmp instanceof Dialog) {
if (transitionType == TYPE_FADE && Display.getInstance().areMutableImagesFast()) {
cmp.paintComponent(g, background);
return;
}
if (!(getSource() instanceof Dialog && getDestination() instanceof Dialog
&& cmp == getDestination())) {
Painter p = cmp.getStyle().getBgPainter();
cmp.getStyle().setBgPainter(null);
g.translate(x, y);
Dialog dlg = (Dialog) cmp;
g.setClip(0, 0, cmp.getWidth(), cmp.getHeight());
getDialogParent(dlg).paintComponent(g, false);
g.translate(-x, -y);
if (drawDialogMenu && dlg.getCommandCount() > 0) {
Component menuBar = dlg.getSoftButton(0).getParent();
if (menuBar != null) {
g.setClip(0, 0, cmp.getWidth(), cmp.getHeight());
menuBar.paintComponent(g, false);
}
}
g.setClip(cx, cy, cw, ch);
cmp.getStyle().setBgPainter(p);
}else{
cmp.paintComponent(g, background);
}
return;
}
//g.clipRect(cmp.getAbsoluteX(), cmp.getAbsoluteY(), cmp.getWidth(), cmp.getHeight());
g.translate(x, y);
//g.clipRect(cmp.getAbsoluteX(), cmp.getAbsoluteY(), cmp.getWidth(), cmp.getHeight());
cmp.paintComponent(g, background);
g.translate(-x, -y);
g.setClip(cx, cy, cw, ch);
cmp.setVisible(b);
}