Example usage for javax.swing.event ListSelectionEvent getValueIsAdjusting

List of usage examples for javax.swing.event ListSelectionEvent getValueIsAdjusting

Introduction

In this page you can find the example usage for javax.swing.event ListSelectionEvent getValueIsAdjusting.

Prototype

public boolean getValueIsAdjusting() 

Source Link

Document

Returns whether or not this is one in a series of multiple events, where changes are still being made.

Usage

From source file:misc.TextBatchPrintingDemo.java

/**
 * Called when the print list selection state is changed.  This is the 
 * {@code ListSelectionListener} method.
 *///from  w w w .java  2  s . co m
public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {
        int index = ((JList) e.getSource()).getSelectedIndex();
        if (index >= 0) {
            // Load the currently selected URL into the page browser.
            PageItem item = (PageItem) selectedPages.getModel().getElementAt(index);
            URL page = item.getPage();
            if (!page.equals(pageItem.getPage())) {
                setPage(page);
            }
        }
    }
}

From source file:eu.europeana.sip.gui.SipCreatorGUI.java

private JComponent createList() {
    dataSetList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataSetList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override//from   ww  w. j a v  a2  s .  c om
        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting())
                return;
            int selected = dataSetList.getSelectedIndex();
            DataSetListModel.Entry selectedEntry = selected >= 0 ? dataSetListModel.getEntry(selected) : null;
            dataSetActions.setEntry(selectedEntry);
        }
    });
    dataSetList.setCellRenderer(new DataSetListModel.Cell());
    dataSetList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    dataSetList.setBackground(getBackground());
    JScrollPane scroll = new JScrollPane(dataSetList);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    return scroll;
}

From source file:com.floreantpos.ui.views.order.modifier.TicketItemModifierTableView.java

private void initComponents() {
    titledBorder.setTitle(modifierSelectionModel.getTicketItem().getName());
    titledBorder.setTitleJustification(TitledBorder.CENTER);
    setBorder(border);//ww  w  . j  a  v a  2s  .com
    setLayout(new java.awt.BorderLayout(5, 5));

    ticketItemActionPanel = new com.floreantpos.swing.TransparentPanel();
    //btnDecreaseAmount = new com.floreantpos.swing.PosButton();
    btnScrollDown = new com.floreantpos.swing.PosButton();
    modifierViewerTable = new com.floreantpos.ui.views.order.modifier.ModifierViewerTable(
            modifierSelectionModel.getTicketItem());
    ticketScrollPane = new PosScrollPane(modifierViewerTable);
    ticketScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    ticketScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    ticketScrollPane.setPreferredSize(new java.awt.Dimension(180, 200));

    createTicketActionPanel();
    createTicketItemControlPanel();

    JPanel centerPanel = new JPanel(new BorderLayout(5, 5));
    centerPanel.add(ticketScrollPane);

    centerPanel.add(createItemDescriptionPanel(), BorderLayout.NORTH);
    add(centerPanel);
    add(ticketActionPanel, BorderLayout.SOUTH);
    centerPanel.add(ticketItemActionPanel, BorderLayout.EAST);

    modifierViewerTable.getRenderer().setInTicketScreen(true);
    modifierViewerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                updateSelectionView();
            }
        }
    });

    modifierViewerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {

            Object selected = modifierViewerTable.getSelected();
            if (!(selected instanceof ITicketItem)) {
                return;
            }

            ITicketItem item = (ITicketItem) selected;

            Boolean printedToKitchen = item.isPrintedToKitchen();
            btnDelete.setEnabled(!printedToKitchen);
        }

    });

    setPreferredSize(new java.awt.Dimension(360, 463));

}

From source file:Main.java

public void valueChanged(ListSelectionEvent e) {
    if (e.getSource() == table.getSelectionModel() && table.getRowSelectionAllowed()) {
        int first = e.getFirstIndex();
        int last = e.getLastIndex();
    } else if (e.getSource() == table.getColumnModel().getSelectionModel()
            && table.getColumnSelectionAllowed()) {
        int first = e.getFirstIndex();
        int last = e.getLastIndex();
    }/*from  www . ja va 2  s .  c o  m*/
    if (e.getValueIsAdjusting()) {
        System.out.println("The mouse button has not yet been released");
    }
}

From source file:com.microsoft.alm.plugin.idea.ui.checkout.CheckoutPageModelImpl.java

