Java Code Examples for javax.swing.plaf.basic.BasicComboPopup

The following are top voted examples for showing how to use javax.swing.plaf.basic.BasicComboPopup. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jdk8u-jdk   File: MouseComboBoxTest.java   View source code 6 votes vote down vote up
private static Point getItemPointToClick(final int item) throws Exception {
    final Point[] result = new Point[1];

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
            Point point = popup.getLocationOnScreen();
            Dimension size = popup.getSize();

            int step = size.height / items.length;
            point.x += size.width / 2;
            point.y += step / 2 + step * item;
            result[0] = point;
        }
    });
    return result[0];
}
 
Example 2
Project: openjdk-jdk10   File: MouseComboBoxTest.java   View source code 6 votes vote down vote up
private static Point getItemPointToClick(final int item) throws Exception {
    final Point[] result = new Point[1];

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
            Point point = popup.getLocationOnScreen();
            Dimension size = popup.getSize();

            int step = size.height / items.length;
            point.x += size.width / 2;
            point.y += step / 2 + step * item;
            result[0] = point;
        }
    });
    return result[0];
}
 
Example 3
Project: openjdk9   File: MouseComboBoxTest.java   View source code 6 votes vote down vote up
private static Point getItemPointToClick(final int item) throws Exception {
    final Point[] result = new Point[1];

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
            Point point = popup.getLocationOnScreen();
            Dimension size = popup.getSize();

            int step = size.height / items.length;
            point.x += size.width / 2;
            point.y += step / 2 + step * item;
            result[0] = point;
        }
    });
    return result[0];
}
 
Example 4
Project: jdk8u_jdk   File: MouseComboBoxTest.java   View source code 6 votes vote down vote up
private static Point getItemPointToClick(final int item) throws Exception {
    final Point[] result = new Point[1];

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
            Point point = popup.getLocationOnScreen();
            Dimension size = popup.getSize();

            int step = size.height / items.length;
            point.x += size.width / 2;
            point.y += step / 2 + step * item;
            result[0] = point;
        }
    });
    return result[0];
}
 
Example 5
Project: swing-material   File: MaterialComboBox.java   View source code 6 votes vote down vote up
public MaterialComboBox() {
    setModel(new DefaultComboBoxModel<T>());
    setRenderer(new FieldRenderer<T>(this));
    setUI(new BasicComboBoxUI() {
        @Override
        protected ComboPopup createPopup() {
            BasicComboPopup popup = new Popup(comboBox);
            popup.getAccessibleContext().setAccessibleParent(comboBox);
            return popup;
        }

        @Override
        protected JButton createArrowButton() {
            JButton button = new javax.swing.plaf.basic.BasicArrowButton(
                    javax.swing.plaf.basic.BasicArrowButton.SOUTH,
                    MaterialColor.TRANSPARENT,
                    MaterialColor.TRANSPARENT,
                    MaterialColor.TRANSPARENT,
                    MaterialColor.TRANSPARENT);
            button.setName("ComboBox.arrowButton");
            return button;
        }
    });
    setOpaque(false);
    setBackground(MaterialColor.TRANSPARENT);
}
 
Example 6
Project: lookaside_java-1.8.0-openjdk   File: MouseComboBoxTest.java   View source code 6 votes vote down vote up
private static Point getItemPointToClick(final int item) throws Exception {
    final Point[] result = new Point[1];

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
            Point point = popup.getLocationOnScreen();
            Dimension size = popup.getSize();

            int step = size.height / items.length;
            point.x += size.width / 2;
            point.y += step / 2 + step * item;
            result[0] = point;
        }
    });
    return result[0];
}
 
Example 7
Project: Stud.IP-Client   File: DropDownBox.java   View source code 6 votes vote down vote up
@Override
protected ComboPopup createPopup() {
    return new BasicComboPopup(comboBox) {
        private static final long serialVersionUID = -1460253465809092623L;

        @Override
        protected void configurePopup() {
            setBorderPainted(true);
            setBorder(BorderFactory.createLineBorder(Template.COLOR_LIGHT_GRAY));
            setOpaque(false);
            add(scroller);
            setFocusable(false);
        }

    };

}
 
