⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a.java~4~

📁 swing下如何实现flash
💻 JAVA~4~
字号:
package swt_flash;


import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;

import com.docuverse.swt.flash.FlashPlayer;
import com.docuverse.swt.flash.FlashPlayerListener;

public class A implements FlashPlayerListener {
        Shell shell;
        FlashPlayer player;

        private void createMenuBar() {
                Menu menuBar = new Menu(shell, SWT.BAR);
                shell.setMenuBar(menuBar);

                MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
                item.setText("Color");
                Menu menu = new Menu(shell, SWT.DROP_DOWN);
                item.setMenu(menu);

                MenuItem subItem = new MenuItem(menu, SWT.NULL);
                subItem.setText("Red");
                subItem.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent event) {
                                player.setVariable("buttonColor", "0xFF0000");
                        }
                });
                subItem = new MenuItem(menu, SWT.NULL);
                subItem.setText("Blue");
                subItem.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent event) {
                                player.setVariable("buttonColor", "0x0000FF");
                        }
                });
                subItem = new MenuItem(menu, SWT.NULL);
                subItem.setText("Green");
                subItem.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent event) {
                                player.setVariable("buttonColor", "0x00FF00");
                        }
                });
        }

        private void createFlashApp() {
                player = new FlashPlayer(shell, SWT.NONE, this);
                // this line loads the flash movie from disk
                player.loadMovie(0,"d:\\a.swf");
                player.setSize(150, 150);
                player.activate();
        }

        public static void main (String [] args) {
                Display display = new Display();
                Shell shell = new A().open (display);

                while (!shell.isDisposed()) {
                        if (!display.readAndDispatch()) display.sleep ();
                }
                display.dispose ();
        }

        public Shell open (Display display) {
                shell = new Shell (display);

                createMenuBar();
                createFlashApp();

                shell.setSize(150, 200);
                shell.open();

                return shell;
        }

        public void onFSCommand(String param, String value) {
                System.out.println("\nFSCommand:\nParam = " + param + "\nValue = " + value);
        }

        public void onReadyStateChange(int arg) {}
        public void onProgress(int arg) {}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -