Date: Mon, 14 Jan 2002 12:36:16 -0800 To: [EMAIL PROTECTED] From: Dmitry Beransky <[EMAIL PROTECTED]> Subject: Re: combo box vs "Java Applet Window"
This happens, because the popup is created as a lightweight component and lightweight components cannot be drawn outside of their parent window's client area. When the list is long enough, the combo box code properly realizes that and creates a heavyweight popup instead. My guess is that there is a bug in JComboBox's code responsible for deciding when to create a heavy-weight popup. A work around would be to force the component always to use the heavyweight popup by setting the lightWeightPopupEnabled property to false. Actually, I just realized that this may not work, because showInputDialog uses a JDialog for display, and the docs for JDialog's main constructor state: NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) created within a modal dialog will be forced to be lightweight. I've tried to determine where the creation of JComboBox comes in the execution of JOptionPane.showInputDialog, and the whole thing is mysterious. The code for showInputDialog is: public static Object showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue) { JOptionPane pane = new JOptionPane(message, messageType, OK_CANCEL_OPTION, icon, null, null); pane.setWantsInput(true); pane.setSelectionValues(selectionValues); pane.setInitialSelectionValue(initialSelectionValue); JDialog dialog = pane.createDialog(parentComponent, title); pane.selectInitialValue(); dialog.show(); Object value = pane.getInputValue(); if(value == UNINITIALIZED_VALUE) return null; return value; } The only line I can imagine leads to creating the JComboBox is: pane.setSelectionValues(selectionValues); but setSelectionValues is just: public void setSelectionValues(Object[] newValues) { Object[] oldValues = selectionValues; selectionValues = newValues; firePropertyChange(SELECTION_VALUES_PROPERTY, oldValues, newValues); if(selectionValues != null) setWantsInput(true); } Maybe some property listener reacts to firePropertyChange to make the JComboBox, but this would be a very strange way to produce the input dialog, and, at any rate, I cannot trace it. Does anybody know how it is that a JComboBox comes to be used by showInputDialog? Thanks! kj _______________________________________________ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing