123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package ui.view;
- import javax.swing.JSplitPane;
- import javax.swing.JPanel;
- import javax.swing.BoxLayout;
- import javax.swing.JButton;
- import java.awt.Dimension;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import javax.swing.JToggleButton;
- import java.awt.Component;
- public class FlexSubData extends JSplitPane {
- public static final String HIDE = "Hide Objects";
- public static final String SHOW = "Show Objects";
- private JPanel subnetInfo;
- private JPanel objectInfo;
- private JPanel currentObj;
- private JButton btnShowObjects;
- private FlexiblePane listener;
- public FlexSubData(FlexibleData fD) {
- setDividerSize(0);
- setAlignmentY(Component.CENTER_ALIGNMENT);
- setAlignmentX(Component.CENTER_ALIGNMENT);
- setOrientation(JSplitPane.VERTICAL_SPLIT);
-
- //subnetInfo = new FlexibleData("test" , 0, 0);
- subnetInfo = fD;
- subnetInfo.setMinimumSize(new Dimension(600, 100));
- setLeftComponent(subnetInfo);
- subnetInfo.setLayout(null);
-
- btnShowObjects = new JButton(SHOW);
- btnShowObjects.setBounds(135, 13, 99, 23);
- btnShowObjects.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- if(btnShowObjects.getText() == SHOW){
- objectInfo.add(currentObj);
- objectInfo.revalidate();
- objectInfo.updateUI();
- listener.revalidate();
- btnShowObjects.setText(HIDE);
- }else if(btnShowObjects.getText() == HIDE){
- objectInfo.removeAll();
- objectInfo.revalidate();
- objectInfo.updateUI();
- listener.revalidate();
- btnShowObjects.setText(SHOW);
- }
- }
- });
- subnetInfo.add(btnShowObjects);
-
- objectInfo = new JPanel();
- setRightComponent(objectInfo);
- objectInfo.setLayout(new BoxLayout(objectInfo, BoxLayout.X_AXIS));
- }
-
- public void setObjects(JPanel obj){
- objectInfo.removeAll();
- currentObj = obj;
- }
-
- public void setListener(FlexiblePane fP){
- listener = fP;
- }
-
- public JPanel getSubInfo(){
- return subnetInfo;
- }
- }
|