Code example for JTextComponent

Methods: getHeightgetWidth

0
     
    public void showPopup(JTextComponent source, int x, int y) {
        if(list.getModel().getSize() == 0) {
            return; 
        } 
        setPreferredSize(new Dimension(source.getWidth(), source.getHeight() * 4));
        show(source,  x, y);
        ensureSelection(); 
    } 
     
    // #106268: always have some item selected for better usability 
    private void ensureSelection () { 
        if (list.getSelectedIndex() == -1 && (list.getModel().getSize() > 0)) {
            list.setSelectedIndex(0);
        } 
    } 
     
    private class FocusHandler extends FocusAdapter {
        @Override 
        public void focusLost(FocusEvent e) {