Skip to content

Sample 008

Michael Karneim edited this page May 9, 2018 · 1 revision
package wiki.snippets;

import java.awt.FlowLayout;

import javax.swing.JFrame;

import org.beanfabrics.model.BooleanPM;
import org.beanfabrics.model.IBooleanPM;
import org.beanfabrics.swing.BnCheckBox;

/**
 * Sample for using a BnCheckBox
 */
public class Sample008 {
    public static void main(String[] args) {
        // the BnCheckBox is a View on IBooleanPM,
        // so we create a model
        IBooleanPM model = new BooleanPM();
        
        // create the checkbox
        BnCheckBox checkBox = new BnCheckBox();
        // assign the model
        checkBox.setPresentationModel(model);
        
        // show the checkbox inside a frame
        JFrame frame = new JFrame("Using BnCheckBox");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout( new FlowLayout());
        frame.add(checkBox);
        frame.setSize(300, 300);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}