-
Bug
-
Resolution: Fixed
-
P3
-
1.0
-
1.0beta2
-
x86
-
solaris_2.4, windows_nt
-
Verified
Win32 Only: awt.List created with allow multiple selections = false, still allows multiple
selections.
Steps to reproduce
Compile and run the attached code
<Click> on items one and three 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(4, 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");
}
}
/* Generic Applet to Application Frame
* @(#)AppletFrame.java 1.3 16 Nov 1995 17:26:57
* @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)
{
// 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
The description field as copied from bug report 1230208 follows:
>From: Ed Snible <###@###.###>
All of the java.awt.List objects that I created were multiple selection no matter what I passed in for the multipleSelection parameter
selections.
Steps to reproduce
Compile and run the attached code
<Click> on items one and three 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(4, 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");
}
}
/* Generic Applet to Application Frame
* @(#)AppletFrame.java 1.3 16 Nov 1995 17:26:57
* @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)
{
// 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
The description field as copied from bug report 1230208 follows:
>From: Ed Snible <###@###.###>
All of the java.awt.List objects that I created were multiple selection no matter what I passed in for the multipleSelection parameter