[5148] in java-interest

home help back first fref pref prev next nref lref last post

Scrolling Panel

daemon@ATHENA.MIT.EDU (Jutta Willamowski)
Tue Jan 30 06:04:57 1996

From: Jutta Willamowski <Jutta.Willamowski@Grenoble.RXRC.Xerox.com>
Date: Tue, 30 Jan 1996 10:23:46 +0100
To: java-interest@java.sun.com

----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 18

Hi,

I would like to define a scrolling panel. I therefore defined two panels :
one containing two scrollbars (horizontal and vertical) and another panel (the
one that should be scrolled). I then redefined the paint method of the second
panel as shown below. This does not work : the scrollbars are correctly updated,
but the second panel is always shown centered in the scrollerarea.

Does anyone know how to define a scrolled panel correctly ? 

Thanks !

____________________________________________________________________________________
Jutta Willamowski                                       Rank Xerox Reasearch Centre
Tel. (+33) - 76 61 50 60                                6, ch. de Maupertuis
Fax. (+33) - 76 61 50 99                                F - 38240 Meylan
Email Jutta.Willamowski@Grenoble.RXRC.xerox.com

----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: paint
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 51


  public void paint(Graphics g)
  {
    Dimension d = new Dimension(totalSize);
    if (d.width < visibleSize.width)
	d.width = visibleSize.width;
    if (d.height < visibleSize.height)
	d.height = visibleSize.height;

    // draws into offscreen Graphics
    if ((offscreen == null) 
	|| (d.width != offscreensize.width) 
	|| (d.height != offscreensize.height))
    {
      offscreensize = d;
      offscreen = createImage(d.width, d.height);

      offgraphics = offscreen.getGraphics();
      offgraphics.setFont(getFont());

      offgraphics.setColor(Color.red);
      offgraphics.fillRect(0, 0, d.width, d.height);
      
      // scroller stuff :                   
      if (scroller!=null) 
      {
	int h_val = scroller.getHorizontalScrollerVal();
	int v_val = scroller.getVerticalScrollerVal();
	int h_vis = visibleSize.width;
	int v_vis = visibleSize.height;
	int h_max = d.width;
	int v_max = d.height;

	h_max = h_max - h_vis;
	v_max = v_max - v_vis;
	if (h_max < h_val) h_val = h_max;
	if (v_max < v_val) v_val = v_max;
	
	scroller.setHorizontalScrollerValues(h_val, h_vis, 0, h_max);
	scroller.setVerticalScrollerValues(v_val, v_vis, 0, v_max);
 
	offgraphics.translate(-h_val, -v_val);
     }

      // draw scrolled objects : 
      //panel.paint(offgraphics);
      //super.paint(offgraphics);

    }
    g.drawImage(offscreen, 0, 0, null);
  }
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post