I have a CheckComboBox that I populate with data I grab from a website with the following method.
public void getCompanies() {
// This method is called every time the user types a letter in the URLText box.
// Grab data from the website and add the data to a list.
HTMLParser p = new HTMLParser(URLText.getText());
List<String> a = p.GetCompanyNames();
// Remove old data so new data can be added.
dropdownMultiple.getItems().remove(0, dropdownMultiple.getItems().size());
for(String element : a) {
dropdownMultiple.getItems().add(element);
}
}
This works just fine but I would like to have the CheckComboBox open the dropdown whenever this method is called. I have a textbox overlayed on top of the CheckComboBox so the user can't click on it. Ultimately I want it to look like an autocomplete dropdown that will dropdown whenever the user types in the text box.
In other words, how can I activate the dropdown event of the CheckComboBox without having the user click on it?
I'm assuming you're talking about org.controlsfx.control.CheckComboBox. Unfortunately, it does not appear the library provides a way to programatically show the popup. But if you don't mind relying on implementation details there is a way to do what you want.
The CheckComboBox's skin uses a JavaFX ComboBox internally. This latter class has a method named show that can be used to manually display the popup. You can get access to this ComboBox via a call to Node.lookup(String).
CheckComboBox<String> box = new CheckComboBox<>();
((ComboBox<?>) box.lookup(".combo-box")).show();
Note: This requires that the CheckComboBox is being displayed in a window.
As a reminder, this deals with implementation details and can therefore break without notice. From looking at the source code this should work for both ControlsFX 8.40.14 and 9.0.0.
Related
I have a list of items within a drop down on Gsheets.
I'd the default to be blank, and if another cell says 'Pending', I'd like the dropdown to automatically also say 'Pending'.
I'd also then like the user to be able to change the item with another option in the list.
I've tried choosing a data range with the function under data validation.
Basically I'd like the dropdown choices to be:
=IF(A2="Pending", "Pending", "")
In Progress
Done
Is this possible within Gsheets, or even using App Script?
I'd like the cell to default to blank, then change to pending based off another cell saying pending.
At the moment it doesn't seem to be dynamic in the sense that it updates when the chosen cell says Pending.
How do I disable input on my editable Combobox? (Well, actually JFoenix JFXCombobox but it's basically the same apart from it's appearance)
setEditable(false) would disable keyboard input on the Combobox but the list would still appear
setDisabled(true) would disable whole Combobox but I want user to be able to focus Combobox so he can copy it's contents if necessery.
Why do I want it like that? In my forms user must first click edit button to be able to change stuff.
Basically, the method ComboBox.setEditable adds/removes an Editor to the ComboBox which can be retrieved via ComboBox.getEditor()
To keep the TextField (to copy from) but disable user-input, simply set the editable flag on the underlying TextField:
private ComboBox<String> myComboBox;
[...]
myComboBox.setEditable(true);
myComboBox.getEditor().setEditable(false);
EDIT:
As #jewelsea said in a comment below, you can hide the list as soon as the user requests to open it:
myComboBox.setOnShown(event -> comboBox.hide());
I think it would be "cleaner" to disable the button which opens the dropdown but unfortunately I have not yet found a way to do that.
I am writing a program in Htmunit where I need to fill in two fields with text, but to get to these fields I need to click on a button to allow for the fields to appear on the screen. I cannot create a new button and click it because that will return a new "page" which I do not want. What other way is there to click on a button without creating a new page, but rather stay on the same page. For reference, I am using this website. The page I need to do this on is the page after the terms acceptance page. I need to click on "foreclosure search", then enter information to the fields.
I am looking for a way to create a popup dialog box when a user double clicks a textinput field that will contain a scroll-able list (from database table) where the user can select a field, hit ok, and have it placed into the textbox when popup closes.
The other major requirement is to have a filter/ or search field in the popup to aid the user in finding the correct option to select from quicker.
What is the best way to implement this?
Modification to gwt's popup panel? maybe a JOptionPane? are there any simple solutions already designed for free commercial use?
You could implement this with a com.google.gwt.user.client.ui.PopupPanel. You can make a PopupPanel that contains a ListBox with your data from the database, along with a OK button. When a user selects a value and hits OK, you should utilize an EventBus along with a custom Event that will pass the value to the field on the page. The page will have an event handler that will catch the event and put it into the field.
Another option is to use a com.google.gwt.user.client.ui.SuggestBox. It is a box that autocompletes / suggests values as you type, kind of like the Youtube search bar.
I can offer more resources to help you accomplish this, if you'd like.
I am working with java applets inorder to embed this applet into one web page. In this applet i used a Choice class to show dropdown list. I know ItemListener helps to know which item is selected once we select an item but Is this possible to know which item has the foucs currently??. i.e, i used the following code
choice = new Choice();
choice.addItem("");
choice.addItem("Choice1");
choice.addItem("Choice 2");
choice.addItem("Choice 3");
Now if i place cursor on choice2 instead of click on it,it has to perform some action. What are the ways to do this?
If I understand your question correctly, you want to add an ItemListener. After you do that, the item listener will be called when something is selected by user input, and then you can take the appropriate action.
One question though, is there a particular reason you're using awt instead of swing?