Thanks for reply
but this what i want to do:
When a key is pressed in an editable combobox, I want the popup menu of the jcombobox to appear automatically, and get the text written in it, but when I changed the icon of the arrow button,the icon changed but the popup menu doesn't appear when key is pressed.
When I tried to do this in Windows look and feel, it worked fine without any problems, but in Synth look and feel, it didn't work. I searched for two days but I couldn't solve the problem.
I tried to use document listener but nothing changed or i didnt use it correctly
I hope my problem is clarified this time
JTextField editor;
.
.
.
editor = (JTextField) jComboBox1.getEditor().getEditorComponent();
\\
editor.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (jComboBox1.isDisplayable())
{
jComboBox1.setPopupVisible(true);
}
System.out.println(editor.getText());
}
});
\\ change arrowbutton icon
jComboBox1.setUI(new SynthComboBoxUI() {
@Override
protected JButton createArrowButton() {
JButton btn = new JButton();
btn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/error3.png")));
return btn;
}
});
don't use KeyListener , use DocumentFilter for filtering unwanted chars or DocumentListener
JTextComponents returns Document (derived JTextField
or JFormattedTextField
from JComboBox
/ JSpinner
)
put Icon to the definitions saved into xml file
for Synt
, you can to test that by derive SynthButtonUI from JComboBOx
from Synth L&F to use Nimbus
use Custom Look and Feel , part of them override methods from BasicXxxUI
directly
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.