作者needFresh (膩了新鮮感)
看板java
標題[問題] 有關JMF截圖問題
時間Tue Oct 27 13:15:29 2009
這是片段的程式碼
private class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
// Grab a frame
// Convert it to an image
FrameGrabbingControl fgc =
(FrameGrabbingControl)playerL.getControl("javax.media.control.FrameGrabbingControl");
buf = fgc.grabFrame();
btoi = new BufferToImage((VideoFormat)buf.getFormat());
img = btoi.createImage(buf);
// show the image
imgpanelLeft.setImage(img);
imgpanelLeft.repaint();
savePNG(img,"test");
}
}
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at SwingCapture$ButtonHandler.actionPerformed(SwingCapture.java:120)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
錯誤訊息是指向FrameGrabbingControl
其中還有很多函式的匯入都是顯示(Unknow Sorce)
想請問大家這個FrameGrabbingControl到底是什麼出現問題??
可以麻煩各位神手為我解惑嗎...
這個問題我想一兩個禮拜了...
麻煩大家了
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.122.146.55
推 PsMonkey:錯誤訊息呢? 不然違反版規喔.... 10/27 13:40
※ 編輯: needFresh 來自: 122.122.146.55 (10/27 13:59)
→ needFresh:感謝提醒 10/27 13:59
推 PsMonkey:唉... 這樣有什麼用? 沒人知道 120 行在哪裡? 10/27 14:24
→ needFresh:我有說是指向FrameGrabbingControl... 10/27 14:38
→ kanandg1:所以是getControl return了null?您有去查api嗎? 10/27 16:41
→ needFresh:查過了 是它的func. "getFrame()"回傳null的樣子 10/27 19:14
→ kanandg1:無法理解= ="func. "getFrame()"未出現在內文中... 10/27 19:58
→ needFresh:糟糕我打錯了!! 是grabFrame() 真是抱歉= =a 10/27 21:01
→ abruce042:會不會...import根本沒定義...(應該不會吧?) 10/28 14:58