Example usage for javax.swing JSplitPane setResizeWeight

List of usage examples for javax.swing JSplitPane setResizeWeight

Introduction

In this page you can find the example usage for javax.swing JSplitPane setResizeWeight.

Prototype

@BeanProperty(description = "Specifies how to distribute extra space when the split pane resizes.")
public void setResizeWeight(double value) 

Source Link

Document

Specifies how to distribute extra space when the size of the split pane changes.

Usage

From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java

private StatView() {

    chartType = ChartType.PIE;/*from   w ww . j a v  a 2  s  .c  o m*/
    chartDataType = DataType.STATUS;
    FilterView.getInstance().addFilterUpdateListener(this);

    setLayout(new BorderLayout());
    final JPanel chart = new ChartPanel(StatView.createPieStatusChart());

    final JSplitPane mainPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chart, buildSidePanel());
    mainPane.setResizeWeight(0.40);
    add(mainPane);
}

From source file:com.offbynull.peernetic.debug.visualizer.JGraphXVisualizer.java

/**
 * Creates a {@link JGraphXVisualizer} object.
 *//*from  w w  w  .  j av  a 2  s.c om*/
public JGraphXVisualizer() {

    graph = new mxGraph();
    graph.setCellsEditable(false);
    graph.setAllowDanglingEdges(false);
    graph.setAllowLoops(false);
    graph.setCellsDeletable(false);
    graph.setCellsCloneable(false);
    graph.setCellsDisconnectable(false);
    graph.setDropEnabled(false);
    graph.setSplitEnabled(false);
    graph.setCellsBendable(false);
    graph.setConnectableEdges(false);
    graph.setCellsMovable(false);
    graph.setCellsResizable(false);
    graph.setAutoSizeCells(true);

    component = new mxGraphComponent(graph);
    component.setConnectable(false);

    component.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    component.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

    nodeLookupMap = new DualHashBidiMap<>();
    connToEdgeLookupMap = new MultiValueMap<>();
    edgeToConnLookupMap = new HashMap<>();
    vertexLingerTriggerMap = new HashMap<>();

    textOutputArea = new JTextArea();
    textOutputArea.setLineWrap(false);
    textOutputArea.setEditable(false);
    JScrollPane textOutputScrollPane = new JScrollPane(textOutputArea);
    textOutputScrollPane.setPreferredSize(new Dimension(0, 100));

    frame = new JFrame("Visualizer");
    frame.setSize(400, 400);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, component, textOutputScrollPane);
    splitPane.setResizeWeight(1.0);

    frame.setContentPane(splitPane);

    component.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            zoomFit();
        }
    });

    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            Recorder<A> rec = recorder.get();
            if (rec != null) {
                IOUtils.closeQuietly(rec);
            }

            VisualizerEventListener veListener = listener.get();
            if (veListener != null) {
                veListener.closed();
            }
        }
    });

    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    splitPane.setDividerLocation(0.2);
}

From source file:com.diversityarrays.dal.server.SqlDialog.java

SqlDialog(JFrame owner, SqlDalDatabase db) {
    super(owner, "SQL", ModalityType.MODELESS);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.database = db;

    runner = new DefaultBackgroundRunner("SQL Command", this);
    setGlassPane(runner.getBlockingPane());

    sqlCommands.setFont(GuiUtil.createMonospacedFont(12));

    includeHeadingsInCopy.addItemListener(new ItemListener() {
        @Override/*from   www .j  a va  2s  .  c  o  m*/
        public void itemStateChanged(ItemEvent e) {
            boolean b = includeHeadingsInCopy.isSelected();
            for (int n = tabbedPane.getTabCount(); --n >= 0;) {
                Component c = tabbedPane.getComponentAt(n);
                if (c instanceof SqlResultsPanel) {
                    ((SqlResultsPanel) c).setIncludeHeadings(b);
                }
            }
        }
    });

    tabbedPane.addContainerListener(new ContainerListener() {
        @Override
        public void componentRemoved(ContainerEvent e) {
            updateClosePanelAction();
        }

        @Override
        public void componentAdded(ContainerEvent e) {
            updateClosePanelAction();
        }
    });
    updateClosePanelAction();

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(runAction));
    buttons.add(Box.createHorizontalStrut(20));
    buttons.add(new JButton(closePanelAction));

    buttons.add(Box.createHorizontalGlue());
    buttons.add(includeHeadingsInCopy);
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(helpAction));
    buttons.add(Box.createHorizontalStrut(10));

    JPanel top = new JPanel(new BorderLayout());
    top.add(BorderLayout.CENTER, new JScrollPane(sqlCommands));
    top.add(BorderLayout.SOUTH, buttons);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, tabbedPane);
    splitPane.setResizeWeight(0.25);

    setContentPane(splitPane);

    pack();

    setSize(800, 600);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            splitPane.setDividerLocation(0.25);
            removeWindowListener(this);
        }

    });
}

