use of javax.swing.event.ChangeEvent in project android by JetBrains.
the class ColumnTreeBuilder method build.
public JComponent build() {
// Stash this value since it'll get stomped WideSelectionTreeUI.
boolean showsRootHandles = myTree.getShowsRootHandles();
myTree.setUI(new ColumnTreeUI());
myTree.setShowsRootHandles(showsRootHandles);
myTree.setCellRenderer(myCellRenderer);
myTable.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
@Override
public void columnAdded(TableColumnModelEvent tableColumnModelEvent) {
}
@Override
public void columnRemoved(TableColumnModelEvent tableColumnModelEvent) {
}
@Override
public void columnMoved(TableColumnModelEvent tableColumnModelEvent) {
}
@Override
public void columnMarginChanged(ChangeEvent changeEvent) {
myTree.revalidate();
myTree.repaint();
}
@Override
public void columnSelectionChanged(ListSelectionEvent listSelectionEvent) {
}
});
myTable.setRowSorter(myRowSorter);
myRowSorter.addRowSorterListener(event -> {
if (myTreeSorter != null && !myRowSorter.getSortKeys().isEmpty()) {
RowSorter.SortKey key = myRowSorter.getSortKeys().get(0);
Comparator<?> comparator = myRowSorter.getComparator(key.getColumn());
Enumeration<TreePath> expanded = myTree.getExpandedDescendants(new TreePath(myTree.getModel().getRoot()));
comparator = key.getSortOrder() == SortOrder.ASCENDING ? comparator : Collections.reverseOrder(comparator);
myTreeSorter.sort(comparator, key.getSortOrder());
if (expanded != null) {
while (expanded.hasMoreElements()) {
myTree.expandPath(expanded.nextElement());
}
}
}
});
myTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
for (ColumnBuilder column : myColumnBuilders) {
column.create(myTableModel);
}
for (int i = 0; i < myColumnBuilders.size(); i++) {
ColumnBuilder column = myColumnBuilders.get(i);
column.configure(i, myTable, myRowSorter, myCellRenderer);
}
JPanel panel = new TreeWrapperPanel(myTable, myTree);
if (myBackground != null) {
panel.setBackground(myBackground);
}
JTableHeader header = myTable.getTableHeader();
header.setReorderingAllowed(false);
JViewport viewport = new JViewport();
viewport.setView(header);
JBScrollPane scrollPane = new JBScrollPane(panel);
scrollPane.setColumnHeader(viewport);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
return scrollPane;
}
use of javax.swing.event.ChangeEvent in project libresonic by Libresonic.
the class PlayerTest method createGUI.
private void createGUI() {
JFrame frame = new JFrame();
JButton startButton = new JButton("Start");
JButton stopButton = new JButton("Stop");
JButton resetButton = new JButton("Reset");
final JSlider gainSlider = new JSlider(0, 1000);
startButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createPlayer();
player.play();
}
});
stopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
player.pause();
}
});
resetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
player.close();
createPlayer();
}
});
gainSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
float gain = (float) gainSlider.getValue() / 1000.0F;
player.setGain(gain);
}
});
frame.setLayout(new FlowLayout());
frame.add(startButton);
frame.add(stopButton);
frame.add(resetButton);
frame.add(gainSlider);
frame.pack();
frame.setVisible(true);
}
use of javax.swing.event.ChangeEvent in project processdash by dtuma.
the class GroupFilterMenu method setSelectedItem.
public void setSelectedItem(UserFilter selection) {
if (selection instanceof UserGroup) {
UserGroup g = (UserGroup) selection;
setIcon(groupIcon);
setText(g.toString());
} else if (selection instanceof UserGroupMember) {
UserGroupMember m = (UserGroupMember) selection;
setIcon(personIcon);
setText(m.toString());
}
boolean isChange = !NullSafeObjectUtils.EQ(selectedItem, selection);
this.selectedItem = selection;
if (isChange) {
for (ChangeListener l : listeners.getListeners(ChangeListener.class)) l.stateChanged(new ChangeEvent(this));
}
}
use of javax.swing.event.ChangeEvent in project n2a by frothga.
the class ParameterSpecGroupPanel method addParam.
public ParameterSpecPanel addParam(ParameterBundle bundle, ParameterSpecification useThisSpec) {
ParameterSpecification spec;
GroupType type = (GroupType) cboGroupType.getSelectedItem();
Object defaultValue = bundle.getParameter().getDefaultValue();
if (useThisSpec == null) {
spec = chooseDefaultSpecification(type, defaultValue);
} else {
spec = useThisSpec;
}
final ParameterSpecPanel pnlSpec = new ParameterSpecPanel(bundle, spec, readOnly);
pnlSpec.addRemoveListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
pnlParams.remove(specPanels.get(pnlSpec));
specPanels.remove(pnlSpec);
pnlParams.updateUI();
fireChangeNotifier();
}
});
pnlSpec.addEditListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
ParameterSpecification spec = pnlSpec.getSpecification();
GroupType type = (GroupType) cboGroupType.getSelectedItem();
switch(type) {
case LATIN_HYPERCUBE:
if (!(spec instanceof EvenSpacingParameterSpecification)) {
cboGroupType.setSelectedItem(GroupType.MIXED);
}
break;
case MONTE_CARLO:
if (!(spec instanceof EvenSpacingParameterSpecification)) {
cboGroupType.setSelectedItem(GroupType.MIXED);
}
break;
}
fireChangeNotifier();
}
});
JPanel cont = Lay.p(pnlSpec, "eb=10t,opaque=false");
specPanels.put(pnlSpec, cont);
pnlParams.add(cont);
updateUI();
fireChangeNotifier();
return pnlSpec;
}
use of javax.swing.event.ChangeEvent in project cayenne by apache.
the class ObjEntityTabbedView method initController.
private void initController() {
projectController.addObjEntityDisplayListener(this);
projectController.addObjAttributeDisplayListener(this);
projectController.addObjRelationshipDisplayListener(this);
addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
resetRemoveButtons();
projectController.setEntityTabSelection(getSelectedIndex());
Component selected = getSelectedComponent();
while (selected instanceof JScrollPane) {
selected = ((JScrollPane) selected).getViewport().getView();
}
if (selected instanceof ExistingSelectionProcessor) {
((ExistingSelectionProcessor) selected).processExistingSelection(e);
}
}
});
}
Aggregations