Example 8
Project: infobip-open-jdk-8   File: MouseComboBoxTest.java   View source code 6 votes vote down vote up
private static Point getItemPointToClick(final int item) throws Exception {
    final Point[] result = new Point[1];

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
            Point point = popup.getLocationOnScreen();
            Dimension size = popup.getSize();

            int step = size.height / items.length;
            point.x += size.width / 2;
            point.y += step / 2 + step * item;
            result[0] = point;
        }
    });
    return result[0];
}
 
Example 9
Project: jdk8u-dev-jdk   File: MouseComboBoxTest.java   View source code 6 votes vote down vote up
private static Point getItemPointToClick(final int item) throws Exception {
    final Point[] result = new Point[1];

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
            Point point = popup.getLocationOnScreen();
            Dimension size = popup.getSize();

            int step = size.height / items.length;
            point.x += size.width / 2;
            point.y += step / 2 + step * item;
            result[0] = point;
        }
    });
    return result[0];
}
 
Example 10
Project: FileTemplatesVariable   File: AutoCompletion.java   View source code 6 votes vote down vote up
private int lookupPopupItem(String pattern, boolean select) {
    BasicComboPopup popup = (BasicComboPopup) comboBox.getAccessibleContext().getAccessibleChild(0);
    JList list = popup.getList();
    int nextMatch = list.getNextMatch(pattern, 0, Position.Bias.Forward);
    if (list.getSelectedIndex() > 0) {
        nextMatch = nextMatch < 0 ? list.getNextMatch(pattern, list.getSelectedIndex(), Position.Bias.Backward) : nextMatch;
    }
    if (select) {
        if (nextMatch >= 0) {
            list.ensureIndexIsVisible(nextMatch);
            list.setSelectedIndex(nextMatch);
        } else {
            list.getSelectionModel().clearSelection();
        }
    }
    return nextMatch;
}
 
Example 11
Project: Juicebox   File: BoundsPopupMenuListener.java   View source code 6 votes vote down vote up
/**
 * Alter the bounds of the popup just before it is made visible.
 */
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    @SuppressWarnings("unchecked")
    JComboBox<E> comboBox = (JComboBox<E>) e.getSource();

    if (comboBox.getItemCount() == 0) return;

    final Object child = comboBox.getAccessibleContext().getAccessibleChild(0);

    if (child instanceof BasicComboPopup) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                customizePopup((BasicComboPopup) child);
            }
        });
    }
}
 
Example 12
Project: Juicebox   File: BoundsPopupMenuListener.java   View source code 6 votes vote down vote up
private void customizePopup(BasicComboPopup popup) {
    scrollPane = getScrollPane(popup);

    if (popupWider)
        popupWider(popup);

    checkHorizontalScrollBar(popup);

    //  For some reason in JDK7 the popup will not display at its preferred
    //  width unless its location has been changed from its default
    //  (ie. for normal "pop down" shift the popup and reset)

    Component comboBox = popup.getInvoker();
    Point location = comboBox.getLocationOnScreen();

    if (popupAbove) {
        int height = popup.getPreferredSize().height;
        popup.setLocation(location.x, location.y - height);
    } else {
        //int height = comboBox.getPreferredSize().height;
        //popup.setLocation(location.x, location.y + height - 1);
        //popup.setLocation(location.x, location.y + height);
        //TODO should not be hardcoded
        popup.setLocation(location.x + 5, location.y + 35);
    }
}
 
Example 13
Project: Juicebox   File: BoundsPopupMenuListener.java   View source code 6 votes vote down vote up
private void popupWider(BasicComboPopup popup) {
    @SuppressWarnings("unchecked")
    JList<E> list = popup.getList();

    //  Determine the maximimum width to use:
    //  a) determine the popup preferred width
    //  b) limit width to the maximum if specified
    //  c) ensure width is not less than the scroll pane width

    int popupWidth = list.getPreferredSize().width
            + 5  // make sure horizontal scrollbar doesn't appear
            + getScrollBarWidth(popup, scrollPane);

    if (maximumWidth != -1) {
        popupWidth = Math.min(popupWidth, maximumWidth);
    }

    Dimension scrollPaneSize = scrollPane.getPreferredSize();
    popupWidth = Math.max(popupWidth, scrollPaneSize.width);

    //  Adjust the width

    scrollPaneSize.width = popupWidth;
    scrollPane.setPreferredSize(scrollPaneSize);
    scrollPane.setMaximumSize(scrollPaneSize);
}
 