From source file:com.orthancserver.SelectImageDialog.java

public SelectImageDialog() {
    tree_ = new JTree();

    tree_.addTreeWillExpandListener(new TreeWillExpandListener() {
        @Override/*w  ww  .  j a  va2  s .  c o  m*/
        public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
            TreePath path = event.getPath();
            if (path.getLastPathComponent() instanceof MyTreeNode) {
                MyTreeNode node = (MyTreeNode) path.getLastPathComponent();
                node.LoadChildren((DefaultTreeModel) tree_.getModel());
            }
        }

        @Override
        public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
        }
    });

    tree_.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = e.getNewLeadSelectionPath();
            if (path != null) {
                MyTreeNode node = (MyTreeNode) path.getLastPathComponent();
                if (node.UpdatePreview(preview_)) {
                    selectedType_ = node.GetResourceType();
                    selectedUuid_ = node.GetUuid();
                    selectedConnection_ = node.GetConnection();
                    okButton_.setEnabled(true);
                }

                removeServer_.setEnabled(node.GetResourceType() == ResourceType.SERVER);
            }
        }
    });

    tree_.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            TreePath path = tree_.getPathForLocation(e.getX(), e.getY());
            if (path != null) {
                MyTreeNode node = (MyTreeNode) path.getLastPathComponent();
                if (e.getClickCount() == 2 && node.GetResourceType() == ResourceType.INSTANCE) {
                    // Double click on an instance, close the dialog
                    isSuccess_ = true;
                    setVisible(false);
                }
            }
        }
    });

    final JPanel contentPanel = new JPanel();
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
        JSplitPane splitPane = new JSplitPane();
        splitPane.setResizeWeight(0.6);
        contentPanel.add(splitPane);

        splitPane.setLeftComponent(new JScrollPane(tree_));
        splitPane.setRightComponent(preview_);
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton btnAddServer = new JButton("Add server");
            btnAddServer.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    OrthancConfigurationDialog dd = new OrthancConfigurationDialog();
                    dd.setLocationRelativeTo(null); // Center dialog on screen

                    OrthancConnection orthanc = dd.ShowModal();
                    if (orthanc != null) {
                        AddOrthancServer(orthanc);
                        ((DefaultTreeModel) tree_.getModel()).reload();
                    }
                }
            });
            buttonPane.add(btnAddServer);
        }

        {
            buttonPane.add(removeServer_);
            removeServer_.setEnabled(false);

            removeServer_.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    MyTreeNode selected = (MyTreeNode) tree_.getLastSelectedPathComponent();
                    if (selected.GetResourceType() == ResourceType.SERVER && JOptionPane.showConfirmDialog(null,
                            "Remove server \"" + selected.getUserObject() + "\"?", "WARNING",
                            JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                        ((DefaultTreeModel) tree_.getModel()).removeNodeFromParent(selected);
                    }
                }
            });
        }

        {
            okButton_.setEnabled(false);
            okButton_.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    isSuccess_ = true;
                    setVisible(false);
                }
            });
            buttonPane.add(okButton_);
            getRootPane().setDefaultButton(okButton_);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    setVisible(false);
                }
            });
            buttonPane.add(cancelButton);
        }
    }

    setUndecorated(false);
    setSize(500, 500);
    setTitle("Select some series or some instance in Orthanc");
    setModal(true);
}

From source file:com.web.vehiclerouting.optaplanner.common.swingui.SolverAndPersistenceFrame.java

private JComponent createQuickOpenPanel() {
    JSplitPane quickOpenSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createQuickOpenUnsolvedPanel(),
            createQuickOpenSolvedPanel());
    quickOpenSplitPane.setResizeWeight(0.8);
    return quickOpenSplitPane;
}

From source file:ec.ui.view.RevisionSaSeriesView.java

/**
 * Constructs a new view// w  w w. ja va  2  s. c  o  m
 */
