001/*----------------------------------------------------------------------------*/
002/* Copyright (c) FIRST 2008-2017. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj.buttons;
009
010import edu.wpi.first.wpilibj.networktables.NetworkTable;
011
012/**
013 * A {@link Button} that uses a {@link NetworkTable} boolean field.
014 */
015public class NetworkButton extends Button {
016
017  private final NetworkTable m_table;
018  private final String m_field;
019
020  public NetworkButton(String table, String field) {
021    this(NetworkTable.getTable(table), field);
022  }
023
024  public NetworkButton(NetworkTable table, String field) {
025    m_table = table;
026    m_field = field;
027  }
028
029  public boolean get() {
030    return m_table.isConnected() && m_table.getBoolean(m_field, false);
031  }
032}