package jetbrains.mps.samples.SwingBuilder.sandbox; /*Generated by MPS */ import javax.swing.JFrame; import java.awt.FlowLayout; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.GridLayout; import javax.swing.JTextField; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JButton; public class SwingDSLDemo { public boolean logicalProperty; { { JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setTitle(buildTitle()); { JComponent c = new JLabel("Sample form"); frame.add(c); } { JPanel p = new JPanel(); p.setLayout(new GridLayout(4, 1)); { JComponent c = new JLabel("The value"); p.add(c); } { final JTextField field = new JTextField(); field.setColumns(10); field.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent p0) { fieldValue = field.getText(); } }); p.add(field); } { JComponent c = new JLabel("Another value"); p.add(c); } frame.add(p); } { JButton button = new JButton("Submit"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent p0) { clicked(); } }); frame.add(button); } frame.setVisible(true); frame.pack(); } } private String buildTitle() { return "Demo"; } private void clicked() { logicalProperty = !(logicalProperty); System.out.println("Clicked! The current value of logicalProperty is: " + logicalProperty); } private String fieldValue = ""; public static void main(String[] args) { new SwingDSLDemo(); } }