public RevisionSaSeriesView() {
    setLayout(new BorderLayout());

    sRenderer = new XYLineAndShapeRenderer();
    sRenderer.setBaseShapesVisible(false);
    //sRenderer.setSeriesStroke(1, new BasicStroke(0.75f, 1, 1, 1.0f, new float[]{2f, 3f}, 0.0f));
    sRenderer.setBasePaint(themeSupport.getLineColor(ColorScheme.KnownColor.RED));

    revRenderer = new XYLineAndShapeRenderer(false, true);

    mainChart = createMainChart();

    chartpanel_ = new JChartPanel(ChartFactory.createLineChart(null, null, null, null, PlotOrientation.VERTICAL,
            false, false, false));

    documentpanel_ = ComponentFactory.getDefault().newHtmlView();

    JSplitPane splitpane = NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, chartpanel_,
            NbComponents.newJScrollPane(documentpanel_));
    splitpane.setDividerLocation(0.5);
    splitpane.setResizeWeight(.5);

    popup = new ChartPopup(null, false);

    chartpanel_.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent e) {
            if (lastIndexSelected != -1) {
                revRenderer.setSeriesShapesFilled(lastIndexSelected, false);
            }
            if (e.getEntity() != null) {
                if (e.getEntity() instanceof XYItemEntity) {
                    XYItemEntity item = (XYItemEntity) e.getEntity();
                    if (item.getDataset().equals(mainChart.getXYPlot().getDataset(REV_INDEX))) {
                        int i = item.getSeriesIndex();

                        revRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6));
                        revRenderer.setSeriesShapesFilled(i, true);
                        revRenderer.setSeriesPaint(i, themeSupport.getLineColor(ColorScheme.KnownColor.BLUE));

                        lastIndexSelected = i;

                        showRevisionPopup(e);
                    }
                }
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
        }
    });

    chartpanel_.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(JChartPanel.ZOOM_SELECTION_CHANGED)) {
                showSelectionPopup((Rectangle2D) evt.getNewValue());
            }
        }
    });

    this.add(splitpane, BorderLayout.CENTER);
    splitpane.setResizeWeight(0.5);

    onColorSchemeChange();
}

From source file:fedroot.dacs.swingdemo.DacsClientFrame.java

/**
 * //from  ww  w  . java 2s  .com
 * @param dacsClientContext
 * @param feduri 
 * @throws java.lang.Exception 
 */
public DacsClientFrame(DacsClientContext dacsClientContext, Federation federation) throws Exception {
    logger.log(Level.INFO, "Federation {0}", federation.getFederationName());

    this.federation = federation;
    this.dacsClientContext = dacsClientContext;
    //        this.dacsClientContext.setDacs902EventHandler(federation, new Event902Handler(this));
    //        this.dacsClientContext.setDacs905EventHandler(federation, new Event905Handler(this));

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel gotoUrlPanel = new JPanel(new FlowLayout());
    JPanel actionPanel = new JPanel(new FlowLayout());
    JPanel modifiersPanel = new JPanel(new FlowLayout());

    /** Enable/Disable DACS Check_only mode */
    checkOnlyCheckBox = new JCheckBox("Enable DACS Check Only", false);
    checkOnlyCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            if (checkOnlyCheckBox.isSelected()) {
                enableEventHandlingCheckBox.setSelected(false);
                enableEventHandlingCheckBox.setEnabled(false);
            } else {
                enableEventHandlingCheckBox.setEnabled(true);
            }
        }
    });

    /** Enable/Disable Event Handling */
    enableEventHandlingCheckBox = new JCheckBox("Enable Event Handling", false);

    final JButton btnGOTO = new JButton("Goto URL");
    btnGOTO.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            try {
                followUrl(new URI(urlTextField.getText().trim()));
            } catch (URISyntaxException ex) {
                // TODO implement popup for error messages
            }
        }
    });

    final JButton btnGO = new JButton("GO");
    btnGO.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            try {
                followUrl(new URI(actionUrls[actionsComboBox.getSelectedIndex()]));
            } catch (URISyntaxException ex) {
                // TODO implement popup for error messages
            }
        }
    });

    final JButton btnUSERNAMES = new JButton("Usernames");
    btnUSERNAMES.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowDacsUsernameFrame();
        }
    });

    final JButton btnLOGIN = new JButton("Login");
    btnLOGIN.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowLoginFrame();
        }
    });

    final JButton btnNAT = new JButton("NATs");
    btnNAT.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowDacsNatFrame();
        }
    });

    Container container = this.getContentPane();

    actionsComboBox = new JComboBox(actions);
    actionsComboBox.setToolTipText("Select an Action");
    actionsComboBox.setEditable(true);
    actionsComboBox.setSelectedIndex(0);

    JLabel actionLabel = new JLabel("Action:");

    urlTextField = new TextField(70);
    urlTextField.setEditable(true);

    gotoUrlPanel.add(urlTextField);
    gotoUrlPanel.add(btnGOTO);

    actionPanel.add(actionLabel);
    actionPanel.add(actionsComboBox);
    actionPanel.add(btnGO);
    actionPanel.add(btnLOGIN);
    actionPanel.add(btnUSERNAMES);
    actionPanel.add(btnNAT);

    mainPanel.add(gotoUrlPanel, BorderLayout.NORTH);
    mainPanel.add(actionPanel, BorderLayout.SOUTH);

    modifiersPanel.add(checkOnlyCheckBox);
    modifiersPanel.add(enableEventHandlingCheckBox);

    JSplitPane splitInputPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPanel, modifiersPanel);

    splitInputPane.setOneTouchExpandable(false);

    responseTextArea = new JTextArea();
    responseTextArea.setEditable(false);
    responseTextArea.setCaretPosition(0);

    htmlPane = new JEditorPane();
    // htmlPane.setContentType("image/png");
    htmlPane.setEditable(false);

    JSplitPane splitResponsePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(responseTextArea),
            new JScrollPane(htmlPane));
    splitResponsePane.setOneTouchExpandable(false);
    splitResponsePane.setResizeWeight(0.35);

    container.setLayout(new BorderLayout());
    container.add(splitInputPane, BorderLayout.NORTH);
    container.add(splitResponsePane, BorderLayout.CENTER);
}

