Thursday, February 23, 2017

example12_with_frame.zubr

This is another zubr example from the Perkun's "examples" folder. It merely demonstrates that we can open a Swing frame when running the program. There are still no Perkun values or variables. Also the optimizer class is not instantiated yet.


// This is an example zubr specification.


// We can import Java packages here.
import javax.swing.JFrame;
import java.awt.Dimension;

%%

// here we put the Perkun code (values and variables)

values {}
variables {}

%%

// here we put Java code to be included in the result class

private static JFrame frame;

public static void main(String[] args) {
    frame = new JFrame();
    frame.setTitle("Optimizer");
    frame.setSize(new Dimension(800, 600));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);   
}


Try to process the example file with zubr:

zubr example12_with_frame.zubr > Optimizer.java

Then compile Optimizer.java with your Java compiler and run it. It will open a frame. When you close the frame the program terminates. Not a big deal. The example just shows how to include Java into your zubr specification.

Download zubr from https://sourceforge.net/projects/perkun/.


No comments:

Post a Comment