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

📄 mainframe.java~2~

📁 这是各类实用工具的源码100例
💻 JAVA~2~
字号:
package jvideodemo2;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.media.*;import javax.media.control.*;import java.io.*;public class MainFrame extends JFrame implements ControllerListener{  private JPanel contentPane;  private BorderLayout borderLayout1 = new BorderLayout();  Component vc = null;  Component cc = null;  TrackControl[] tc = null;  Processor processor = null;  //Construct the frame  public MainFrame() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  public MainFrame(String mediaURL){    this();    try{      Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, new Boolean(true));      MediaLocator ml = new MediaLocator(mediaURL);      processor = Manager.createProcessor(ml);    }catch(IOException err){      terminate(err.toString());    }catch(NoProcessorException err){      terminate("Could not find a processor");    }    if (processor == null)      terminate("Could not create a processor");    processor.addControllerListener(this);    processor.configure();    while (processor.getState()!=Processor.Configured);    processor.setContentDescriptor(null);    tc = processor.getTrackControls();    if (tc.length>0){      Codec[] cd = new Codec[1];      cd[0] = new NegativeEffect();      try{        tc[0].setCodecChain(cd);      }catch(UnsupportedPlugInException err){        terminate(err.toString());      }    }    processor.realize();  }  //Component initialization  private void jbInit() throws Exception  {    //setIconImage(Toolkit.getDefaultToolkit().createImage(MainFrame.class.getResource("[Your Icon]")));    contentPane = (JPanel) this.getContentPane();    contentPane.setLayout(borderLayout1);    this.setSize(new Dimension(400, 300));    this.setTitle("JVideoDemo2");  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  public void controllerUpdate(ControllerEvent e){    if (e instanceof ControllerClosedEvent)      System.exit(0);    if (e instanceof EndOfMediaEvent){      processor.setMediaTime(new Time(0));      return;    }    if (e instanceof RealizeCompleteEvent){      vc = processor.getVisualComponent();      if (vc!=null)        this.getContentPane().add(vc,BorderLayout.CENTER);      cc =processor.getControlPanelComponent();      if (cc!=null)        this.add(cc,BorderLayout.SOUTH);      this.pack();      this.setResizable(false);      this.setVisible(true);    }  }  public void terminate(String str){    System.out.println(str);    System.exit(-1);  }}

⌨️ 快捷键说明

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