我正在尝试放置两个画布元素,让每个屏幕占据一半。但是当我使用 FlowLayout 时,两个画布都放在中心,彼此放在一起。
我有以下结果:
我想得到如下图所示:
我的代码:
public class SigForApplication extends Frame{
public SigForApplication(String title) {
commonInit(title);
sigInit();
}
public static void main(String[] args) {
SigForApplication a = new SigForApplication("SigFor");
}
private void commonInit(String title) {
this.setTitle(title);
this.setLayout(new FlowLayout());
this.setSize(800, 400);
this.setVisible(true);
this.addWindowListener(
new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
}
private void sigInit() {
SignatureCanvasInput sigCanvasIn = new SignatureCanvasInput();
sigCanvasIn.setSize(new Dimension(400, 200));
this.add(sigCanvasIn);
SignatureCanvasInput sigCanvasOutput = new SignatureCanvasInput();
sigCanvasOutput.setMaximumSize(new Dimension(400, 200));
this.add(sigCanvasOutput);
}
}