我在图像中有一个AWT Applet。整个区域可用于绘制一些东西。现在我想在它前面嵌入一个ScrollPane。但滚动会产生影响,画面会被覆盖。
所以我需要一种方法来嵌入一个不影响底层绘画的组件。我完全不熟悉这些东西了。摇摆是别无选择。代码添加在底部。
谢谢。
public class AWT extends Applet {
Dimension offDimension;
Image offImage;
Graphics offGraphics;
Panel panel = new Panel();
ScrollPane scrollpane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
public void paint(Graphics g) {
update(g);
}
public void update(Graphics g) {
if ((offGraphics == null) || (500 != offDimension.width)
|| (500 != offDimension.height)) {
Dimension d = new Dimension(500,500);
offDimension = d;
offImage = createImage(500, 500);
offGraphics = offImage.getGraphics();
}
redraw(offGraphics);
g.drawImage(offImage, 0, 0, this);
}
public void init() {
ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
Panel p = new Panel();
TextArea a = new TextArea();
a.setText("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
sp.add(a);
sp.setSize(300, 300);
add(sp);
}
public void redraw(Graphics g) {
g.drawRect(50, 50, 55, 55);
g.setColor(Color.BLUE);
g.fillRoundRect(0 , 0, 200, 200, 200, 200);
}
}