1 package nl.tudelft.goal.ut2004.visualizer.panels.connection; 2 3 import java.awt.event.ActionEvent; 4 import java.awt.event.ActionListener; 5 import java.net.URI; 6 7 import javax.swing.JButton; 8 import javax.swing.JLabel; 9 import javax.swing.JPanel; 10 11 import cz.cuni.amis.utils.flag.Flag; 12 import cz.cuni.amis.utils.flag.FlagListener; 13 14 public class ConnectingPanel extends JPanel { 15 16 private final JLabel connectionStatus; 17 private final JButton disconnectButton; 18 19 public ConnectingPanel(Flag<URI> uriFlag, final IDisconnect disconnect) { 20 this.connectionStatus = new JLabel("Connecting to: " 21 + uriFlag.getFlag()); 22 this.disconnectButton = new JButton("Disconnect"); 23 24 add(connectionStatus); 25 add(disconnectButton); 26 27 uriFlag.addListener(new FlagListener<URI>() { 28 29 @Override 30 public void flagChanged(URI changedValue) { 31 connectionStatus.setText("Connecting to: " + changedValue); 32 } 33 }); 34 35 this.disconnectButton.addActionListener(new ActionListener() { 36 37 @Override 38 public void actionPerformed(ActionEvent arg0) { 39 disconnect.disconnect(); 40 41 } 42 }); 43 } 44 }