public PropertyPanel(MainWindow mw)
    {
        this.mw = mw;
        this.texts = new TextField[5];
        this.targets = new Choice[4];
        this.types = new Choice[4];

        setLayout(new BorderLayout(8, 8));
        add(name = new Label("Properties", Label.CENTER), BorderLayout.NORTH);
        add( msg = new Label("", Label.CENTER), BorderLayout.SOUTH);
        msg.setForeground(Color.RED);

        p1 = new TabbedPanel(TAB_NAMES);
        add(p1, BorderLayout.CENTER);
        final Panel [] ps = p1.getPanels();

        for(Panel p : ps)
            p.setLayout( new StackLayout(4, 4, 2));


        // position
        add_header(ps[0], "Point 0", "");
        texts[0] = add_edit(ps[0], "X0", "0");
        texts[1] = add_edit(ps[0], "Y0", "0");

        add_header(ps[0], "Point 1", "");
        texts[2] = add_edit(ps[0], "X1", "0");
        texts[3] = add_edit(ps[0], "Y1", "0");

        add_header(ps[0], "size", "");
        ps[0].add(new Label("dX", Label.RIGHT));
        ps[0].add(dx = new Label("", Label.LEFT));
        ps[0].add(new Label("dY", Label.RIGHT));
        ps[0].add(dy = new Label("", Label.LEFT));


        // targets
        add_header(ps[1], "Point 0", "");
        targets[0] = add_choice(ps[1], "X0 anchor");
        types[0] = add_choice(ps[1], "X0 type");
        targets[1] = add_choice(ps[1], "Y0 anchor");
        types[1] = add_choice(ps[1], "Y0 type");

        add_header(ps[1], "Point 1", "");
        targets[2] = add_choice(ps[1], "X1 anchor");
        types[2] = add_choice(ps[1], "X1 type");
        targets[3] = add_choice(ps[1], "Y1 anchor");
        types[3] = add_choice(ps[1], "Y1 type");

        // misc
        add_header(ps[2], "Region extras", "");
        texts[4] = add_edit(ps[2], "Flags", "0");


        add_header(ps[2], "Global parameters", "");

        for(Choice type : types) {
            for(int j = 0; j < Database.TYPES.length; j++)
                type.add(Database.TYPES[j]);
            type.select(0);
        }

        alignment = add_choice(ps[2], "Real-time alignment");
        alignment.add("None");
        for(int i = 1; i < 8; i++)
            alignment.add("" + (1 << i) + " pixels");

        alignment_force = add_button(ps[2], "Set to RT value", "Editor alignment");


        alignment.select(Database.global_alignment);
        p1.set(0);
        regionChanged();

        // for(TextField tf : texts) tf.addTextListener(this);
        for(TextField tf : texts) tf.addKeyListener(this);
        for(Choice c : targets) c.addItemListener(this);
        for(Choice c : types) c.addItemListener(this);

        alignment.addItemListener(this);
        alignment_force.addActionListener(this);
    }