-
Bug
-
Resolution: Fixed
-
P3
-
1.0
-
1.0beta2
-
x86
-
windows_nt
-
Verified
Solaris only: List.makeVisible() of the last index in the list causes the list to scroll the
last index item into the first position in the list and open up blank spaces for the rest of
the list. Lists should not be able to scroll past the last item.
Steps to reproduce:
Compile the following code
Run java ListTest
Press <makeVisible>
// note: item 6 is now the top item in the list and there are two blank spaces below it
in the list.
/* tests the list stuff */
import java.awt.*;
import java.applet.Applet;
public class ListTest extends Applet
{
List list;
Label label;
Label label1;
public void init()
{
Panel panel = new Panel();
list = new List(3, false);
list.addItem("One");
list.addItem("Two");
list.addItem("Three");
list.addItem("Four");
list.addItem("Five");
list.addItem("Six");
panel.add( new Button("makeVisible") );
panel.add( new Button("getVisibleIndex") );
panel.add( label = new Label("Nothing") );
panel.add( new Button("getSelectedIndex") );
panel.add( label1 = new Label("Nothing") );
add(panel);
add(list);
resize(400, 400);
}
public boolean action(Event evt, Object obj)
{
if (evt.target instanceof Button)
{
String text = (String) obj;
if ( text.equals("makeVisible") )
list.makeVisible(list.countItems() - 1);
else if ( text.equals("getVisibleIndex") )
label.setText( Integer.toString( list.getVisibleIndex() ) );
else
label1.setText( Integer.toString( list.getSelectedIndex() ) );
return true;
} // end if button
return super.action(evt, obj);
}
public static void main(String args[])
{
AppletFrame.startApplet("ListTest", "List Test", args);
}
}
/* Generic Applet to Application Frame
* @(#)AppletFrame.java 1.4 02 Dec 1995 15:28:07
* @author Kevin A. Smith
*
*/
import java.awt.Frame;
import java.awt.Event;
import java.awt.Dimension;
import java.applet.Applet;
// Applet to Application Frame window
class AppletFrame extends Frame
{
public static void startApplet(String className,
String title,
String args[])
{
// local variables
Applet a;
Dimension appletSize;
try
{
// create an instance of your applet class
a = (Applet) Class.forName(className).newInstance();
}
catch (ClassNotFoundException e) { return; }
catch (InstantiationException e) { return; }
catch (IllegalAccessException e) { return; }
// initialize the applet
a.init();
a.start();
// create new application frame window
AppletFrame f = new AppletFrame(title);
// add applet to frame window
f.add("Center", a);
// resize frame window to fit applet
// assumes that the applet sets its own size
// otherwise, you should set a specific size here.
appletSize = a.size();
f.pack();
f.resize(appletSize);
// show the window
f.show();
} // end startApplet()
// constructor needed to pass window title to class Frame
public AppletFrame(String name)
{
// call java.awt.Frame(String) constructor
super(name);
}
// needed to allow window close
public boolean handleEvent(Event e)
{
// Window Destroy event
if (e.id == Event.WINDOW_DESTROY)
{
// exit the program
System.exit(0);
return true;
}
// it's good form to let the super class look at any
// unhandled events
return super.handleEvent(e);
} // end handleEvent()
} // end class AppletFrame
last index item into the first position in the list and open up blank spaces for the rest of
the list. Lists should not be able to scroll past the last item.
Steps to reproduce:
Compile the following code
Run java ListTest
Press <makeVisible>
// note: item 6 is now the top item in the list and there are two blank spaces below it
in the list.
/* tests the list stuff */
import java.awt.*;
import java.applet.Applet;
public class ListTest extends Applet
{
List list;
Label label;
Label label1;
public void init()
{
Panel panel = new Panel();
list = new List(3, false);
list.addItem("One");
list.addItem("Two");
list.addItem("Three");
list.addItem("Four");
list.addItem("Five");
list.addItem("Six");
panel.add( new Button("makeVisible") );
panel.add( new Button("getVisibleIndex") );
panel.add( label = new Label("Nothing") );
panel.add( new Button("getSelectedIndex") );
panel.add( label1 = new Label("Nothing") );
add(panel);
add(list);
resize(400, 400);
}
public boolean action(Event evt, Object obj)
{
if (evt.target instanceof Button)
{
String text = (String) obj;
if ( text.equals("makeVisible") )
list.makeVisible(list.countItems() - 1);
else if ( text.equals("getVisibleIndex") )
label.setText( Integer.toString( list.getVisibleIndex() ) );
else
label1.setText( Integer.toString( list.getSelectedIndex() ) );
return true;
} // end if button
return super.action(evt, obj);
}
public static void main(String args[])
{
AppletFrame.startApplet("ListTest", "List Test", args);
}
}
/* Generic Applet to Application Frame
* @(#)AppletFrame.java 1.4 02 Dec 1995 15:28:07
* @author Kevin A. Smith
*
*/
import java.awt.Frame;
import java.awt.Event;
import java.awt.Dimension;
import java.applet.Applet;
// Applet to Application Frame window
class AppletFrame extends Frame
{
public static void startApplet(String className,
String title,
String args[])
{
// local variables
Applet a;
Dimension appletSize;
try
{
// create an instance of your applet class
a = (Applet) Class.forName(className).newInstance();
}
catch (ClassNotFoundException e) { return; }
catch (InstantiationException e) { return; }
catch (IllegalAccessException e) { return; }
// initialize the applet
a.init();
a.start();
// create new application frame window
AppletFrame f = new AppletFrame(title);
// add applet to frame window
f.add("Center", a);
// resize frame window to fit applet
// assumes that the applet sets its own size
// otherwise, you should set a specific size here.
appletSize = a.size();
f.pack();
f.resize(appletSize);
// show the window
f.show();
} // end startApplet()
// constructor needed to pass window title to class Frame
public AppletFrame(String name)
{
// call java.awt.Frame(String) constructor
super(name);
}
// needed to allow window close
public boolean handleEvent(Event e)
{
// Window Destroy event
if (e.id == Event.WINDOW_DESTROY)
{
// exit the program
System.exit(0);
return true;
}
// it's good form to let the super class look at any
// unhandled events
return super.handleEvent(e);
} // end handleEvent()
} // end class AppletFrame
- relates to
-
JDK-1228744 fp.bugs 2555: all platforms: List.getVisibleIndex() always returns -1
- Closed