Other | Other |
---|---|
1.1.5 1.1.5Fixed | 1.2.0Fixed |
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
This is a sparc only bug. If the application's scrollbar event handler failed to return to AWT, the AWT will keep sending the scrolling events as if the mouse button was held down and caused the scrollbar to run away... (it's on both JDK 1.1 and 1.1.1) Try the following testing code. ----------------------------------------------- import java.awt.*; import java.awt.Color; public class ScrollbarTest2 extends java.applet.Applet { ScrollControl ScrollControl; Scrollbar f1; public void init() { Color foreColor = new Color(0,0,0); Color backColor = new Color(160,160,160); setBackground(backColor); setForeground(foreColor); setLayout(new GridLayout(1,2,10,10)); // play with different delay values... // if the scrollbar's handler can not return to AWT within certain time, // the AWT will keep sending the same event (just as if you press the mouse // button down :( ScrollControl = new ScrollControl(this, "0",0, /* delay */ 800); add(ScrollControl); } void update(ScrollControl in) { Color c; String s1 = in.lab1.getText(); int v1 = ScrollControl.f1.getValue(); } } class ScrollControl extends Panel { Scrollbar f1; Label lab1; ScrollbarTest2 outerparent; int delay; public ScrollControl(ScrollbarTest2 target, String lbl, int val, int delay) { this.outerparent = target; setLayout(new GridLayout(1,2,0,0)); f1 = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 200); lab1 = new Label(String.valueOf(f1.getValue()),Label.CENTER); add(lab1); add(f1); this.delay = delay; } public boolean handleEvent(Event evt) { if (evt.target instanceof Scrollbar) { int v = ((Scrollbar)evt.target).getValue(); lab1.setText(String.valueOf(v)); this.outerparent.update(this); if (evt.id == Event.SCROLL_PAGE_UP || evt.id == Event.SCROLL_PAGE_DOWN) { try { Thread.sleep(delay); } catch (Exception e) { } } return(true); } else return false; } } samuel.chen@Eng 1997-04-28
|