public static void main(String[] args) {
JFrame testFrame = new JFrame(StateTest.class.getSimpleName());
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final Label stateLabel = new Label();
final StringScalarBox stringScalarBox = new StringScalarBox();
final IKey key = new TangoKey();
TangoKeyTool.registerAttribute(key, "tango/tangotest/titan/state");
JButton connectButton = new JButton("connect/disconnect");
connectButton.addActionListener(new ActionListener() {
boolean connected = false;
@Override
public void actionPerformed(ActionEvent e) {
if (connected) {
connected = false;
stringScalarBox.disconnectWidget(stateLabel, key);
} else {
connected = true;
stringScalarBox.connectWidget(stateLabel, key);
}
}
});
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(stateLabel, BorderLayout.CENTER);
mainPanel.add(connectButton, BorderLayout.SOUTH);
testFrame.setContentPane(mainPanel);
testFrame.setSize(300, 100);
testFrame.setLocationRelativeTo(null);
testFrame.setVisible(true);
IKey key1 = new TangoKey();
IKey key2 = new TangoKey();
IKey key3 = new TangoKey();
TangoKeyTool.registerAttribute(key1, "tango/tangotest/1/state");
TangoKeyTool.registerAttribute(key2, "tango/tangotest/1/state");
TangoKeyTool.registerAttribute(key3, "tangotest1/state");