Examples of JFlashPlayer


Examples of chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer

  public static JComponent createContent() {
    JPanel contentPane = new JPanel(new BorderLayout());
    JPanel flashPlayerPanel = new JPanel(new BorderLayout());
    flashPlayerPanel.setBorder(BorderFactory.createTitledBorder("Native Flash Player component"));
    final JFlashPlayer flashPlayer = new JFlashPlayer();
    flashPlayer.setControlBarVisible(true);
    FlashPluginOptions flashLoadingOptions = new FlashPluginOptions();
    flashLoadingOptions.setVariables(new HashMap<String, String>() {{put("mytext", "My Text");}});
    flashPlayer.load(VariablesAndFlow.class, "resource/dyn_text_moving.swf", flashLoadingOptions);
    flashPlayerPanel.add(flashPlayer, BorderLayout.CENTER);
    contentPane.add(flashPlayerPanel, BorderLayout.CENTER);
    JPanel variablePanel = new JPanel(new BorderLayout());
    variablePanel.setBorder(BorderFactory.createTitledBorder("Get/Set Variables"));
    JPanel getSetNorthPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2));
    getSetNorthPanel.add(new JLabel("Text:"));
    final JTextField setTextField = new JTextField(new PlainDocument() {
      @Override
      public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
        if(str != null && getLength() + str.length() > 7) {
          return;
        }
        super.insertString(offs, str, a);
      }
    }, "Set", 14);
    getSetNorthPanel.add(setTextField);
    JButton setButton = new JButton("Set");
    setButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        flashPlayer.setVariable("mytext", setTextField.getText());
      }
    });
    getSetNorthPanel.add(setButton);
    JButton getButton = new JButton("Get");
    getSetNorthPanel.add(getButton);
    variablePanel.add(getSetNorthPanel, BorderLayout.NORTH);
    JPanel getSetSouthPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2));
    getSetSouthPanel.add(new JLabel("Last acquired text:"));
    final JLabel getLabel = new JLabel("-");
    getButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        String value = (String)flashPlayer.getVariable("mytext");
        getLabel.setText(value == null || value.length() == 0? " ": value);
      }
    });
    getSetSouthPanel.add(getLabel);
    variablePanel.add(getSetSouthPanel, BorderLayout.SOUTH);
View Full Code Here

