用户对问题“如何使用其窗体为玻璃窗格设置动画?”的回答 | 您所在的位置:网站首页 › agraphics › 用户对问题“如何使用其窗体为玻璃窗格设置动画?”的回答 |
当显示一个Form并调用另一个Form的show方法时,新的Form会在旧的Form上生成动画。 然而,玻璃窗格显然不参与动画,这看起来很奇怪。 有没有办法让玻璃窗格参与动画? 下面是一些代码: Form hi = new Form("Hi World", BoxLayout.y()); hi.add(new Label("Hi World")); hi.setGlassPane(new Painter() { @Override public void paint(Graphics aGraphics, Rectangle aRectangle) { int width = hi.getWidth(); int height = hi.getHeight(); int size = Math.min(width, height) * 2 / 3; aGraphics.setColor(0xff0000); aGraphics.fillRoundRect((width - size) / 2, (height - size) / 2, size, size, size / 4, size / 4); } }); hi.getToolbar().addCommandToRightBar(new Command("Other") { @Override public void actionPerformed(ActionEvent aActionEvent) { Form form = new Form("Other Form"); form.getToolbar().addCommandToLeftBar(new Command("Back") { @Override public void actionPerformed(ActionEvent aActionEvent) { hi.showBack(); } }); form.setGlassPane(new Painter() { @Override public void paint(Graphics aGraphics, Rectangle aRectangle) { int width = hi.getWidth(); int height = hi.getHeight(); int size = Math.min(width, height) * 2 / 3; aGraphics.setColor(0x2020ff); aGraphics.fillRoundRect((width - size) / 2, (height - size) / 2, size, size, size / 4, size / 4); } }); form.show(); } }); hi.show(); |
CopyRight 2018-2019 实验室设备网 版权所有 |