怎样才能在java gui界面里嵌入一个flash软件?
在自己所做的Java程序中嵌入一个flash软件,在Javagui界面里就运行flash软件即可以看flash...
在自己所做的Java程序中嵌入一个flash软件,在Java gui界面里就运行flash软件即可以看flash
展开
2013-07-03
展开全部
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 SWTFlash_Example 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,"c:\\eclipse\\workspace\\SWTFlashExample\\SwtFlashExample.swf");
player.setSize(150, 150); player.activate();
}
public static void main (String [] args) {
Display display = new Display();
Shell shell = new SWTFlash_Example().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) {
}
}
arcade_mc.onPress = function() {
fscommand("pressed", ++this.count);
}
function onButtonColorChange(prop, oldval, newval) {
var c = new Color(arcade_mc.color_mc);
c.setRGB(newval);
}
this.watch("buttonColor", onButtonColorChange);
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 SWTFlash_Example 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,"c:\\eclipse\\workspace\\SWTFlashExample\\SwtFlashExample.swf");
player.setSize(150, 150); player.activate();
}
public static void main (String [] args) {
Display display = new Display();
Shell shell = new SWTFlash_Example().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) {
}
}
arcade_mc.onPress = function() {
fscommand("pressed", ++this.count);
}
function onButtonColorChange(prop, oldval, newval) {
var c = new Color(arcade_mc.color_mc);
c.setRGB(newval);
}
this.watch("buttonColor", onButtonColorChange);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-03
展开全部
Java的Flash类库 JSwiff 这个插件是专门用来处理flash的比较简单 可以用来生成和修改flash文件 如果仅仅是播放一个flash,那比较容易,加载一个播放器就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询