Skip to content

Instantly share code, notes, and snippets.

@mmhelloworld
Created April 7, 2014 02:48
Show Gist options
  • Select an option

  • Save mmhelloworld/10014175 to your computer and use it in GitHub Desktop.

Select an option

Save mmhelloworld/10014175 to your computer and use it in GitHub Desktop.

Revisions

  1. mmhelloworld created this gist Apr 7, 2014.
    28 changes: 28 additions & 0 deletions AppletSupport.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    package fregeappletsupport;

    import javax.swing.JApplet;
    import javax.swing.SwingUtilities;

    import fregeapplet.HelloApplet;

    /**
    * A starter class since Frege cannot extend a Java class
    *
    */
    public class AppletSupport extends JApplet {
    @Override
    public void init() {
    try {
    SwingUtilities.invokeAndWait(new Runnable() {
    @Override
    public void run() {
    // This calls frege function
    HelloApplet.appletInit(AppletSupport.this).apply(1).result().forced();
    }
    });
    } catch (final Exception e) {
    System.err.println("createGUI didn't complete successfully");
    }
    }

    }
    13 changes: 13 additions & 0 deletions HelloApplet.fr
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    module fregeapplet.HelloApplet where

    import Java.Swing

    data JApplet = native javax.swing.JApplet

    appletInit :: JApplet -> IO ()
    appletInit applet = do
    hw <- JLabel.new "Hello World from frege!"
    applet.add hw
    return ()