Sử dụng một số plugins hoặc API (Opensource rất nhiều)
Ví dụ sử dụng EasyJCom
Mã:
// NOTE: This sample assumes you have built the Flash COM object (Flash.ocx)'s JNI DLL with EZ JCom using the package name "flashswf" import flashswf.*;import javax.swing.*;import java.awt.*;import java.awt.event.*; public class FlashTest extends JFrame { /*** TO BE DONE *** Change the following string to point to the initial .swf file you want played. *** This can be a URL or it can be a path to a file. ***/ String home = "C:\\sample.swf"; ShockwaveFlash flash; JButton playButton = new JButton(); JButton browseButton = new JButton(); JLabel label = new JLabel( "URL or Path to .swf file: " ); JTextField url = new JTextField( 24 ); JPanel buttonPanel = new JPanel(); // This method is called when the Play button is clicked. void onPlayButtonClick() { try { // Load and play the .swf file. flash.getIShockwaveFlash().LoadMovie( 0, url.getText()); flash.getIShockwaveFlash().Play(); } catch (Exception ex) { ex.printStackTrace(); } } // This method is called when the Browse button is clicked. void onBrowseButtonClick() { // Let the user select a local .swf file. JFileChooser dlg = new JFileChooser(); dlg.setFileFilter( new javax.swing.filechooser.FileFilter() { public boolean accept(java.io.File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith( ".swf" ); } public String getDescription() { return "Flash Files (*.swf)"; } } ); dlg.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES ); dlg.setDialogTitle( "Select .swf file" ); dlg.showOpenDialog( this ); if ( dlg.getSelectedFile() != null ) { url.setText( dlg.getSelectedFile().getAbsolutePath()); } } // Primary entry point for the display void showFlash() { try { setDefaultCloseOperation( EXIT_ON_CLOSE ); getContentPane().setLayout( new BorderLayout()); // Create a container instance and add it to the frame. ezjcom.JComActiveXContainer activexContainer = new ezjcom.JComActiveXContainer(); getContentPane().add( activexContainer, BorderLayout.CENTER ); playButton.setText( "Play" ); browseButton.setText( "Browse..." ); browseButton.setFont( new Font( "Dialog", 0, 10 )); buttonPanel.add( label ); buttonPanel.add( browseButton ); buttonPanel.add( url ); buttonPanel.add( playButton ); getContentPane().add( buttonPanel, BorderLayout.SOUTH ); playButton.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { onPlayButtonClick(); } }); browseButton.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { onBrowseButtonClick(); } }); // Create the ActiveX object and attach it to the container. flash = new ShockwaveFlash(); activexContainer.setActiveX( flash ); // Provide a home. flash.getIShockwaveFlash().LoadMovie( 0, home ); flash.getIShockwaveFlash().Play(); // Show the frame. setSize( 600, 400 ); setVisible( true ); } catch (Exception ex) { ex.printStackTrace(); } } public static void main( String[] args ) { new FlashTest().showFlash(); } }
Pallet nhựa Long An đã trở thành một trong những lựa chọn phổ biến cho nhu cầu vận chuyển và lưu trữ hàng hóa trong nhiều ngành công nghiệp. Với đặc tính nhẹ nhàng, chắc chắn và dễ vận chuyển, các...
Thanh lý pallet nhựa Long An giá rẻ