Package javax.swing.plaf.metal

Examples of javax.swing.plaf.metal.MetalComboBoxButton


    JComboBox cb = new JComboBox();
    MyMetalComboBoxUI ui = new MyMetalComboBoxUI();
    cb.setUI(ui);
    Insets insets = ui.getArrowButton().getInsets();
    Insets comboInsets = cb.getInsets();
    MetalComboBoxButton b = (MetalComboBoxButton) ui.getArrowButton();
    Dimension displaySize = ui.getDisplaySize();
    int width = displaySize.width + insets.left + 2 * insets.right
                + comboInsets.left + comboInsets.right
                + b.getComboIcon().getIconWidth();
    int height = displaySize.height + comboInsets.top + comboInsets.bottom
                 + insets.top + insets.bottom;
    harness.check(ui.getMinimumSize(cb), new Dimension(width, height));
                   // the width is the display width plus the button width and
                   // the button width is equal to 'height'
   
    cb.setModel(new DefaultComboBoxModel(new Object[] {"X"}));
    displaySize = ui.getDisplaySize();
    width = displaySize.width + insets.left + 2 * insets.right
                + comboInsets.left + comboInsets.right
                + b.getComboIcon().getIconWidth();
    height = displaySize.height + comboInsets.top + comboInsets.bottom
             + insets.top + insets.bottom;
    harness.check(ui.getMinimumSize(cb), new Dimension(width, height));
   
    cb.setPrototypeDisplayValue("XX");   
    displaySize = ui.getDisplaySize();
    width = displaySize.width + insets.left + 2 * insets.right
                + comboInsets.left + comboInsets.right
                + b.getComboIcon().getIconWidth();
    height = displaySize.height + comboInsets.top + comboInsets.bottom
             + insets.top + insets.bottom;
    harness.check(ui.getMinimumSize(cb), new Dimension(width, height));
  }
View Full Code Here


  {
    JComboBox cb = new JComboBox();
    cb.setFont(new Font("Dialog", Font.PLAIN, 24));
    MyMetalComboBoxUI ui = new MyMetalComboBoxUI();
    cb.setUI(ui);
    MetalComboBoxButton button = (MetalComboBoxButton) ui.getArrowButton();
    MetalComboBoxIcon icon = (MetalComboBoxIcon) button.getComboIcon();
    Insets insets = button.getInsets();
    int additionalWidth = insets.left + insets.right + 2;
    int additionalHeight = insets.top + insets.bottom + 2;
    int iconWidth = icon.getIconWidth() + 6// a margin = 6 by trial and
                                              // error
    FontMetrics fm = cb.getFontMetrics(cb.getFont());
View Full Code Here

    JComboBox cb = new JComboBox();
    MyMetalComboBoxUI ui = new MyMetalComboBoxUI();
    cb.setUI(ui);
    Insets insets = ui.getArrowButton().getInsets();
    Insets comboInsets = cb.getInsets();
    MetalComboBoxButton b = (MetalComboBoxButton) ui.getArrowButton();
    Dimension displaySize = ui.getDisplaySize();
    int width = displaySize.width + insets.left + 2 * insets.right
                + comboInsets.left + comboInsets.right
                + b.getComboIcon().getIconWidth();
    int height = displaySize.height + comboInsets.top + comboInsets.bottom
                 + insets.top + insets.bottom;
    harness.check(ui.getPreferredSize(cb), new Dimension(width, height));
                   // the width is the display width plus the button width and
                   // the button width is equal to 'height'
   
    cb.setModel(new DefaultComboBoxModel(new Object[] {"X"}));
    displaySize = ui.getDisplaySize();
    width = displaySize.width + insets.left + 2 * insets.right
                + comboInsets.left + comboInsets.right
                + b.getComboIcon().getIconWidth();
    height = displaySize.height + comboInsets.top + comboInsets.bottom
             + insets.top + insets.bottom;
    harness.check(ui.getPreferredSize(cb), new Dimension(width, height));
   
    cb.setPrototypeDisplayValue("XX");   
    displaySize = ui.getDisplaySize();
    width = displaySize.width + insets.left + 2 * insets.right
                + comboInsets.left + comboInsets.right
                + b.getComboIcon().getIconWidth();
    height = displaySize.height + comboInsets.top + comboInsets.bottom
             + insets.top + insets.bottom;
    harness.check(ui.getPreferredSize(cb), new Dimension(width, height));
   
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    JComboBox jcb = new JComboBox(new Object[] {"A", "B", "C"});
    Icon icon = new MetalComboBoxIcon();
    MetalComboBoxButton b = new MetalComboBoxButton(jcb, icon,
            new CellRendererPane(), new JList());
    harness.check(b.getComboIcon() == icon);   
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    JComboBox jcb = new JComboBox(new Object[] {"A", "B", "C"});
    Icon icon = new MetalComboBoxIcon();
    MetalComboBoxButton b = new MetalComboBoxButton(jcb, icon,
            new CellRendererPane(), new JList());
    harness.check(b.getComboBox() == jcb);   
  }
