-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.0.2
-
x86
-
windows_95
The attached program hangs on Win 32 only (specifically win 95).
I am using JDK 1.0.2 and appletviewer.
Minimal html page needed as well as this program.
The customer's description outlines the problem pretty well
I find that I can make the problem go away by just changing
System.out.print (_fields[f].getText()+" ");
to read
System.out.print (f+" ");
Nothing else I removed helped at all.
So I think it is something about calling this function whilst handling the scroll event.
I can't figure out what ...
//////////////////////////
Tony Squier
###@###.###
//////////////////////////
/**
* This sample code shows a serious problem with the scrollbar
* on the Windows '95 platform (and likely Windows NT). The issue
* is that the scrollbar will lock-up the applet after the user
* has scrolled for a while. What appears to be the problem is
* in the doScroll() method below. The only time the applet will
* lock is when the TextField's getText() method is called. If this
* statement is removed, then the applet does not seem to ever lock-up.
* The problem seems to get worse as more TextFields are added.
*
* Much of the code below is not really part of the problem, but is
* there to show how the scrolling is being performed and to give
* feedback to the user that the data is actually being scrolled. If
* all the code is removed except the stuff to add the scrollbar,
* the event handler, and the TextField getText() methods, the applet
* will still lock.
*
* This code has never hung the Sun Motif environment (both OpenWin and CDE).
*/
import java.awt.*;
import java.applet.*;
import java.util.*;
public class ScrollApplet extends Applet
{
final static int NUMBER_FIELDS = 20;
final static int NUMBER_ITEMS = 60;
Scrollbar _scrollbar;
TextField _fields[];
String _items[];
public void init()
{
setLayout (new BorderLayout());
Panel aPanel = new Panel ();
aPanel.setLayout (new GridLayout (0,2));
_fields = new TextField[NUMBER_FIELDS];
for ( int f = 0; f < NUMBER_FIELDS; f++ )
{
_fields[f] = new TextField (10);
aPanel.add (_fields[f]);
}
_items = new String [NUMBER_ITEMS];
for ( int i = 0; i < _items.length; i++ )
{
_items[i] = String.valueOf (i);
}
_scrollbar = new Scrollbar (Scrollbar.VERTICAL, 0,
NUMBER_FIELDS, 0,
NUMBER_ITEMS-NUMBER_FIELDS);
add ("East", _scrollbar);
add ("Center", aPanel);
}
public boolean handleEvent (Event theEvent)
{
boolean retvalue = true;
if ( theEvent.id == Event.SCROLL_LINE_UP || theEvent.id ==
Event.SCROLL_ABSOLUTE )
{
doScroll();
}
else if ( theEvent.id == Event.SCROLL_LINE_DOWN || theEvent.id
==
Event.SCROLL_ABSOLUTE)
{
doScroll();
}
else if ( theEvent.id == Event.SCROLL_PAGE_UP )
{
doScroll();
}
else if ( theEvent.id == Event.SCROLL_PAGE_DOWN )
{
doScroll();
}
else
{
retvalue = super.handleEvent (theEvent);
}
return retvalue;
}
void doScroll()
{
System.out.print ("Values: ");
for ( int f = 0; f < NUMBER_FIELDS; f++ )
{
// On Windows the following line will cause the
// applet to "hang" after the user has scrolled
// through the list for a while.
System.out.print (_fields[f].getText()+" ");
_fields[f].setText (_items[_scrollbar.getValue() + f]);
}
System.out.println("");
}
}
I am using JDK 1.0.2 and appletviewer.
Minimal html page needed as well as this program.
The customer's description outlines the problem pretty well
I find that I can make the problem go away by just changing
System.out.print (_fields[f].getText()+" ");
to read
System.out.print (f+" ");
Nothing else I removed helped at all.
So I think it is something about calling this function whilst handling the scroll event.
I can't figure out what ...
//////////////////////////
Tony Squier
###@###.###
//////////////////////////
/**
* This sample code shows a serious problem with the scrollbar
* on the Windows '95 platform (and likely Windows NT). The issue
* is that the scrollbar will lock-up the applet after the user
* has scrolled for a while. What appears to be the problem is
* in the doScroll() method below. The only time the applet will
* lock is when the TextField's getText() method is called. If this
* statement is removed, then the applet does not seem to ever lock-up.
* The problem seems to get worse as more TextFields are added.
*
* Much of the code below is not really part of the problem, but is
* there to show how the scrolling is being performed and to give
* feedback to the user that the data is actually being scrolled. If
* all the code is removed except the stuff to add the scrollbar,
* the event handler, and the TextField getText() methods, the applet
* will still lock.
*
* This code has never hung the Sun Motif environment (both OpenWin and CDE).
*/
import java.awt.*;
import java.applet.*;
import java.util.*;
public class ScrollApplet extends Applet
{
final static int NUMBER_FIELDS = 20;
final static int NUMBER_ITEMS = 60;
Scrollbar _scrollbar;
TextField _fields[];
String _items[];
public void init()
{
setLayout (new BorderLayout());
Panel aPanel = new Panel ();
aPanel.setLayout (new GridLayout (0,2));
_fields = new TextField[NUMBER_FIELDS];
for ( int f = 0; f < NUMBER_FIELDS; f++ )
{
_fields[f] = new TextField (10);
aPanel.add (_fields[f]);
}
_items = new String [NUMBER_ITEMS];
for ( int i = 0; i < _items.length; i++ )
{
_items[i] = String.valueOf (i);
}
_scrollbar = new Scrollbar (Scrollbar.VERTICAL, 0,
NUMBER_FIELDS, 0,
NUMBER_ITEMS-NUMBER_FIELDS);
add ("East", _scrollbar);
add ("Center", aPanel);
}
public boolean handleEvent (Event theEvent)
{
boolean retvalue = true;
if ( theEvent.id == Event.SCROLL_LINE_UP || theEvent.id ==
Event.SCROLL_ABSOLUTE )
{
doScroll();
}
else if ( theEvent.id == Event.SCROLL_LINE_DOWN || theEvent.id
==
Event.SCROLL_ABSOLUTE)
{
doScroll();
}
else if ( theEvent.id == Event.SCROLL_PAGE_UP )
{
doScroll();
}
else if ( theEvent.id == Event.SCROLL_PAGE_DOWN )
{
doScroll();
}
else
{
retvalue = super.handleEvent (theEvent);
}
return retvalue;
}
void doScroll()
{
System.out.print ("Values: ");
for ( int f = 0; f < NUMBER_FIELDS; f++ )
{
// On Windows the following line will cause the
// applet to "hang" after the user has scrolled
// through the list for a while.
System.out.print (_fields[f].getText()+" ");
_fields[f].setText (_items[_scrollbar.getValue() + f]);
}
System.out.println("");
}
}