Scrigroup - Documente si articole

Username / Parola inexistente      

Home Documente Upload Resurse Alte limbi doc  

AccessAdobe photoshopAlgoritmiAutocadBaze de dateCC sharp
CalculatoareCorel drawDot netExcelFox proFrontpageHardware
HtmlInternetJavaLinuxMatlabMs dosPascal
PhpPower pointRetele calculatoareSqlTutorialsWebdesignWindows

AspAutocadCDot netExcelFox proHtmlJava
LinuxMathcadPhotoshopPhpSqlVisual studioWindowsXml

Drop-down lists


+ Font mai mare | - Font mai mic


Trimite pe Messenger
Seam Contexts
Casting operators
Java programming guidelines
Combining composition and inheritance
RTTI considered harmful
Alternatives to action
Web Applications
Multidimensional arrays
Sharing limited resources: Improperly accessing resources
Connecting to databases with JDBC

Drop-down lists

Like a group of radio buttons, a drop-down list is a way to force the user to select only one element from a group of possibilities. However, itís a much more compact way to accomplish this, and itís easier to change the elements of the list without surprising the user. (You can change radio buttons dynamically, but that tends to be visibly jarring).

Javaís Choice box is not like the combo box in Windows, which lets you select from a list or type in your own selection. With a Choice box you choose one and only one element from the list. In the following example, the Choice box starts with a certain number of entries and then new entries are added to the box when a button is pressed. This allows you to see some interesting behaviors in Choice boxes:


// Using drop-down lists

import java.awt.*;

import java.applet.*;

public class Choice1 extends Applet ;

TextField t = new TextField(30);

Choice c = new Choice();

Button b = new Button('Add items');

int count = 0;

public void init()

public boolean action (Event evt, Object arg)


return super.action(evt, arg);

return true;


} ///:~

The TextField displays the ďselected index,Ē which is the sequence number of the currently selected element, as well as the String representation of the second argument of action( ), which is in this case the string that was selected.

When you run this applet, pay attention to the determination of the size of the Choice box: in Windows, the size is fixed from the first time you drop down the list. This means that if you drop down the list, then add more elements to the list, the elements will be there but the drop-down list wonít get any longer (you can scroll through the elements). However, if you add all the elements before the first time the list is dropped down, then it will be sized correctly. Of course, the user will expect to see the whole list when itís dropped down, so this behavior puts some significant limitations on adding elements to Choice boxes.

This behavior is apparently a bug and will be fixed in a later version of Java.

Politica de confidentialitate



Vizualizari: 374
Importanta: rank

Comenteaza documentul:

Te rugam sa te autentifici sau sa iti faci cont pentru a putea comenta

Creaza cont nou

Termeni si conditii de utilizare | Contact
© SCRIGROUP 2022 . All rights reserved

Distribuie URL

Adauga cod HTML in site