For what it's worth, I've tried a few combinations: putting a
Choice with twelve month names in a Frame or in a JFrame, using
different layout managers, and so on. On *none* of them did I get
any scroll bars! The only way I could get scroll bars to show up
was to add more items to the Choice: twenty-four didn't scroll,
but thirty-six did.
My suspicion at the moment is that there's something else you're
doing that causes the Choice to behave this way: Setting a size on
the Container or on the Choice itself, using a layout manager that
I didn't try, using a gigantic font, or something of that sort. But
without knowing just what you're doing, all I can do is guess.
Could you whittle down your code to a short, complete, compilable
example that demonstrates the problem, and post it? Exact details
on the Java version would also be welcome.
Thank you for looking into it.
I noticed that if I run the same application on a different machine I
do not get a scrollbar, however I am getting it on my machine, and
apparently our client is too.
The program below reproduces the issue, though it's not based on our
code, but rather just a sample code I found online while trying to see
if the issue was with our application or somewhere else. On one
machine the pulldown Choice doesn't have a scrollbar, and on the other
machine it does.
The machine where I do not get the scrollbar has java 1.6.0_10
The machine where I do get the scrollbar has java 1.6.0_05
/* copied from
**
http://java.comsci.us/examples/awt/Choice.html
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
public class Choice2 extends JFrame implements ItemListener {
/* Declaration */
private LayoutManager Layout;
private Choice Selector;
private Font SansSerif;
public static void main(String []argv)
{
Choice2 c2 = new Choice2();
}
public Choice2 () {
/* Declaration */
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String [] ColorList;
int i;
/* Instantiation */
ColorList = new String [20];
SansSerif = new Font ("SansSerif", Font.BOLD, 14);
Layout = new FlowLayout ();
Selector = new Choice ();
/* Decoration */
ColorList [0] = "Red";
ColorList [1] = "Magenta";
ColorList [2] = "Blue";
ColorList [3] = "Cyan";
ColorList [4] = "Green";
ColorList [5] = "Yellow";
ColorList [6] = "White";
ColorList [7] = "Gray";
ColorList [8] = "Black";
ColorList [9] = "Black2";
ColorList [10] = "1Red";
ColorList [11] = "1Magenta";
ColorList [12] = "1Blue";
ColorList [13] = "1Cyan";
ColorList [14] = "1Green";
ColorList [15] = "1Yellow";
ColorList [16] = "1White";
ColorList [17] = "1Gray";
ColorList [18] = "1Black";
ColorList [19] = "1Black2";
for (i = 0; i < ColorList.length; ++i) {
Selector.insert (ColorList
, i);
}
Selector.setBackground (Color.yellow);
Selector.setForeground (Color.red);
Selector.setFont (SansSerif);
/* Location */
setLayout (Layout);
add (Selector);
/* Configuration */
Selector.addItemListener (this);
/* Initialization */
Selector.select (5);
setBackground (Color.yellow);
setSize(300, 300);
setVisible(true);
}
public void itemStateChanged(ItemEvent e) {
int Selection;
Selection = Selector.getSelectedIndex();
if (Selection == 0) {
setBackground (Color.red);
} else if (Selection == 1) {
setBackground (Color.magenta);
} else if (Selection == 2) {
setBackground (Color.blue);
} else if (Selection == 3) {
setBackground (Color.cyan);
} else if (Selection == 4) {
setBackground (Color.green);
} else if (Selection == 5) {
setBackground (Color.yellow);
} else if (Selection == 6) {
setBackground (Color.white);
} else if (Selection == 7) {
setBackground (Color.gray);
} else if (Selection == 8) {
setBackground (Color.black);
}
}
}