View Full Code Here

  private void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("MetalComboBoxButton(JComboBox, Icon, CellRendererPane, JList)");       
    JComboBox jcb = new JComboBox(new Object[] {"A", "B", "C"});
    Icon icon = new MetalComboBoxIcon();
    MetalComboBoxButton b = new MetalComboBoxButton(jcb, icon,
            new CellRendererPane(), new JList());
    harness.check(b.getComboBox() == jcb);
    harness.check(b.getComboIcon() == icon);
    harness.check(!b.isIconOnly());
    Insets margin = b.getMargin();
    harness.check(margin, new Insets(2, 14, 2, 14));
    harness.check(margin instanceof UIResource);
    Insets insets = b.getInsets();
    harness.check(insets, new Insets(5, 17, 5, 17));
   
    boolean pass = false;
    try
    {
      b = new MetalComboBoxButton(null, icon, new CellRendererPane(),
              new JList());
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    b = new MetalComboBoxButton(jcb, null, new CellRendererPane(), new JList());
    harness.check(b.getComboIcon() == null);
    b = new MetalComboBoxButton(jcb, icon, null, new JList());
    b = new MetalComboBoxButton(jcb, icon, new CellRendererPane(), null);
  }
View Full Code Here

  private void testConstructor2(TestHarness harness)
  {
    harness.checkPoint("MetalComboBoxButton(JComboBox, Icon, boolean, CellRendererPane, JList)");       
    JComboBox jcb = new JComboBox(new Object[] {"A", "B", "C"});
    Icon icon = new MetalComboBoxIcon();
    MetalComboBoxButton b = new MetalComboBoxButton(jcb, icon, true,
            new CellRendererPane(), new JList());
    harness.check(b.getComboBox() == jcb);
    harness.check(b.getComboIcon() == icon);
    harness.check(b.isIconOnly());
   
    boolean pass = false;
    try
    {
      b = new MetalComboBoxButton(null, icon, true, new CellRendererPane(),
            new JList());
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    b = new MetalComboBoxButton(jcb, null, true, new CellRendererPane(),
            new JList());
    harness.check(b.getComboIcon() == null);
   
    b = new MetalComboBoxButton(jcb, icon, true, null, new JList());
    b = new MetalComboBoxButton(jcb, icon, true, new CellRendererPane(), null);
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    JComboBox jcb = new JComboBox(new Object[] {"A", "B", "C"});
    Icon icon = new MetalComboBoxIcon();
    MetalComboBoxButton b = new MetalComboBoxButton(jcb, icon,
            new CellRendererPane(), new JList());
    harness.check(!b.isIconOnly());
    b.setIconOnly(true);
    harness.check(b.isIconOnly());
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    JComboBox jcb = new JComboBox(new Object[] {"A", "B", "C"});
    Icon icon1 = new MetalComboBoxIcon();
    MetalComboBoxButton b = new MetalComboBoxButton(jcb, icon1,
            new CellRendererPane(), new JList());
    harness.check(b.isEnabled());
   
    b.setEnabled(false);
    harness.check(!b.isEnabled());
  }
View Full Code Here

  public void test(TestHarness harness)     
  {
    JComboBox jcb = new JComboBox(new Object[] {"A", "B", "C"});
    Icon icon1 = new MetalComboBoxIcon();
    Icon icon2 = MetalIconFactory.getHorizontalSliderThumbIcon();
    MetalComboBoxButton b = new MetalComboBoxButton(jcb, icon1,
            new CellRendererPane(), new JList());
    harness.check(b.getComboIcon() == icon1);
   
    b.setComboIcon(icon2);
    harness.check(b.getComboIcon() == icon2);
   
    b.setComboIcon(null);
    harness.check(b.getComboIcon() == null);
  }
View Full Code Here

TOP

Related Classes of javax.swing.plaf.metal.MetalComboBoxButton

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.