Example 14
Project: cn1   File: MetalComboBoxUITest.java   View source code 6 votes vote down vote up
public void testGetMinimumSize() throws Exception {
    ui.setComboBox(comboBox);
    ComboPopup popup = new BasicComboPopup(comboBox);
    ui.setPopup(popup);
    ui.setListBox(popup.getList());
    ui.installListeners();
    comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent(
            popup.getList(), "", -1, false, false).getPreferredSize();
    Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8,
            listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
    assertEquals(expectedSize, ui.getCachedMinimumSize());
    ui.setCachedMinimumSize(new Dimension(100, 100));
    assertEquals(ui.getCachedMinimumSize(), ui.getMinimumSize(null));
    comboBox.addItem("aaa");
    listPart = new BasicComboBoxRenderer().getListCellRendererComponent(popup.getList(),
            "aaa", -1, false, false).getPreferredSize();
    expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
}
 
Example 15
Project: openjdk-jdk7u-jdk   File: MouseComboBoxTest.java   View source code 6 votes vote down vote up
private static Point getItemPointToClick(final int item) throws Exception {
    final Point[] result = new Point[1];

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
            Point point = popup.getLocationOnScreen();
            Dimension size = popup.getSize();

            int step = size.height / items.length;
            point.x += size.width / 2;
            point.y += step / 2 + step * item;
            result[0] = point;
        }
    });
    return result[0];
}
 
Example 16
Project: com.opendoorlogistics   File: BoundsPopupMenuListener.java   View source code 6 votes vote down vote up
/**
 * Alter the bounds of the popup just before it is made visible.
 */
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
	JComboBox comboBox = (JComboBox) e.getSource();

	if (comboBox.getItemCount() == 0)
		return;

	final Object child = comboBox.getAccessibleContext().getAccessibleChild(0);

	if (child instanceof BasicComboPopup) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				customizePopup((BasicComboPopup) child);
			}
		});
	}
}
 
Example 17
Project: com.opendoorlogistics   File: BoundsPopupMenuListener.java   View source code 6 votes vote down vote up
protected void popupWider(BasicComboPopup popup) {
	JList list = popup.getList();

	// Determine the maximimum width to use:
	// a) determine the popup preferred width
	// b) limit width to the maximum if specified
	// c) ensure width is not less than the scroll pane width

	int popupWidth = list.getPreferredSize().width + 5 // make sure horizontal scrollbar doesn't appear
			+ getScrollBarWidth(popup, scrollPane);

	if (maximumWidth != -1) {
		popupWidth = Math.min(popupWidth, maximumWidth);
	}

	Dimension scrollPaneSize = scrollPane.getPreferredSize();
	popupWidth = Math.max(popupWidth, scrollPaneSize.width);

	// Adjust the width

	scrollPaneSize.width = popupWidth;
	scrollPane.setPreferredSize(scrollPaneSize);
	scrollPane.setMaximumSize(scrollPaneSize);
}
 
Example 18
Project: freeVM   File: MetalComboBoxUITest.java   View source code 6 votes vote down vote up
public void testGetMinimumSize() throws Exception {
    ui.setComboBox(comboBox);
    ComboPopup popup = new BasicComboPopup(comboBox);
    ui.setPopup(popup);
    ui.setListBox(popup.getList());
    ui.installListeners();
    comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent(
            popup.getList(), "", -1, false, false).getPreferredSize();
    Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8,
            listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
    assertEquals(expectedSize, ui.getCachedMinimumSize());
    ui.setCachedMinimumSize(new Dimension(100, 100));
    assertEquals(ui.getCachedMinimumSize(), ui.getMinimumSize(null));
    comboBox.addItem("aaa");
    listPart = new BasicComboBoxRenderer().getListCellRendererComponent(popup.getList(),
            "aaa", -1, false, false).getPreferredSize();
    expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
}
 
Example 19
Project: freeVM   File: MetalComboBoxUITest.java   View source code 6 votes vote down vote up
public void testGetMinimumSize() throws Exception {
    ui.setComboBox(comboBox);
    ComboPopup popup = new BasicComboPopup(comboBox);
    ui.setPopup(popup);
    ui.setListBox(popup.getList());
    ui.installListeners();
    comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent(
            popup.getList(), "", -1, false, false).getPreferredSize();
    Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8,
            listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
    assertEquals(expectedSize, ui.getCachedMinimumSize());
    ui.setCachedMinimumSize(new Dimension(100, 100));
    assertEquals(ui.getCachedMinimumSize(), ui.getMinimumSize(null));
    comboBox.addItem("aaa");
    listPart = new BasicComboBoxRenderer().getListCellRendererComponent(popup.getList(),
            "aaa", -1, false, false).getPreferredSize();
    expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
}
 
