Skip to content

Instantly share code, notes, and snippets.

@mmhelloworld
Created April 7, 2014 02:48
Show Gist options
  • Save mmhelloworld/10014175 to your computer and use it in GitHub Desktop.
Save mmhelloworld/10014175 to your computer and use it in GitHub Desktop.
Java Applets with Frege
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");
}
}
}
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 ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment