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

📄 moviepanel.java

📁 java写的图片浏览器,类似acds
💻 JAVA
字号:
package org.net9.oops.jsee;
/*
 * MoviePanel.java
 *
 * Created on 2 July 2002, 19:36
 */
import java.net.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;

public class MoviePanel extends JPanel {

    javax.media.Player player;
    int Preview_Area_Height, Preview_Area_Width;
    JPanel thisPointer;
    //URL mediaFile;
    /** Creates new form MoviePanel */
    public MoviePanel(URL mf, int width, int height) {
        //mediaFile = mf;
        Preview_Area_Width = width;
        Preview_Area_Height = height;
        thisPointer = this;
        try {
            player = javax.media.Manager.createPlayer(mf);    
            player.addControllerListener( new EventHandler());
        } catch (IOException ie) {}
          catch (javax.media.NoPlayerException npe) {}
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        
        setLayout(new java.awt.BorderLayout());
        
    }//GEN-END:initComponents

    public void stop() {
        player.stop();
    }
    
    public void start() {
        if (player != null)
        player.start();
    }
    
    private class EventHandler implements javax.media.ControllerListener {
        public void controllerUpdate(javax.media.ControllerEvent e) {
            if (e instanceof javax.media.RealizeCompleteEvent) {
                Component visualComp;
                Component controlComp;
                visualComp = player.getVisualComponent();
                controlComp = player.getControlPanelComponent();
                
                Dimension vSize = (player.getVisualComponent()).getPreferredSize();
                //System.out.println("Height: " + vSize.height + " Width: " + vSize.width);
                int xCoordinate, yCoordinate;                                
                xCoordinate = (Preview_Area_Width - vSize.width)/2;
                //System.out.println("X coordinate: " + xCoordinate);
                yCoordinate = (Preview_Area_Height - vSize.height)/2;
                //System.out.println("Y coordinate: " + yCoordinate);
                
                visualComp.setBounds(xCoordinate, yCoordinate, vSize.width, vSize.height);
                controlComp.setBounds(xCoordinate, vSize.height+yCoordinate, vSize.width, controlComp.getPreferredSize().height);
                //panel.add(new JLabel("Damn it"), BorderLayout.NORTH);
                //panel.add(new JLabel("North"), BorderLayout.NORTH);
                
                thisPointer.add(visualComp, BorderLayout.CENTER);
                thisPointer.add(controlComp, BorderLayout.SOUTH);
                thisPointer.setSize(vSize.width + xCoordinate, vSize.height + yCoordinate + 20);
            }
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}

⌨️ 快捷键说明

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