Examples of chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer

  public static JComponent createContent() {
    JPanel contentPane = new JPanel(new BorderLayout());
    JPanel flashPlayerPanel = new JPanel(new BorderLayout());
    flashPlayerPanel.setBorder(BorderFactory.createTitledBorder("Native Flash Player component"));
    final JFlashPlayer flashPlayer = new JFlashPlayer();
    // Flash Demo from Paulus Tuerah (www.goldenstudios.or.id)
    flashPlayer.load(FunctionCalls.class, "resource/FlashPlayerInteractions.swf");
    flashPlayerPanel.add(flashPlayer, BorderLayout.CENTER);
    contentPane.add(flashPlayerPanel, BorderLayout.CENTER);
    GridBagLayout gridBag = new GridBagLayout();
    JPanel interactionsPanel = new JPanel(gridBag);
    interactionsPanel.setBorder(BorderFactory.createTitledBorder("Java Interactions"));
    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = 0;
    cons.gridy = 0;
    cons.insets = new Insets(1, 1, 1, 1);
    cons.anchor = GridBagConstraints.WEST;
    JLabel functionLabel = new JLabel("Function Call: ");
    gridBag.setConstraints(functionLabel, cons);
    interactionsPanel.add(functionLabel);
    cons.gridy++;
    JLabel commandLabel = new JLabel("Received Command: ");
    gridBag.setConstraints(commandLabel, cons);
    interactionsPanel.add(commandLabel);
    cons.gridx++;
    cons.gridy = 0;
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.weightx = 1;
    FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 2, 0);
    JPanel getterSetterFunctionPanel = new JPanel(flowLayout);
    JButton getterButton = new JButton("Get");
    getterSetterFunctionPanel.add(getterButton);
    final JTextField functionTextField = new JTextField(14);
    getterSetterFunctionPanel.add(functionTextField);
    JButton setterButton = new JButton("Set");
    getterSetterFunctionPanel.add(setterButton);
    gridBag.setConstraints(getterSetterFunctionPanel, cons);
    interactionsPanel.add(getterSetterFunctionPanel);
    cons.gridy++;
    final JLabel commandValueLabel = new JLabel("-");
    gridBag.setConstraints(commandValueLabel, cons);
    interactionsPanel.add(commandValueLabel);
    contentPane.add(interactionsPanel, BorderLayout.SOUTH);
    // Attach the listeners
    getterButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        functionTextField.setText((String)flashPlayer.invokeFlashFunctionWithResult("getMessageX"));
      }
    });
    setterButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        flashPlayer.invokeFlashFunction("setMessageX", functionTextField.getText());
      }
    });
    flashPlayer.addFlashPlayerListener(new FlashPlayerListener() {
      public void commandReceived(FlashPlayerCommandEvent e) {
        if("sendCommandTest".equals(e.getCommand())) {
          StringBuilder sb = new StringBuilder();
          Object[] parameters = e.getParameters();
          for(int i=0; i<parameters.length; i++) {
View Full Code Here

Examples of chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer

* @author Christopher Deckers
*/
public class SimpleFlashExample {

  public static JComponent createContent() {
    JFlashPlayer flashPlayer = new JFlashPlayer();
    flashPlayer.load(SimpleFlashExample.class, "resource/Movement-pointer_or_click.swf");
    return flashPlayer;
  }
View Full Code Here

Examples of chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setOpaque(true);
    layeredPane.setBackground(new Color(200, 200, 255));
    int layerIndex = 0;
    // A flash player
    JFlashPlayer flashPlayer = new JFlashPlayer(JFlashPlayer.constrainVisibility());
    flashPlayer.setControlBarVisible(false);
    flashPlayer.load(SimpleFlashExample.class, "resource/Movement-pointer_or_click.swf");
    flashPlayer.setBounds(0, 0, 200, 200);
    layeredPane.setLayer(flashPlayer, layerIndex++);
    layeredPane.add(flashPlayer);
    // A swing panel
    JPanel swingPanel = new JPanel();
    swingPanel.setBorder(BorderFactory.createTitledBorder("Swing JPanel"));
View Full Code Here

Examples of chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer

    });
  }

  private static JFlashPlayer createPlayerWithDefaultLyfeCycle(final JTextArea logTextArea, JComponent componentPane) {
    log(logTextArea, "- JFlashPlayer creation.");
    JFlashPlayer flashPlayer = new JFlashPlayer(JFlashPlayer.destroyOnFinalization());
    flashPlayer.setControlBarVisible(false);
    log(logTextArea, "  -> Calls will be played after initialization.");
    flashPlayer.runInSequence(new Runnable() {
      public void run() {
        log(logTextArea, "- JFlashPlayer is initialized.");
        log(logTextArea, "  -> runInSequence() used to display this message.");
      }
    });
    log(logTextArea, "- Before JFlashPlayer.load() call.");
    flashPlayer.load(SimpleFlashExample.class, "resource/Movement-pointer_or_click.swf");
    flashPlayer.runInSequence(new Runnable() {
      public void run() {
        log(logTextArea, "- runInSequence(): JFlashPlayer.load() has run.");
      }
    });
    log(logTextArea, "- After JFlashPlayer.load() call.");
View Full Code Here

Examples of chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer

    return flashPlayer;
  }

  private static JFlashPlayer createPlayerWithForcedInitializationLyfeCycle(final JTextArea logTextArea, JComponent componentPane) {
    log(logTextArea, "- JFlashPlayer creation.");
    JFlashPlayer flashPlayer = new JFlashPlayer(JFlashPlayer.destroyOnFinalization());
    flashPlayer.setControlBarVisible(false);
    log(logTextArea, "- JFlashPlayer addition to containment hierarchy.");
    log(logTextArea, "  (mandatory before forced initialization)");
    componentPane.add(flashPlayer, BorderLayout.CENTER);
    componentPane.revalidate();
    componentPane.repaint();
    log(logTextArea, "- Forced initialization of the native peer.");
    log(logTextArea, "  -> Calls are now synchronous.");
    flashPlayer.initializeNativePeer();
    flashPlayer.runInSequence(new Runnable() {
      public void run() {
        log(logTextArea, "- JFlashPlayer is initialized.");
        log(logTextArea, "  -> runInSequence() used to display this message.");
      }
    });
    log(logTextArea, "- Before JFlashPlayer.load() call.");
    flashPlayer.load(SimpleFlashExample.class, "resource/Movement-pointer_or_click.swf");
    flashPlayer.runInSequence(new Runnable() {
      public void run() {
        log(logTextArea, "- runInSequence(): JFlashPlayer.load() has run.");
      }
    });
    log(logTextArea, "- After JFlashPlayer.load() call.");
View Full Code Here

Examples of chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer

    // Flash Player internal frame
    JInternalFrame flashPlayerInternalFrame = new JInternalFrame("Flash Player");
    flashPlayerInternalFrame.setBounds(100, 100, 400, 280);
    flashPlayerInternalFrame.setResizable(true);
    flashPlayerInternalFrame.setVisible(true);
    JFlashPlayer flashPlayer = new JFlashPlayer(JFlashPlayer.proxyComponentHierarchy());
    flashPlayer.setControlBarVisible(false);
    flashPlayer.load(SimpleFlashExample.class, "resource/Movement-pointer_or_click.swf");
    flashPlayerInternalFrame.add(flashPlayer, BorderLayout.CENTER);
    desktopPane.add(flashPlayerInternalFrame);
    // Web Browser 2 internal frame, with a button on top
    JInternalFrame webBrowser2InternalFrame = new JInternalFrame("Web Browser 2 with a JButton on top");
    webBrowser2InternalFrame.setBounds(190, 190, 400, 280);
View Full Code Here

Examples of chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer

*/
public class DeferredDestruction {


  public static JComponent createContent() {
    final JFlashPlayer flashPlayer = new JFlashPlayer(JFlashPlayer.destroyOnFinalization());
    final JPanel contentPane = new JPanel(new BorderLayout()) {
      @Override
      public void removeNotify() {
        super.removeNotify();
        // flashPlayer is destroyed on finalization.
        // Rather than wait for garbage collection, release when the component is removed from its parent.
        flashPlayer.disposeNativePeer();
      }
    };
    flashPlayer.setControlBarVisible(false);
    flashPlayer.load(SimpleFlashExample.class, "resource/Movement-pointer_or_click.swf");
    contentPane.add(flashPlayer, BorderLayout.CENTER);
    JButton addRemoveButton = new JButton("Add/Remove component");
    addRemoveButton.addActionListener(new ActionListener() {
      protected boolean isAdded = true;
      public void actionPerformed(ActionEvent e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.