private void setupSelectionListener() {
    // Set up event listener to set the Directory name when the selection changes
    repositoryTableModel.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override//ww w  .j av a  2s. c om
        public void valueChanged(ListSelectionEvent e) {
            // No need to change things while the list is adjusting
            if (!e.getValueIsAdjusting()) {
                final ServerContext row = repositoryTableModel.getSelectedContext();
                // Get the repository name and set the directory name to match
                final String repositoryName = (row != null && row.getGitRepository() != null)
                        ? row.getGitRepository().getName()
                        : "";
                setDirectoryName(repositoryName);
            }
        }
    });
}

From source file:com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutPageModelImpl.java

private void setupSelectionListener() {
    // Set up event listener to set the Directory name when the selection changes
    repositoryTableModel.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override// ww  w .  ja v a2 s.  c o m
        public void valueChanged(ListSelectionEvent e) {
            // No need to change things while the list is adjusting
            if (!e.getValueIsAdjusting()) {
                final ServerContext row = repositoryTableModel.getSelectedContext();
                // Get the repository name and set the directory name to match
                final String repositoryName = parentModel.getRepositoryName(row);
                setDirectoryName(repositoryName);
            }
        }
    });
}

From source file:com.funambol.email.admin.user.ResultSearchUserPanel.java

/**
 * Set up graphic elements for this panel.
 *
 * @throws Exception if error occures during creation of the panel
 *//*from ww w  . jav a2s.  c  o m*/
private void init() throws Exception {

    // create objects to display
    this.setLayout(new BorderLayout());
    this.setBorder(BorderFactory.createEmptyBorder());

    // create a model for the user table and pass it to the JTable object
    model = new UserTableModel();
    table = new JTable(model);

    table.setShowGrid(true);
    table.setAutoscrolls(true);
    table.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollpane = new JScrollPane(table);
    table.setPreferredScrollableViewportSize(new Dimension(800, 200));
    table.setFont(GuiFactory.defaultTableFont);
    table.getTableHeader().setFont(GuiFactory.defaultTableHeaderFont);
    this.add(scrollpane, BorderLayout.CENTER);

    //
    // Select user.
    //
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ListSelectionModel rowSM = table.getSelectionModel();

    rowSM.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {

            if (event.getValueIsAdjusting()) {
                return;
            }

            ListSelectionModel lsm = (ListSelectionModel) event.getSource();

            if (lsm.isSelectionEmpty()) {

                selectedUser = null;
            } else {

                int selectedRow = lsm.getMinSelectionIndex();
                selectedUser = users[selectedRow];
            }
        }
    });

    rowSM.clearSelection();

    table.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent event) {

            if (event.getClickCount() < 2) {
                return;
            }

            //
            // If the selected user is already associated to an account
            // then insertion process can't go on.
            //

            String userName = selectedUser.getUsername();
            String value[] = new String[] { userName };
            WhereClause wc = new WhereClause("username", value, WhereClause.OPT_EQ, true);
            MailServerAccount[] tmp = null;
            try {
                tmp = WSDao.getAccounts(wc);
            } catch (Exception e) {
            }

            if (tmp.length > 0) {

                StringBuilder sb = new StringBuilder("The user ");
                sb.append(userName).append(" is already associated to an account");
                Object[] options = { "OK" };
                JOptionPane.showOptionDialog(null, sb.toString(), "Warning", JOptionPane.OK_CANCEL_OPTION,
                        JOptionPane.WARNING_MESSAGE, null, options, options[0]);

            } else {
                //
                // Go to next step.
                //
                step.goToNextStep();
            }
        }
    });

}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterListEdtDlg.java

/**
 * /*from  w ww  .j  ava 2  s.  c o m*/
 */
private void hookFormatListSelectionListener() {
    if (formatListSelectionListener == null) {
        formatListSelectionListener = new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) {
                    return;
                }
                updateUIEnabled();
            }
        };
    }

    formatList.addListSelectionListener(formatListSelectionListener);
}

From source file:com.bwc.ora.views.LrpDisplayFrame.java

