窗体切换特效之一
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-01 17:52 点击:次
以上第一幅图是窗体切换特效之一;第二幅图是控件切换特效之一
以下给出设置特效的代码,这些代码同样来自Sample例子中:
1. /*
2. * Copyright ?2008 Sun Microsystems, Inc. All rights reserved.
3. * Use is subject to license terms.
4. *
5. */
6. package com.sun.lwuit.uidemo;
7.
8. import com.sun.lwuit.Button;
9. import com.sun.lwuit.ButtonGroup;
10. import com.sun.lwuit.CheckBox;
11. import com.sun.lwuit.Command;
12. import com.sun.lwuit.Component;
13. import com.sun.lwuit.Container;
14. import com.sun.lwuit.Dialog;
15. import com.sun.lwuit.Display;
16. import com.sun.lwuit.Form;
17. import com.sun.lwuit.Label;
18. import com.sun.lwuit.M3G;
19. import com.sun.lwuit.RadioButton;
20. import com.sun.lwuit.TextArea;
21. import com.sun.lwuit.TextField;
22. import com.sun.lwuit.animations.CommonTransitions;
23. import com.sun.lwuit.animations.Transition;
24. import com.sun.lwuit.animations.Transition3D;
25. import com.sun.lwuit.events.ActionEvent;
26. import com.sun.lwuit.events.ActionListener;
27. import com.sun.lwuit.layouts.BoxLayout;
28. import com.sun.lwuit.layouts.FlowLayout;
29. import com.sun.lwuit.plaf.Style;
30.
31.
32. /**
33. * Transitons between screens
34. *
35. * @author Shai Almog
36. */
37. public class TransitionDemo extends Demo {
38. /**
39. * The selected radio button index
40. */
41. private static int selectedIndex = 0;
42.
43. public String getName() {
44. return "Transitions";
45. }
46.
47. protected String getHelp() {
48. return "Transitions appear when switching from one form to the next, a transition can be bound " +
49. "to the operation of exiting or entering the screen. There are default transitions in the toolkit " +
50. "and custom transitions are easy to write.";
51. }
52.
53. private RadioButton createRB(String label, ButtonGroup g, Form f) {
54. RadioButton b = new RadioButton(label);
55. Style s = b.getStyle();
56. s.setMargin(0, 0, 0, 0);
57. s.setBgTransparency(70);
58. g.add(b);
59. f.addComponent(b);
60. return b;
61. }
62.
63. protected void execute(final Form f) {
64. f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
65. Label title = new Label("Please select a transition type:");
66. title.getStyle().setMargin(0, 0, 0, 0);
67. title.getStyle().setBgTransparency(70);
68. f.addComponent(title);
69.
70. final ButtonGroup radioButtonGroup = new ButtonGroup();
71. createRB("Slide Horizontal", radioButtonGroup, f);
72. createRB("Slide Vertical", radioButtonGroup, f);
73. createRB("Fade", radioButtonGroup, f);
74. if(M3G.isM3GSupported()) {
75. createRB("Rotate", radioButtonGroup, f)
相关新闻>>
- 发表评论
-
- 最新评论 更多>>