How to check if the SWT combo is currently opened? - java

I have an SWT combo box in my GUI. Is it possible to check if the combo box has been opened?
(I've a mechanism which refreshes the state shown in the combo box, when a user opens it sometimes it jumps between user selection and that what the algorithm thinks is fine, the user selection has a priority over everything else).

Combo SWT component have method getListVisible() which returns flag if combo dropdown list part is visible or not.. see documentation for combo for details.

The response of Sorceror is about org.eclipse.swt.widgets.Combo
If you need this method on javax.swing.JComboBox you can use isPopupVisible()

Related

How to open Combo Box popup in javafx

I want to show combo box popup while click or hover on any label(component) instade of combo box and I don't know how to trigger combo box popup panel.
comboBox.show()
Requests that the ComboBox display the popup aspect of the user interface. As mentioned in the ComboBoxBase class javadoc, what is actually shown when this method is called is undefined, but commonly it is some form of popup or dialog window.

Using Button Groups to Make Checkboxes Unselectables

I have checkboxes. I have a buttongroup. When I click on the option "All Checkboxes," I want all checkboxes in the button group to be made unselectable (grayed out) (Except the "All Checkboxes" one which is selected.) How do I this?
Also, how can I add an item/set the items to a Combo Box using NetBeans?
I have checkboxes. I have a buttongroup. When I click on the option "All Checkboxes," I want all checkboxes in the button group to be made unselectable (grayed out) (Except the "All Checkboxes" one which is selected.) How do I this?
A ButtonGroup cannot be used to grey-out (functionally and visibly disable) a JCheckBox. Better to put them in a List<JCheckBox> and in the ActionListener for "All CheckBoxes" iterate through calling setEnabled(true/false) on the items in the list, the parameter depending on the state of the "All Checkboxes" JCheckBox.
Also, how can I add an item/set the items to a Combo Box using NetBeans?
I have no idea how to do this "using NetBeans", but using Swing you simply get the JComboBox's model, usually a DefaultComboBoxModel, and add items to it.
Also, how can I add an item/set the items to a Combo Box using NetBeans?
Just like you would with Swing normally, comboBox.setModel(comboBoxModel). Don't rely on the form editor to do it for you. Somethings you just have to get your hands dirty with.

Edit Popup Dialog from AutoComplete SWT Combo Widget

im trying to edit the Popup which displays when i type something in my Combo. I tried to extend the ContentProposalAdapter, but it seems more complicated i needed...I want to display a Table instead of a simple String list in the Popup, so is there any chance to do this or do i have to write my own ContentProposalAdapter :/
I solved it after watching into the SWT Snippets from http://www.eclipse.org/swt/snippets/. I just write my own class who takes an SWT Text and add some Listeners, a ModifyListener opens a new Dialog (without any button or something else). The dialog holds a TableViewer and ViewFilter

How to update the list of items in the SWT Combo box?

I have a UI with a Combo box. The list of items, which can be chosen, has to be refreshed every time the combo is about to open the list.
Is there any way - i.e. to add a listener which will inform UI that Combo is about to open?
Unfortunately I am not able to observe model to update the list when it changes.
Unfortunatelly there is no such method for SWT Components. In Swing it would be easy with the help of the PopupMenuListener Interface.
A workaround I can think of would be to implement a MouseListener and a KeyboardListener (As Comboboxes can be opened by pressing 'space') so you can at least update your Combobox List when those two Events take place.

Java ComboBox What controls where list will display?

Possibly an odd question but how can I change how my Java Swing combo box displays its list of items? The default behavior is for the list to be displayed below the combo box. There are times, when the combo box is low on the screen, that the list is displayed above the combo box. Is there a way to force it to always display above? What if I wanted the list to "pop out" and float above the form displaying larger than the normal size? Are these things possible?
Thanks
ST
The display location and size of the popup is not decided by the JComboBox itself, but by the installed look & feel. You can either provide your own look & feel or wrap the currently installed one by overriding javax.swing.plaf.basic.BasicComboBoxUI#createPopup() to provide your own implementation of javax.swing.plaf.basic.BasicComboPopup#getPopupLocation() and javax.swing.plaf.basic.BasicComboPopup#computePopupBounds().

Categories