edu.cmu.tetradapp.ui.DualListPanel Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2017 University of Pittsburgh.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package edu.cmu.tetradapp.ui;
import edu.cmu.tetrad.graph.Node;
import javax.swing.*;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.*;
/**
* Nov 21, 2017 2:13:40 PM
*
* @author Kevin V. Bui ([email protected])
* @version $Id: $Id
*/
@SuppressWarnings("ALL")
public class DualListPanel extends JPanel {
private static final long serialVersionUID = -5301381955599984479L;
/**
* The panel for the buttons.
*/
private JPanel buttonPanel;
/**
* The panel for the buttons parents.
*/
private JPanel buttonParentPanel;
/**
* The button to move to source.
*/
private JButton moveToSource;
/**
* The button to move to selector.
*/
private JButton moveToselector;
/**
* The list of selected nodes.
*/
private JList selectedList;
/**
* The scroll pane for the selected list.
*/
private JScrollPane selectedScrollPane;
/**
* The list of source nodes.
*/
private JList sourceList;
/**
* The scroll pane for the source list.
*/
private JScrollPane unselectedScrollPane;
/**
* Constructor for DualListPanel.
*/
public DualListPanel() {
initComponents();
}
private void initComponents() {
GridBagConstraints gridBagConstraints;
this.sourceList = new JList<>();
this.selectedList = new JList<>();
this.unselectedScrollPane = new JScrollPane(this.sourceList);
this.selectedScrollPane = new JScrollPane(this.selectedList);
this.buttonParentPanel = new JPanel();
this.buttonPanel = new JPanel();
this.moveToselector = new JButton();
this.moveToSource = new JButton();
setOpaque(false);
this.unselectedScrollPane.setBorder(BorderFactory.createTitledBorder("Not selected"));
this.unselectedScrollPane.setViewportView(this.sourceList);
this.selectedScrollPane.setBorder(BorderFactory.createTitledBorder("Selected"));
this.selectedScrollPane.setViewportView(this.selectedList);
this.buttonParentPanel.setOpaque(false);
this.buttonParentPanel.setLayout(new GridBagLayout());
this.buttonPanel.setOpaque(false);
this.moveToselector.setText(">");
this.moveToselector.setMaximumSize(new Dimension(64, 25));
this.moveToselector.setMinimumSize(new Dimension(64, 25));
this.moveToselector.setPreferredSize(new Dimension(64, 25));
this.moveToSource.setText("<");
this.moveToSource.setMaximumSize(new Dimension(64, 25));
this.moveToSource.setMinimumSize(new Dimension(64, 25));
this.moveToSource.setPreferredSize(new Dimension(64, 25));
GroupLayout buttonPanelLayout = new GroupLayout(this.buttonPanel);
this.buttonPanel.setLayout(buttonPanelLayout);
buttonPanelLayout.setHorizontalGroup(
buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(buttonPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(moveToselector, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(moveToSource, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
buttonPanelLayout.setVerticalGroup(
buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(buttonPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(moveToselector, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(moveToSource, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = GridBagConstraints.BOTH;
buttonParentPanel.add(buttonPanel, gridBagConstraints);
GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(unselectedScrollPane, GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(buttonParentPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(selectedScrollPane, GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(this.unselectedScrollPane)
.addComponent(this.buttonParentPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(this.selectedScrollPane, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
);
this.unselectedScrollPane.getAccessibleContext().setAccessibleName("Unselected");
this.unselectedScrollPane.getAccessibleContext().setAccessibleDescription("");
}
/**
* Getter for the field moveToSource
.
*
* @return a {@link javax.swing.JButton} object
*/
public JButton getMoveToSource() {
return this.moveToSource;
}
/**
* Getter for the field moveToselector
.
*
* @return a {@link javax.swing.JButton} object
*/
public JButton getMoveToselector() {
return this.moveToselector;
}
/**
* Getter for the field selectedList
.
*
* @return a {@link javax.swing.JList} object
*/
public JList getSelectedList() {
return this.selectedList;
}
/**
* Getter for the field selectedScrollPane
.
*
* @return a {@link javax.swing.JScrollPane} object
*/
public JScrollPane getSelectedScrollPane() {
return this.selectedScrollPane;
}
/**
* Getter for the field sourceList
.
*
* @return a {@link javax.swing.JList} object
*/
public JList getSourceList() {
return this.sourceList;
}
/**
* Getter for the field unselectedScrollPane
.
*
* @return a {@link javax.swing.JScrollPane} object
*/
public JScrollPane getUnselectedScrollPane() {
return this.unselectedScrollPane;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy