1
I’m using a free design in my project and dragging to my jFrame the components I want. However, I needed to use a jComboBox with autocomplete and guided by this site. Now I wanted to use the class 'Autocompletejcombobox' and apply it to a jCombobox that I dragged into my frame. This is possible?
I tried to put this part of the code in the constructor:
List<String> myWords = new ArrayList<>();
myWords.add("bike");
myWords.add("car");
myWords.add("cap");
myWords.add("cape");
myWords.add("canadian");
myWords.add("caprecious");
myWords.add("catepult");
StringSearchable searchable = new StringSearchable(myWords);
AutocompleteJComboBox combo = new AutocompleteJComboBox(searchable);
//combo.setBounds(600, 200, 100, 25);
jPanel3.add(combo);
The point is that I didn’t want to be using the setBounds method because it’s complicated to be looking for the best position and size for jComboBox. If you do not use this method, the combo does not appear in my jPanel that I want.
Any suggestions on how to apply this autocomplete to a jComboBox that I dragged to my jFrame?
You could show the creation and initialization of your jPanel3?
– Math
The point is, I didn’t boot anything, I just created new jForm and I’m dragging the components into the design
– Hugo Machado
Right, right. But show more of your code, especially everything that involves the variable
jPanel3
.– Math
I’m not using jPanel3 anywhere in the code :s I just tried to add it but it didn’t work :s
– Hugo Machado
The solution to your problem (probably) boils down to one thing: the proper choice of a Layout Manager. But to be perfectly honest, I don’t think I quite understand your problem. Do you know how to use Lms? Do you know what you’re using? Your question is
Como adicionar uma JComboBox em um JPanel sem usar o setBounds()?
?– Math
I’ve never worked much with the netbeans swing, and I’m not really into the Layoutmanagers. But in short yes, I want to put a Jcombobox on my jPanel3 without being by setBounds
– Hugo Machado