Does Google suggest using Java SWT?

I want a ComboBox dropdown, for example Google Search (i.e. when we enter one letter, then elements starting with this letter are displayed). When the drop-down list appears, we can choose one of the words as our text field value.

Can I do this in SWT?

comboLabel.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { ArrayList<String> listElements = new ArrayList<String>(); // on pressing down arrow list gets expanded ie list drops down if(e.keyCode == 16777218) { comboLabel.setListVisible(true); } // if key pressed is only a number of charecter or space. else if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 97 && e.keyCode <= 122) || e.keyCode == 32) { // for removing all previously assigned labels comboLabel.remove(0,comboLabel.getItemCount()-1); listElements = labels.getLabels(comboLabel.getText()); } for (int i=0; i<listElements.size();i++) { comboLabel.add(listElements.get(i),i); } } }); 
+4
source share
3 answers

What you mean is the ComboBox auto suggestion. As far as I know, it is not available in any standard Java widget library. However, many people have created their own component for automatic creation. Here is a good example with source and executable .jnlp extensions.

+2
source

I don’t think there is anything like that in SWT. SWT widgets must match their own widgets on all platforms (as a rule), so it would be difficult to implement something like this. One place to look for SWT Widgets that are new or experimental is the Nebula project, but I don't see it either.

+2
source

should not be difficult. Just take a List where all your search strings are, and then do some regular expressions or indexOf or Collections.binarySearch objects, etc. Then draw a list in the text box with all the options. I can write you an example. What type of search data?

0
source

Source: https://habr.com/ru/post/1388712/


All Articles