private LrpDisplayFrame() {
    //set up frame and chart
    //configure initial display setting for the panel
    chartPanel = new ChartPanel(null);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    this.setSize(800, 800);
    add(chartPanel, BorderLayout.CENTER);

    //make it so this jframe can't gain focus
    setFocusableWindowState(false);/*from w w w  .jav  a2 s .c o m*/

    //add listener to check to see which LRP should be displayed
    lrps.addListSelectionListener((ListSelectionEvent e) -> {
        if (!e.getValueIsAdjusting()) {
            if (lrps.getSelectedIndex() > -1) {
                setChart(lrps.getSelectedValue().getAllSeriesData());
                setVisible(true);
            } else {
                setVisible(false);
            }
        }
    });

    //add listener to check for updates to lrp selection to change lrp
    lrpSettings.addPropertyChangeListener(e -> {
        if (lrps.getSelectedIndex() > -1) {
            if (e.getPropertyName().equals(LrpSettings.PROP_LRP_WIDTH)) {
                Lrp newLrp;
                try {
                    newLrp = new Lrp(Collections.getInstance().getLrpCollection().getSelectedValue().getName(),
                            Collections.getInstance().getLrpCollection().getSelectedValue()
                                    .getLrpCenterXPosition(),
                            Collections.getInstance().getLrpCollection().getSelectedValue()
                                    .getLrpCenterYPosition(),
                            ModelsCollection.getInstance().getLrpSettings().getLrpWidth(),
                            ModelsCollection.getInstance().getLrpSettings().getLrpHeight(),
                            Collections.getInstance().getLrpCollection().getSelectedValue().getType());
                } catch (LRPBoundaryViolationException e1) {
                    JOptionPane.showMessageDialog(null, e1.getMessage() + " Try again.", "LRP generation error",
                            JOptionPane.ERROR_MESSAGE);
                    lrpSettings.setLrpWidth((int) e.getOldValue());
                    return;
                }
                Collections.getInstance().getLrpCollection().setLrp(newLrp,
                        Collections.getInstance().getLrpCollection().getSelectedIndex());
            } else {
                updateSeries(lrps.getSelectedValue().getAllSeriesData());
            }
        }
    });

    //add listener to check for updates to oct settings to change lrp
    octSettings.addPropertyChangeListener(e -> {
        if (lrps.getSelectedIndex() > -1) {
            switch (e.getPropertyName()) {
            case OctSettings.PROP_APPLY_CONTRAST_ADJUSTMENT:
            case OctSettings.PROP_APPLY_NOISE_REDUCTION:
            case OctSettings.PROP_DISPLAY_LOG_OCT:
            case OctSettings.PROP_SHARPEN_KERNEL_RADIUS:
            case OctSettings.PROP_SHARPEN_WEIGHT:
            case OctSettings.PROP_SMOOTHING_FACTOR:
                updateSeries(lrps.getSelectedValue().getAllSeriesData());
            default:
                break;
            }
        }
    });

    //add listener to see if the LRP display needs updating when a selection on oct changes
    lrps.addListDataChangeListener(new ListDataListener() {
        @Override
        public void intervalAdded(ListDataEvent e) {
        }

        @Override
        public void intervalRemoved(ListDataEvent e) {
        }

        @Override
        public void contentsChanged(ListDataEvent e) {
            clearAnnotations();
            updateSeries(lrps.getSelectedValue().getAllSeriesData());
        }
    });

    //add mouse listener for chart to detect when to display labels for
    //peaks in the pop-up menu, also specify what to do when label is clicked
    chartPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent cme) {
            ChartEntity entity = cme.getEntity();
            if (entity instanceof XYItemEntity && cme.getTrigger().getButton() == MouseEvent.BUTTON1) {

                XYItemEntity item = (XYItemEntity) entity;
                LabelPopupMenu labelMenu = new LabelPopupMenu(chartPanel, item, lrps.getSelectedValue());

                labelMenu.show(chartPanel, cme.getTrigger().getX(), cme.getTrigger().getY());
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            //do nothing
        }

    });
}

From source file:com.github.alexfalappa.nbspringboot.projects.customizer.CfgPropsDialog.java

/** Creates new form CfgPropsDialog */
public CfgPropsDialog(java.awt.Dialog parent) {
    super(parent, true);
    initComponents();/*from w  w w  .j av a2s. c o  m*/
    // retrieve some flads from prefs
    final Preferences prefs = NbPreferences.forModule(PrefConstants.class);
    final boolean bDeprLast = prefs.getBoolean(PREF_DEPR_SORT_LAST, true);
    bDeprErrorShow = prefs.getBoolean(PREF_DEPR_ERROR_SHOW, false);
    // setup props sorting
    this.sortedProps = new TreeSet<>(new ConfigurationMetadataComparator(bDeprLast));
    // setup property list
    lCfgProps.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                final ConfigurationMetadataProperty selectedValue = lCfgProps.getSelectedValue();
                if (selectedValue != null) {
                    tpDetails.setText(Utils.cfgPropDetailsHtml(selectedValue));
                    tpDetails.setCaretPosition(0);
                }
            }
        }
    });
    // set default button
    rootPane.setDefaultButton(bOk);
    // close dialog with ESC key
    final ActionListener escAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            CfgPropsDialog.this.setVisible(false);
        }
    };
    rootPane.registerKeyboardAction(escAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);
}