Print
Sample Scripts

This page contains an assortment of sample scripts, written in MVEL, to demonstrate the language:

Sample 1 - Inline Array's and Foreach Loop

colors = {'red', 'green', 'blue'};

foreach (c : colors) {
   System.out.println(c + "!");
}

Output:

red!

green!

blue!

Sample 2 - Swing

import javax.swing.JFrame;
import javax.swing.JLabel;

with (frame = new JFrame()) {
    title = "My Swing Frame",
    resizable = true
}

frame.contentPane.add(new JLabel("My Label"));
frame.pack();
frame.visible = true;

See a similar example of this script in the MVEL Shell, demonstrated here

Powered by Atlassian Confluence