From source file:fedroot.dacs.swingdemo.DemoFrame.java

/**
 * // w w w  .j a v a  2 s . c  o  m
 * @param dacsClientContext
 * @param feduri 
 * @throws java.lang.Exception 
 */
public DemoFrame(DacsClientContext dacsClientContext, Federation federation) throws Exception {
    logger.log(Level.INFO, "Federation {0}", federation.getFederationName());

    this.federation = federation;
    this.dacsClientContext = dacsClientContext;
    //        this.dacsClientContext.setDacs902EventHandler(federation, new Event902Handler(this));
    //        this.dacsClientContext.setDacs905EventHandler(federation, new Event905Handler(this));

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel gotoUrlPanel = new JPanel(new FlowLayout());
    JPanel actionPanel = new JPanel(new FlowLayout());
    JPanel modifiersPanel = new JPanel(new FlowLayout());

    /** Enable/Disable DACS Check_only mode */
    checkOnlyCheckBox = new JCheckBox("Enable DACS Check Only", false);
    checkOnlyCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            if (checkOnlyCheckBox.isSelected()) {
                enableEventHandlingCheckBox.setSelected(false);
                enableEventHandlingCheckBox.setEnabled(false);
            } else {
                enableEventHandlingCheckBox.setEnabled(true);
            }
        }
    });

    /** Enable/Disable Event Handling */
    enableEventHandlingCheckBox = new JCheckBox("Enable Event Handling", false);

    final JButton btnGOTO = new JButton("Goto URL");
    btnGOTO.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            try {
                followUrl(new URI(urlTextField.getText().trim()));
            } catch (URISyntaxException ex) {
                // TODO implement popup for error messages
            }
        }
    });

    final JButton btnGO = new JButton("GO");
    btnGO.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            try {
                followUrl(new URI(actionUrls[actionsComboBox.getSelectedIndex()]));
            } catch (URISyntaxException ex) {
                // TODO implement popup for error messages
            }
        }
    });

    final JButton btnUSERNAMES = new JButton("Usernames");
    btnUSERNAMES.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowDacsUsernameFrame();
        }
    });

    final JButton btnLOGIN = new JButton("Login");
    btnLOGIN.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowLoginFrame();
        }
    });

    final JButton btnNAT = new JButton("NATs");
    btnNAT.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowDacsNatFrame();
        }
    });

    Container container = this.getContentPane();

    actionsComboBox = new JComboBox(actions);
    actionsComboBox.setToolTipText("Select an Action");
    actionsComboBox.setEditable(true);
    actionsComboBox.setSelectedIndex(0);

    JLabel actionLabel = new JLabel("Action:");

    urlTextField = new TextField(70);
    urlTextField.setEditable(true);

    gotoUrlPanel.add(urlTextField);
    gotoUrlPanel.add(btnGOTO);

    actionPanel.add(actionLabel);
    actionPanel.add(actionsComboBox);
    actionPanel.add(btnGO);
    actionPanel.add(btnLOGIN);
    actionPanel.add(btnUSERNAMES);
    actionPanel.add(btnNAT);

    mainPanel.add(gotoUrlPanel, BorderLayout.NORTH);
    mainPanel.add(actionPanel, BorderLayout.SOUTH);

    modifiersPanel.add(checkOnlyCheckBox);
    modifiersPanel.add(enableEventHandlingCheckBox);

    JSplitPane splitInputPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPanel, modifiersPanel);

    splitInputPane.setOneTouchExpandable(false);

    responseTextArea = new JTextArea();
    responseTextArea.setEditable(false);
    responseTextArea.setCaretPosition(0);

    htmlPane = new JEditorPane();
    // htmlPane.setContentType("image/png");
    htmlPane.setEditable(false);

    JSplitPane splitResponsePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(responseTextArea),
            new JScrollPane(htmlPane));
    splitResponsePane.setOneTouchExpandable(false);
    splitResponsePane.setResizeWeight(0.35);

    container.setLayout(new BorderLayout());
    container.add(splitInputPane, BorderLayout.NORTH);
    container.add(splitResponsePane, BorderLayout.CENTER);
}