Example 20
Project: jmt   File: SteppedComboBoxUI.java   View source code 5 votes vote down vote up
@Override
protected ComboPopup createPopup() {
	BasicComboPopup popup = new BasicComboPopup(comboBox) {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		public void show() {
			Dimension popupSize = ((SteppedComboBox) comboBox).getPopupSize();
			popupSize.setSize(popupSize.width, getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
			Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
			scroller.setMaximumSize(popupBounds.getSize());
			scroller.setPreferredSize(popupBounds.getSize());
			scroller.setMinimumSize(popupBounds.getSize());
			list.invalidate();
			int selectedIndex = comboBox.getSelectedIndex();
			if (selectedIndex == -1) {
				list.clearSelection();
			} else {
				list.setSelectedIndex(selectedIndex);
			}
			list.ensureIndexIsVisible(list.getSelectedIndex());
			setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());

			show(comboBox, popupBounds.x, popupBounds.y);
		}
	};
	popup.getAccessibleContext().setAccessibleParent(comboBox);
	return popup;
}
 
Example 21
Project: QN-ACTR-Release   File: SteppedComboBoxUI.java   View source code 5 votes vote down vote up
@Override
protected ComboPopup createPopup() {
	BasicComboPopup popup = new BasicComboPopup(comboBox) {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		public void show() {
			Dimension popupSize = ((SteppedComboBox) comboBox).getPopupSize();
			popupSize.setSize(popupSize.width, getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
			Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
			scroller.setMaximumSize(popupBounds.getSize());
			scroller.setPreferredSize(popupBounds.getSize());
			scroller.setMinimumSize(popupBounds.getSize());
			list.invalidate();
			int selectedIndex = comboBox.getSelectedIndex();
			if (selectedIndex == -1) {
				list.clearSelection();
			} else {
				list.setSelectedIndex(selectedIndex);
			}
			list.ensureIndexIsVisible(list.getSelectedIndex());
			setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());

			show(comboBox, popupBounds.x, popupBounds.y);
		}
	};
	popup.getAccessibleContext().setAccessibleParent(comboBox);
	return popup;
}
 
Example 22
Project: OpenJSharp   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 23
Project: jdk8u-jdk   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 24
Project: jdk8u-jdk   File: bug4743225.java   View source code 5 votes vote down vote up
public static BasicComboPopup getPopup() {
    AccessibleContext c = cb.getAccessibleContext();
    for(int i = 0; i < c.getAccessibleChildrenCount(); i ++) {
        if (c.getAccessibleChild(i) instanceof BasicComboPopup) {
            return (BasicComboPopup) c.getAccessibleChild(i);
        }
    }
    throw new AssertionError("No BasicComboPopup found");
}
 
Example 25
Project: openjdk-jdk10   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 26
Project: openjdk-jdk10   File: bug4743225.java   View source code 5 votes vote down vote up
public static BasicComboPopup getPopup() {
    AccessibleContext c = cb.getAccessibleContext();
    for(int i = 0; i < c.getAccessibleChildrenCount(); i ++) {
        if (c.getAccessibleChild(i) instanceof BasicComboPopup) {
            return (BasicComboPopup) c.getAccessibleChild(i);
        }
    }
    throw new AssertionError("No BasicComboPopup found");
}
 
Example 27
Project: openjdk9   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 28
Project: openjdk9   File: bug4743225.java   View source code 5 votes vote down vote up
public static BasicComboPopup getPopup() {
    AccessibleContext c = cb.getAccessibleContext();
    for(int i = 0; i < c.getAccessibleChildrenCount(); i ++) {
        if (c.getAccessibleChild(i) instanceof BasicComboPopup) {
            return (BasicComboPopup) c.getAccessibleChild(i);
        }
    }
    throw new AssertionError("No BasicComboPopup found");
}
 
Example 29
Project: Java8CN   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 30
Project: workcraft   File: FlatComboBox.java   View source code 5 votes vote down vote up
@Override
protected ComboPopup createPopup() {
    BasicComboPopup popup = new BasicComboPopup(comboBox) {
        @Override
        protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
            return super.computePopupBounds(px, py, Math.max(comboBox.getPreferredSize().width, pw), ph);
        }
    };
    popup.getAccessibleContext().setAccessibleParent(comboBox);
    return popup;
}
 
