12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import java.awt.BorderLayout;
- import java.util.Observable;
- import java.util.Observer;
- import javax.swing.JComboBox;
- import javax.swing.JLabel;
- import javax.swing.JButton;
- import javax.swing.JSplitPane;
- import javax.swing.border.EmptyBorder;
- import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
- import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ProbabilityDistributionHandler;
- public class PortDistributionConfigurationPopUp extends JFrame implements Observer{
-
- private Port port;
-
- private JSplitPane splitPane;
-
- public PortDistributionConfigurationPopUp(Port port) {
- this.port = port;
- this.setSize(300, 500);
- splitPane = new JSplitPane();
- splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
- splitPane.setBorder(new EmptyBorder(0, 0, 0, 0));
- getContentPane().add(splitPane, BorderLayout.CENTER);
-
- JPanel panel = new JPanel();
- splitPane.setLeftComponent(panel);
- panel.setLayout(null);
-
- JLabel lblDescription = new JLabel("Distribution Type:");
- lblDescription.setBounds(10, 10, 120, 20);
- panel.add(lblDescription);
-
- JComboBox comboBox = new JComboBox();
- comboBox.setBounds(120, 10, 190, 20);
- panel.add(comboBox);
-
- JButton btnImport = new JButton("Import");
- btnImport.setBounds(320, 10, 100, 20);
- panel.add(btnImport);
- splitPane.setDividerLocation(40);
-
- update(null,null);
- }
- @Override
- public void update(Observable o, Object arg) {
- if(port == null)return;
- ProbabilityDistributionHandler handler = port.getTriggerHandler();
-
- if(handler!=null)
- splitPane.setRightComponent(handler.getConfigurationPanel());
- else
- splitPane.setRightComponent(null);
- }
- }
|