Package java.awt.event

Examples of java.awt.event.ItemEvent


            // Send ChangeEvent
            fireStateChanged();

            // Send ItemEvent
            fireItemStateChanged(new ItemEvent(this,
                    ItemEvent.ITEM_STATE_CHANGED,
                    this,
                    this.isSelected() ? ItemEvent.SELECTED : ItemEvent.DESELECTED));

        }
View Full Code Here


    public void handleEvent(AWTEvent e)
    {
        if (e instanceof ItemEvent)
        {
            Choice c = (Choice) e.getSource();
            ItemEvent itemEvent = (ItemEvent) e;
            Object clicked = itemEvent.getItem();
            int index = 0;
            for (int i = 0; i < c.getItemCount(); i++)
            {
                if (c.getItem(i) == clicked)
                {
View Full Code Here

                    selectionStr[i] = String.valueOf(selections[i]);
                }
                postEvent(l, selectionStr, true);
            } else
            {
                ItemEvent itemEvent = (ItemEvent) e;
                Integer clicked = (Integer) itemEvent.getItem();
                postEvent(l, String.valueOf(clicked), true);
            }
        }
    }
View Full Code Here

                //because the user could do several selection/deselection
                //before submiting the changes, there's no way to keep track
                //of the order
                if (event == -1)
                {
                    postEvent(context, new ItemEvent(l, ItemEvent.ITEM_STATE_CHANGED, l, ItemEvent.DESELECTED));
                } else if (event == 1)
                {
                    postEvent(context, new ItemEvent(l, ItemEvent.ITEM_STATE_CHANGED, l, ItemEvent.SELECTED));
                }
            } catch (NumberFormatException e)
            {
                throw new InputException("Choice input value is not an integer", e);
            }
View Full Code Here

                Choice choice = (Choice) peer.getComponentObject();
                if (choice.getSelectedIndex() != i)
                {
                    _logger.finest("item changes detected on component " + choice);
                    choice.select(i);
                    postEvent(context, new ItemEvent(choice, ItemEvent.ITEM_STATE_CHANGED, choice, ItemEvent.SELECTED));
                }
            } catch (NumberFormatException e)
            {
                _logger.warning("Choice input value is not an integer");
            }
View Full Code Here

        //the checking
        if (hasEvent(peer, inputForm))
        {
            Checkbox cbox = (Checkbox) peer.getComponent();
            cbox.setState(!cbox.getState()); //toggle the checkbox
            postEvent(context, new ItemEvent(cbox, ItemEvent.ITEM_STATE_CHANGED, cbox, cbox.getState()
                    ? ItemEvent.SELECTED
                    : ItemEvent.DESELECTED));
        } else if (hasGroupEvent(peer, inputForm))
        {
            Checkbox cbox = (Checkbox) peer.getComponentObject();
            CheckboxGroup grp = cbox.getCheckboxGroup();
            /*
             * should not need to fire unselection Checkbox selected = grp.getSelectedCheckbox(); context.getEventQueue().postEvent(
             * new ItemEvent(selected, ItemEvent.ITEM_STATE_CHANGED, selected, ItemEvent.DESELECTED));
             */
            grp.setSelectedCheckbox(cbox);
            postEvent(context, new ItemEvent(cbox, ItemEvent.ITEM_STATE_CHANGED, cbox, ItemEvent.SELECTED));
        }
    }
View Full Code Here

        {
            _logger.finest("Input for " + peer);
            CheckboxMenuItem item = (CheckboxMenuItem) peer.getComponentObject();
            item.setState(!item.getState());
            postEvent(context, new ActionEvent(item, ActionEvent.ACTION_PERFORMED, item.getActionCommand()));
            postEvent(context, new ItemEvent(item, ItemEvent.ITEM_STATE_CHANGED, item, (item.getState()
                    ? ItemEvent.SELECTED
                    : ItemEvent.DESELECTED)));
        } else
        {
            _logger.finest("No input for " + peer);
View Full Code Here

        ItemController l = new ItemController();
        comboBox.addItemListener(l);
        assertEquals(1, comboBox.getItemListeners().length);
        comboBox.addItemListener(new ItemController());
        assertEquals(2, comboBox.getItemListeners().length);
        comboBox.fireItemStateChanged(new ItemEvent(comboBox, ItemEvent.ITEM_STATE_CHANGED,
                "a", ItemEvent.SELECTED));
        assertEquals(1, l.getEvents().size());
        assertEquals(comboBox, l.getEvents().get(0).getSource());
        comboBox.removeItemListener(l);
        assertEquals(1, comboBox.getItemListeners().length);
View Full Code Here

        ItemController l = new ItemController();
        comboBox.addItemListener(l);
        assertEquals(1, comboBox.getItemListeners().length);
        comboBox.addItemListener(new ItemController());
        assertEquals(2, comboBox.getItemListeners().length);
        comboBox.fireItemStateChanged(new ItemEvent(comboBox, ItemEvent.ITEM_STATE_CHANGED,
                "a", ItemEvent.SELECTED));
        assertEquals(1, l.getEvents().size());
        assertEquals(comboBox, l.getEvents().get(0).getSource());
        comboBox.removeItemListener(l);
        assertEquals(1, comboBox.getItemListeners().length);
View Full Code Here

    }

    public void testFireItemStateChanged() {
        Object item1 = "item1";
        Object item2 = "item2";
        ItemEvent event1 = new ItemEvent(button, 11, item1, 2);
        ItemEvent event2 = new ItemEvent(button, 111, item2, 1);
        ConcreteItemListener listener1 = new ConcreteItemListener();
        ConcreteItemListener listener2 = new ConcreteItemListener();
        button.addItemListener(listener1);
        button.addItemListener(listener2);
        button.fireItemStateChanged(event1);
View Full Code Here

TOP

Related Classes of java.awt.event.ItemEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.