From source file:model.DrawTopologyDiagram.java

@Override
public void init() {

    //create a graph
    Graph<VertexTopology, Number> ig = Graphs.<VertexTopology, Number>synchronizedDirectedGraph(
            new DirectedSparseMultigraph<VertexTopology, Number>());

    ObservableGraph<VertexTopology, Number> og = new ObservableGraph<VertexTopology, Number>(ig);
    og.addGraphEventListener(new GraphEventListener<VertexTopology, Number>() {

        public void handleGraphEvent(GraphEvent<VertexTopology, Number> evt) {
            System.err.println("got " + evt);

        }//from   w  w w  . jav  a  2  s.  com
    });
    this.g = og;
    //layouts
    //create a graphdraw
    //        layout = new FRLayout2<String,Number>(g);
    //        layout = new SpringLayout<String,Number>(g);
    //        ((FRLayout)layout).setMaxIterations(200);
    layout = new KKLayout<VertexTopology, Number>(g);

    vv = new VisualizationViewer<VertexTopology, Number>(layout, new Dimension(600, 600));

    createGraph();

    Container content = getContentPane();
    JPanel totalCasesPanel = new JPanel();

    final JPanel scaleGrids = new JPanel(new GridLayout(0, 2));
    scaleGrids.add(new JLabel("   Test Cases      "));
    scaleGrids.add(new JLabel("       "));
    totalCasesPanel.add(scaleGrids);

    JPanel filteredCasesPanel = new JPanel();

    final JPanel filteredGrids = new JPanel(new GridLayout(0, 2));
    filteredGrids.add(new JLabel("   Filtered Cases      "));
    filteredGrids.add(new JLabel("       "));
    filteredCasesPanel.add(filteredGrids);

    JRootPane rp = this.getRootPane();
    rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

    content.setLayout(new BorderLayout());
    content.setBackground(java.awt.Color.lightGray);
    content.setFont(new Font("Serif", Font.PLAIN, 12));

    vv.getModel().getRelaxer().setSleepTime(500);
    vv.setGraphMouse(new DefaultModalGraphMouse<VertexTopology, Number>());

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    vv.setForeground(Color.white);

    FontMetrics fm = vv.getFontMetrics(vv.getFont());
    int width = fm.stringWidth(g.toString());

    Transformer<VertexTopology, Shape> vertexSize = new Transformer<VertexTopology, Shape>() {
        public Shape transform(VertexTopology i) {

            Ellipse2D circle = new Ellipse2D.Double(-20, -20, 40, 40);
            // in this case, the vertex is twice as large                
            return circle;
        }

    };

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller() {
        @Override
        public String transform(Object v) {

            return ((VertexTopology) v).getScreenName();
        }
    });

    vv.getRenderContext().setVertexShapeTransformer(vertexSize);

    //Get picked states
    final PickedState<VertexTopology> pickedState = vv.getPickedVertexState();
    pickedState.addItemListener(new ItemListener() {
        ArrayList<TestCase> outputTestCase = new ArrayList<TestCase>();
        final Map<String, JButton> createdBtns = new HashMap<String, JButton>();

        Map<String, Integer> deviceSelected = new HashMap<String, Integer>(); // not useful

        ArrayList<String> endPointList = new ArrayList<String>();

        @Override
        public void itemStateChanged(ItemEvent e) {
            // TODO Auto-generated method stub
            Object subject = e.getItem();
            if (e.getStateChange() != 1) {
                scaleGrids.removeAll();
                filteredGrids.removeAll();
                endPointList.remove(getScreenName(subject));

                outputTestCase.clear();

                filteredGrids.repaint();
                filteredGrids.add(new JLabel("   Filtered Cases      "));
                filteredGrids.add(new JLabel("       "));

                scaleGrids.repaint();
                scaleGrids.add(new JLabel("   Test Cases      "));
                scaleGrids.add(new JLabel("       "));

                deviceSelected.clear();

            }
            if (e.getStateChange() == 1) {

                for (TestCase testCase : outputTestCase) {
                    scaleGrids.removeAll();
                    scaleGrids.add(new JLabel("   Test Cases      "));
                    scaleGrids.add(new JLabel("       "));

                    filteredGrids.removeAll();
                    filteredGrids.add(new JLabel("   Filtered Cases      "));
                    filteredGrids.add(new JLabel("       "));

                }

                if (subject instanceof VertexTopology) {
                    final VertexTopology edgePicked = (VertexTopology) subject;
                    if (pickedState.isPicked(edgePicked)) {

                        for (TestCase testCase : edgePicked.getTestCaseList()) {
                            if (!outputTestCase.contains(testCase))
                                outputTestCase.add(testCase);
                            System.out.println("The size for reference is " + testCase.inputReferenceMap.size()
                                    + testCase.getName());
                            System.out.println("The size for target is " + testCase.inputTargetMap.size()
                                    + testCase.getName());
                        }

                        if (deviceSelected.get(edgePicked.getScreenName()) != null)
                            deviceSelected.put(edgePicked.getScreenName(),
                                    deviceSelected.get(edgePicked.getScreenName()) + 1);
                        else
                            deviceSelected.put(edgePicked.getScreenName(), 1);

                        endPointList.add(edgePicked.getScreenName());

                    }
                }
            }

            for (TestCase testCase : outputTestCase) {
                JButton btnCase = new JButton(testCase.getName());
                scaleGrids.add(btnCase);

                if (testCase.getInputDeviceList().size() <= endPointList.size())
                    if (testCaseSelected(testCase, endPointList)) {
                        JButton btnCaseFiltered = new JButton(testCase.getName());
                        filteredGrids.add(btnCaseFiltered);
                    }
                ;

            }

            scaleGrids.revalidate();
            scaleGrids.setVisible(true);
        }

    });

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    vv.setGraphMouse(graphMouse);
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);

    content.setPreferredSize(new Dimension(1400, 900));
    content.add(vv);
    switchLayout = new JButton("Switch to SpringLayout");
    //        switchLayout.addActionListener(new ActionListener() {
    //
    //            @SuppressWarnings("unchecked")
    //            public void actionPerformed(ActionEvent ae) {
    //               Dimension d = new Dimension(600,600);
    //                if (switchLayout.getText().indexOf("Spring") > 0) {
    //                    switchLayout.setText("Switch to FRLayout");
    //                    layout = new SpringLayout<String,Number>(g,
    //                        new ConstantTransformer(EDGE_LENGTH));
    //                    layout.setSize(d);
    //                    vv.getModel().setGraphLayout(layout, d);
    //                } else {
    //                    switchLayout.setText("Switch to SpringLayout");
    //                    layout = new FRLayout<String,Number>(g, d);
    //                    vv.getModel().setGraphLayout(layout, d);
    //                }
    //            }
    //        });

    JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, totalCasesPanel, filteredCasesPanel);
    jSplitPane.setResizeWeight(.5d);

    content.add(switchLayout, BorderLayout.SOUTH);
    content.add(jSplitPane, BorderLayout.EAST);
}

From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java

private JComponent createContentPane() {
    JComponent quickOpenPanel = createQuickOpenPanel();
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(createToolBar(), BorderLayout.NORTH);
    mainPanel.add(createMiddlePanel(), BorderLayout.CENTER);
    mainPanel.add(createScorePanel(), BorderLayout.SOUTH);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, quickOpenPanel, mainPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.2);
    return splitPane;
}