BoundedRangeModel hModel = new DefaultBoundedRangeModel(iX,iEX,0,iW); horizontalBar.setModel(hModel);
try { BoundedRangeModel hModel = new DefaultBoundedRangeModel(iX,iEX,0,iW); horizontalBar.setModel(hModel); } catch(IllegalArgumentException iae) { System.err.println("illegal width:["+iX+","+iEX+",0," +iW+"]"); iae.printStackTrace(); }
    public BrowserInternalFrame(BrowserController theController)    {        setSize(600,600);        setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);                if(theController != null)        {            this.controller = theController;            String title = controller.getName();            setTitle("Image Browser: "+title);            this.embeddedView = controller.getView();            embeddedView.setZoomToScale(true);            this.env = BrowserEnvironment.getInstance();        }                setJMenuBar(new BrowserMenuBar(theController.getBrowserModel()));                JPanel toolbarPanel = new JPanel();        toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));                IconManager manager = env.getIconManager();                JButton optionsButton =            new JButton(manager.getSmallIcon(IconManager.OPTIONS_BAR));        optionsButton.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent e)            {                controller.getOverlayModel().showPalette(UIConstants.OPTIONS_PALETTE_NAME);            }        });        optionsButton.setToolTipText("Show Options Menu");                        toolbarPanel.add(optionsButton);        toolbarPanel.add(new JSeparator(JSeparator.HORIZONTAL));        ZoomButtonPanel panel = new ZoomButtonPanel(embeddedView);        toolbarPanel.add(panel);        Container container = getContentPane();        container.setLayout(new BorderLayout());                final JScrollBar horizontalBar =            new JScrollBar(JScrollBar.HORIZONTAL);                    final JScrollBar verticalBar =            new JScrollBar(JScrollBar.VERTICAL);                embeddedView.getViewCamera().addCameraListener(new CameraListener()        {            /* (non-Javadoc)             * @see org.openmicroscopy.shoola.agents.browser.ui.CameraListener#cameraBoundsChanged(double, double, double, double, double, double)             */            public void cameraBoundsChanged(double valueX, double valueY,                                            double extentX, double extentY,                                            double width, double height)            {                int iX = (int)Math.round(valueX);                int iY = (int)Math.round(valueY);                int iEX = (int)Math.round(extentX);                int iEY = (int)Math.round(extentY);                int iW = (int)Math.round(width);                int iH = (int)Math.round(height);                                BoundedRangeModel horizModel = horizontalBar.getModel();                BoundedRangeModel vertModel = verticalBar.getModel();                                if(iEX+iX > iW) horizontalBar.setEnabled(false);                else                {                    horizontalBar.setEnabled(true);                    if(iW != horizModel.getMaximum() ||                       iEX != horizModel.getExtent())                    {                        BoundedRangeModel hModel =                            new DefaultBoundedRangeModel(iX,iEX,0,iW);                        horizontalBar.setModel(hModel);                    }                    else                    {                        horizModel.setValue(iX);                    }                }                                if(iEY+iY > iH) verticalBar.setEnabled(false);                else                {                    verticalBar.setEnabled(true);                    if(iH != vertModel.getMaximum() ||                       iEY != vertModel.getExtent())                    {                        BoundedRangeModel vModel =                            new DefaultBoundedRangeModel(iY,iEY,0,iH);                        verticalBar.setModel(vModel);                    }                    else                    {                        vertModel.setValue(iY);                    }                }            }        });        horizontalBar.setEnabled(false);        horizontalBar.setModel(new DefaultBoundedRangeModel(0,0,0,0));        horizontalBar.addAdjustmentListener(new AdjustmentListener()        {            public void adjustmentValueChanged(AdjustmentEvent e)            {                int value = e.getValue();                embeddedView.getViewCamera().setX(value);            }        });                verticalBar.setEnabled(false);        verticalBar.setModel(new DefaultBoundedRangeModel(0,0,0,0));        verticalBar.addAdjustmentListener(new AdjustmentListener()        {            public void adjustmentValueChanged(AdjustmentEvent e)            {                int value = e.getValue();                embeddedView.getViewCamera().setY(value);            }        });                JPanel fakeScrollPane = new JPanel();        JPanel verticalPanel = new JPanel();        verticalPanel.setLayout(new BorderLayout());        verticalPanel.add(embeddedView,BorderLayout.CENTER);        verticalPanel.add(verticalBar,BorderLayout.EAST);                JPanel horizontalPanel = new JPanel();        horizontalPanel.setLayout(new BorderLayout());        horizontalPanel.add(horizontalBar,BorderLayout.CENTER);        horizontalPanel.add(Box.createHorizontalStrut(verticalBar.getPreferredSize().width),                            BorderLayout.EAST);                verticalPanel.add(horizontalPanel,BorderLayout.SOUTH);                fakeScrollPane.setLayout(new BorderLayout());        fakeScrollPane.add(verticalPanel,BorderLayout.CENTER);        container.add(fakeScrollPane,BorderLayout.CENTER);        container.add(toolbarPanel,BorderLayout.NORTH);        if(controller.getStatusView() != null)        {            container.add(controller.getStatusView(),BorderLayout.SOUTH);        }        this.addFocusListener(new CommonFocusAdapter(this));                final UIWrapper refCopy = this;        this.addInternalFrameListener(new InternalFrameAdapter()        {            /* (non-Javadoc)             * @see javax.swing.event.InternalFrameAdapter#internalFrameClosing(javax.swing.event.InternalFrameEvent)             */            public void internalFrameClosing(InternalFrameEvent arg0)            {                env.getBrowserManager().removeBrowser(refCopy);            }        });    }