Example 31
Project: jdk8u_jdk   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 32
Project: jdk8u_jdk   File: bug4743225.java   View source code 5 votes vote down vote up
public static BasicComboPopup getPopup() {
    AccessibleContext c = cb.getAccessibleContext();
    for(int i = 0; i < c.getAccessibleChildrenCount(); i ++) {
        if (c.getAccessibleChild(i) instanceof BasicComboPopup) {
            return (BasicComboPopup) c.getAccessibleChild(i);
        }
    }
    throw new AssertionError("No BasicComboPopup found");
}
 
Example 33
Project: lookaside_java-1.8.0-openjdk   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 34
Project: lookaside_java-1.8.0-openjdk   File: bug4743225.java   View source code 5 votes vote down vote up
public static BasicComboPopup getPopup() {
    AccessibleContext c = cb.getAccessibleContext();
    for(int i = 0; i < c.getAccessibleChildrenCount(); i ++) {
        if (c.getAccessibleChild(i) instanceof BasicComboPopup) {
            return (BasicComboPopup) c.getAccessibleChild(i);
        }
    }
    throw new AssertionError("No BasicComboPopup found");
}
 
Example 35
Project: NoMoreDropboxMSN   File: MSNView.java   View source code 5 votes vote down vote up
/**
 * Updates the color of the user state combo box
 */
private void updateStateBoxColor(){
        ComboUserState.setForeground(state_colors[ComboUserState.getSelectedIndex()]);
        Object child = ComboUserState.getAccessibleContext().getAccessibleChild(0);
        BasicComboPopup popup = (BasicComboPopup)child;
        JList list = popup.getList();
        list.setSelectionForeground(state_colors[ComboUserState.getSelectedIndex()]);
        list.setSelectionBackground(Color.WHITE);
}
 
Example 36
Project: DropboxMSN   File: MSNView.java   View source code 5 votes vote down vote up
/**
 * Updates the color of the user state combo box
 */
private void updateStateBoxColor(){
        ComboUserState.setForeground(state_colors[ComboUserState.getSelectedIndex()]);
        Object child = ComboUserState.getAccessibleContext().getAccessibleChild(0);
        BasicComboPopup popup = (BasicComboPopup)child;
        JList list = popup.getList();
        list.setSelectionForeground(state_colors[ComboUserState.getSelectedIndex()]);
        list.setSelectionBackground(Color.WHITE);
}
 
Example 37
Project: infobip-open-jdk-8   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 38
Project: infobip-open-jdk-8   File: bug4743225.java   View source code 5 votes vote down vote up
public static BasicComboPopup getPopup() {
    AccessibleContext c = cb.getAccessibleContext();
    for(int i = 0; i < c.getAccessibleChildrenCount(); i ++) {
        if (c.getAccessibleChild(i) instanceof BasicComboPopup) {
            return (BasicComboPopup) c.getAccessibleChild(i);
        }
    }
    throw new AssertionError("No BasicComboPopup found");
}
 
Example 39
Project: jdk8u-dev-jdk   File: JPopupMenu.java   View source code 5 votes vote down vote up
private void fireActiveDescendant() {
    if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList<?> popupList = ((BasicComboPopup)JPopupMenu.this).getList();
        if (popupList == null) {
            return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
            return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
            return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
            AccessibleContext invokerContext = invoker.getAccessibleContext();
            if (invokerContext != null) {
                // Check invokerContext because Component.getAccessibleContext
                // returns null. Classes that extend Component are responsible
                // for returning a non-null AccessibleContext.
                invokerContext.firePropertyChange(
                    ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
                    null, selectedItem);
            }
        }
    }
}
 
Example 40
Project: jdk8u-dev-jdk   File: bug4743225.java   View source code 5 votes vote down vote up
public static BasicComboPopup getPopup() {
    AccessibleContext c = cb.getAccessibleContext();
    for(int i = 0; i < c.getAccessibleChildrenCount(); i ++) {
        if (c.getAccessibleChild(i) instanceof BasicComboPopup) {
            return (BasicComboPopup) c.getAccessibleChild(i);
        }
    }
    throw new AssertionError("No BasicComboPopup found");
}