View Single Post
  #2   Spotlight this post!  
Unread 19-01-2013, 20:06
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Custom SmartDashboard Widget

I haven't made a widget personally, but the people who made SmartDashboard have made quite a few! Here's CheckBox from the SmartDashboard source code:
Code:
package edu.wpi.first.smartdashboard.gui.elements;

import edu.wpi.first.smartdashboard.gui.elements.bindings.AbstractValueWidget;
import javax.swing.*;

import edu.wpi.first.smartdashboard.properties.*;
import edu.wpi.first.smartdashboard.types.*;

/**
 * Implements a simple text box UI element with a name label.
 * @author pmalmsten
 */
public class CheckBox extends AbstractValueWidget {

    public static final DataType[] TYPES = {DataType.BOOLEAN};

    public final BooleanProperty editable = new BooleanProperty(this, "Editable", true);
    
    private EditableBooleanValueCheckBox valueField;

    public void init() {
        setResizable(false);

        setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

        valueField = new EditableBooleanValueCheckBox(getFieldName());

        add(valueField);
    }

    @Override
    public void propertyChanged(Property property) {
        if (property == editable) {
            valueField.setEnabled(editable.getValue());
        }
    }
}
__________________
I code stuff.
Reply With Quote