void dispatchSliderEvent(MouseEvent e, int eventType) {
        if(!myrenderer.sliderHasFocus) if(eventType!=MouseEvent.MOUSE_RELEASED){
            if(eventType==MouseEvent.MOUSE_PRESSED){
                Object item = this.getItemAt(myrenderer.selectedIndex);
                if(item instanceof ZoomButtons) ((ZoomButtons)item).button.doClick();
            }
            return;
        }
        int yOffset = 0;//32;//Verticle distance from top of popup to start of slder component. 
        //System.out.println("event at:("+e.getX()+","+(e.getY()-yOffset)+")");//-dropCombo.getY()
        zoomSlider.dispatchEvent(new MouseEvent((Component) e.getSource(), eventType, e.getWhen(), e.getModifiers(), e.getX(), e.getY() - yOffset, e.getClickCount(), e.isPopupTrigger(), e.getButton()));
        refresher.refresh();
    }
}

//class EmptyIcon extends ImageIcon{
//    @Override
//    public int getIconWidth(){
//        return 1;
//    }
//    @Override
//    public int getIconHeight(){
//        return 1;
//    }
//}

class HiddenComboBoxUI extends BasicComboBoxUI {
    public static ComponentUI createUI(JComponent c) {
      return new HiddenComboBoxUI();
    }

    //Create blank button
    @Override
    protected JButton createArrowButton() {
      JButton button = new JButton(new ImageIcon());
      button.setBorder(null);
      return button;
    }
}

class DropButton extends JToolBar {
    ZoomButtons item;
    public DropButton(ZoomButtons tbItem) {
        item=tbItem;
        if(!item.button.isVisible()){
            this.setVisible(false);
            this.setPreferredSize(new Dimension(0,0));
            this.setMaximumSize(new Dimension(0,0));
        }
        else{
        setFloatable(false);
        add(Box.createHorizontalGlue());
        add(item.button);
        add(Box.createHorizontalGlue());
        }
    }
}

class ComponentRenderer implements ListCellRenderer{
    boolean sliderHasFocus=false;
    int selectedIndex=0;

    ComponentRenderer(){
    }
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        if (value instanceof javax.swing.Icon) value = new JLabel((Icon) value);
        if (value instanceof ZoomButtons) value=new DropButton((ZoomButtons)value);
        ((JComponent)value).setOpaque(true);
        if ((value instanceof JSlider)){
            //On linux the slider component does not function correctly so do not display it
            if (!Settings.isWindows())
                return new JPanel();
            sliderHasFocus=isSelected;
        }
        if(isSelected){//Alt text?
            selectedIndex = index;
        }
        return (JComponent)value;
    }
}

class ZoomEditor  extends BasicComboBoxEditor{//implements ComboBoxEditor{//
    static final BufferedImage img =SysIcon.ZoomToX.getBufferedImage(1, BufferedImage.TYPE_INT_ARGB);
    ZoomBar parent;
    GUI mainGUI;

    ZoomEditor(GUI gui,ZoomBar parnt){
        super();
        parent=parnt;
        mainGUI=gui;
    }

    public void update(){
        setItem(null);
    }
    public void makeFocusable(){
        editor.setFocusable(true);
    }
    boolean focusWasLocked(){
        return !editor.isFocusable();
    }

    void dispatchMouse(MouseEvent e){
        editor.dispatchEvent(e);
    }

    @Override
    public JTextField createEditorComponent() {
        editor = new JTextField("",4){
        @Override
        public void paint(Graphics g){
            super.paint(g);
            float trans = 0.15f;
            float[] scale = {trans,trans,trans,trans};
            RescaleOp op = new RescaleOp(scale,(new float[4]),null);
            Graphics2D g2 = ((Graphics2D)g);
            g2.drawImage(img,op, (getWidth()/2)-(img.getWidth()/2), 0);
        }
        };
        editor.setHorizontalAlignment(JTextField.CENTER);
        editor.setBorder(null);
        return editor;
    }
    @Override
    public void setItem(Object anObject){
        String setText="Zoom: Fit";
        int sliderVal =parent.zoomSlider.getValue();
        if(sliderVal>=300) sliderVal = Math.max(300,(int)(mainGUI.mainPanel.getZoomMult()*100));
        if (sliderVal!=0) setText=Integer.toString(sliderVal)+"%";
        editor.setText(setText);
        editor.setFocusable(false);
    }
    @Override
    public Object getItem(){
        parent.zoomSlider.setValueIsAdjusting(true);
        String editorText = editor.getText();
        int newVal =0;
        if(editorText!=null){
            if(editorText.toLowerCase().endsWith("fit")) parent.zoomSlider.setValue(0);
            else{
                StringBuffer numbers = new StringBuffer();
                char c;
                for (int i=0;i<editorText.length();i++) {
                    c = editorText.charAt(i);
                    if (Character.isDigit(c)) {
                        numbers.append(c);
                    }
                }
                try{
                    newVal=Integer.parseInt(numbers.toString());
                    parent.zoomSlider.setValue(newVal);
                } catch (Exception e){
                    //fail silently if invalid
                }
            }
        }
        if(parent.zoomSlider.getValue()<300) {
            parent.zoomSlider.setValueIsAdjusting(false);
        return parent.zoomSlider.getValue();
        }
        mainGUI.zoomTo(newVal);
        return newVal;
    }
}
class RefreshableComboBoxModel extends DefaultComboBoxModel{
    RefreshableComboBoxModel(Object[] itmes){
        super(itmes);
    }
    public void refresh(){
        this.fireContentsChanged(this, 0, 2);
    }
}