Package javax.swing.plaf.basic

Examples of javax.swing.plaf.basic.BasicComboPopup


        StyleConstants.setItalic(resultStyle, true);
        StyleConstants.setForeground(resultStyle, new Color(0x20, 0x4a, 0x87));
       
        completeCombo = new JComboBox();
        completeCombo.setRenderer(new DefaultListCellRenderer()); // no silly ticks!
        completePopup = new BasicComboPopup(completeCombo);
       
        if (message != null) {
            final MutableAttributeSet messageStyle = new SimpleAttributeSet();
            StyleConstants.setBackground(messageStyle, area.getForeground());
            StyleConstants.setForeground(messageStyle, area.getBackground());
View Full Code Here


import com.jgoodies.looks.plastic.PlasticComboBoxUI;

public class SteppedComboBoxUI extends PlasticComboBoxUI {
  @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;
  }
View Full Code Here

                .createLayoutManager());
    }

    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));
    }
View Full Code Here

        StyleConstants.setItalic(resultStyle, true);
        StyleConstants.setForeground(resultStyle, new Color(0x20, 0x4a, 0x87));
       
        completeCombo = new JComboBox();
        completeCombo.setRenderer(new DefaultListCellRenderer()); // no silly ticks!
        completePopup = new BasicComboPopup(completeCombo);
       
        if (message != null) {
            final MutableAttributeSet messageStyle = new SimpleAttributeSet();
            StyleConstants.setBackground(messageStyle, area.getForeground());
            StyleConstants.setForeground(messageStyle, area.getBackground());
View Full Code Here

    @Test
    public void testEventsGetFiredOnSetText() {
        MessageList events = new MessageList();
        MockComponentListener listener = new MockComponentListener(events, "popup");
        BasicComboPopup popup = (BasicComboPopup) dialog.getComboBox().getAccessibleContext().getAccessibleChild(0);
        popup.getList().addFocusListener(listener);
        popup.getList().addMouseListener(listener);
        assertEquals("a", mComboBox.getText());
        events.assertEmpty();
        mComboBox.setText("b");
        events.assertNextMessageInList("popup:mouseEntered");
        events.assertNextMessageInList("popup:mousePressed");
View Full Code Here

        StyleConstants.setItalic(resultStyle, true);
        StyleConstants.setForeground(resultStyle, new Color(0x20, 0x4a, 0x87));
       
        completeCombo = new JComboBox();
        completeCombo.setRenderer(new DefaultListCellRenderer()); // no silly ticks!
        completePopup = new BasicComboPopup(completeCombo);
       
        if (message != null) {
            final MutableAttributeSet messageStyle = new SimpleAttributeSet();
            StyleConstants.setBackground(messageStyle, area.getForeground());
            StyleConstants.setForeground(messageStyle, area.getBackground());
View Full Code Here

* @author Vicky C
*/

class SteppedComboBoxUI extends MetalComboBoxUI {
  protected ComboPopup createPopup() {
    BasicComboPopup popup = new BasicComboPopup(comboBox) {

            @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;
  }
View Full Code Here

                .createLayoutManager());
    }

    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));
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected ComboPopup createPopup ()
    {
        return new BasicComboPopup ( comboBox )
        {
            @Override
            protected JScrollPane createScroller ()
            {
                final JScrollPane scroll = super.createScroller ();
View Full Code Here

    });

        creatorAddressCombo.setPopupVisible(false);

        Object child = creatorAddressCombo.getAccessibleContext().getAccessibleChild(0);
        BasicComboPopup popup = (BasicComboPopup)child;

        JList list = popup.getList();
        list.setSelectionBackground(Color.cyan);
        list.setBorder(null);

    for (int i = 0; i < creatorAddressCombo.getComponentCount(); i++) {
            if (creatorAddressCombo.getComponent(i) instanceof CellRendererPane) {
View Full Code Here

TOP

Related Classes of javax.swing.plaf.basic.BasicComboPopup

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.