Package javax.swing.plaf.basic

Examples of javax.swing.plaf.basic.BasicComboBoxUI


  }
 
  private void testNonEditable(TestHarness harness)
  {
    JComboBox cb = new JComboBox();
    BasicComboBoxUI ui = new BasicComboBoxUI();
    cb.setUI(ui);
    int additionalHeight = 2// margin?  border?
    int additionalWidth = 2
    FontMetrics fm = cb.getFontMetrics(cb.getFont());
   
    // the following width calculation is a guess.  We know the value
    // depends on the font size, and that it is relatively small, so after
    // trying out a few candidates this one seems to give the right result
    int width = fm.charWidth(' ') + additionalWidth;
    int height = fm.getHeight() + additionalHeight;
    harness.check(ui.getPreferredSize(cb),
            new Dimension(width + height, 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"}));
    width = fm.charWidth('X') + additionalWidth;
    harness.check(ui.getPreferredSize(cb),
            new Dimension(width + height, height));
   
    cb.setModel(new DefaultComboBoxModel(new Object[] {null}));
    harness.check(ui.getPreferredSize(cb).height, height);
   
    cb.setModel(new DefaultComboBoxModel(new Object[] {""}));
    harness.check(ui.getPreferredSize(cb).height, height);
   
    cb.setPrototypeDisplayValue("XX");   
    width = fm.stringWidth("XX") + additionalWidth;
    harness.check(ui.getPreferredSize(cb),
            new Dimension(width + height, height));
  }
View Full Code Here


  private void testEditable(TestHarness harness)
  {
    harness.checkPoint("testEditable()");
    JComboBox cb = new JComboBox();
    BasicComboBoxUI ui = new BasicComboBoxUI();
    cb.setUI(ui);
    JTextField tf = (JTextField) cb.getEditor().getEditorComponent();
    cb.setEditable(true);
    Font font = cb.getFont();
    FontMetrics fm = cb.getFontMetrics(font);
    int height = fm.getHeight() + 2;
    int width = fm.stringWidth("m") * tf.getColumns() + height;
    harness.check(ui.getPreferredSize(cb), new Dimension(width, height));   
    cb.setModel(new DefaultComboBoxModel(new Object[] {"X"}));
    harness.check(ui.getPreferredSize(cb), new Dimension(width, height));       
    cb.setPrototypeDisplayValue("XX");   
    harness.check(ui.getPreferredSize(cb), new Dimension(width, height));   
  }
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness
  {
    JComboBox cb = new JComboBox();
    BasicComboBoxUI ui = new BasicComboBoxUI();
    cb.setUI(ui);
    harness.check(ui.getMaximumSize(cb), new Dimension(32767, 32767))
  }
View Full Code Here

            byteArrayOutputStream));

        DefaultListModel model = new DefaultListModel();
        model.add(0, 1);
        model.add(1, 2);
        ListDataHandler listDataHandler = new BasicComboBoxUI().new ListDataHandler();
        model.addListDataListener(listDataHandler);
       
        encoder.writeObject(model);
        encoder.close();
        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
View Full Code Here

            byteArrayOutputStream));

        DefaultListModel model = new DefaultListModel();
        model.add(0, 1);
        model.add(1, 2);
        ListDataHandler listDataHandler = new BasicComboBoxUI().new ListDataHandler();
        model.addListDataListener(listDataHandler);
       
        encoder.writeObject(model);
        encoder.close();
        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
View Full Code Here

                getSecondSpinner().setValue(getSelectedCalendar().getTime().getSeconds());
               
  }      

  public void updateUI() {
    BasicComboBoxUI cui = (BasicComboBoxUI) UIManager.getUI(this);
    if (cui instanceof MetalComboBoxUI) {
      cui = new MetalDateComboBoxUI();
    } else if (cui instanceof MotifComboBoxUI) {
      cui = new MotifDateComboBoxUI();
    } else if (cui instanceof WindowsComboBoxUI) {
View Full Code Here

        comboBox.setToolTipText(getModel().getToolTip());
    }

    private void registerInternalSelectionListener() {
        internalSelectionListener = new InternalSelectionListener();
        BasicComboBoxUI comboBoxUi = (BasicComboBoxUI) comboBox.getUI();
        Accessible a = comboBoxUi.getAccessibleChild(comboBox, 0);
        if (a instanceof ComboPopup) {
            JList jlist = ((ComboPopup) a).getList();
            jlist.addListSelectionListener(internalSelectionListener);
        }
        comboBox.addActionListener(internalSelectionListener);
View Full Code Here

        }
        comboBox.addActionListener(internalSelectionListener);
    }

    private void uninstallInternalSelectionListener() {
        BasicComboBoxUI comboBoxUi = (BasicComboBoxUI) comboBox.getUI();
        Accessible a = comboBoxUi.getAccessibleChild(comboBox, 0);
        if (a instanceof ComboPopup) {
            JList jlist = ((ComboPopup) a).getList();
            jlist.removeListSelectionListener(internalSelectionListener);
        }
        comboBox.removeActionListener(internalSelectionListener);
View Full Code Here

    public MenuTendina(String[] parteData)
    {
        super(parteData);                                                       //Imposta il modello di parte data da creare
        this.setBackground(Color.white);                                        //Imposta colore di sfondo
        this.setBorder(new EtchedBorder());                                     //Crea bordi
        this.setUI(new BasicComboBoxUI());                                      //Imposta stile del menu a tendina
    }
View Full Code Here

TOP

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

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.