jcombobox

Return the focus to JComboBox inside a JTable after showOptionDialog

三世轮回 提交于 2019-12-11 02:28:37
问题 I'm having problems with a JComboBox used as a CellEditor for a JTable . I want after editing the JComboBox and pressing tab to show an OptionsDialog and, if a specific option is selected, the focus to remain on the JComboBox . The problem is that the focus moves to the next cell because of tab and I cannot return it to the JComboBox Below is one of my test cases: import java.awt.KeyboardFocusManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing

JComboBox does not behave same as JTextField. How can i have it look similar?

偶尔善良 提交于 2019-12-11 01:35:04
问题 I have this following combo box, where i am able to create my combo box with items etc, but the look is not same as JTextField. How can i make JCombobox look same like JTextField? MyComboBox.java: import java.awt.Color; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.LineBorder; import javax.swing.plaf.basic.BasicComboBoxUI; public class MyComboBox extends JComboBox { public MyComboBox(String[] name) { Border border = BorderFactory.createEmptyBorder(11, 11,

How to limit the editable text in JComboBox?

蹲街弑〆低调 提交于 2019-12-11 00:06:42
问题 I already have this in my jcombobox: myjcombobox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!(Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) { getToolkit().beep(); e.consume(); } } }); This code prevents the writing of any character in the jcombobox besides digits. ONLY DIGITS. But since my jcombobox is editable the user can write several digits and that's

Scala compiler build error JComboBox type parameters

天涯浪子 提交于 2019-12-10 19:11:13
问题 So I'm trying to compile the scala compiler, I've overcome many problems trying to get this done but I am currently stuck at quick.lib This is very confusing as the source is taken directly from the scala team themselves so I know it should compile. Also taken an old version I know compiles elsewhere and tested that but get the same error. Any help on the issue or a point in the right direction would be greatly appreciated. quick.lib: [scalacfork] Compiling 103 files to C:\programming\scala

Java JComboBox Autocomplete [closed]

风格不统一 提交于 2019-12-10 19:05:04
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have an ArrayList of People - which is made up of a Name, email, and a few numbers (however they are all strings). I use this list

Get tooltip from JComboBox Renderer

我的梦境 提交于 2019-12-10 18:18:31
问题 I have a ComboBox renderer that extend JPanel and has two labels. In here i need to show tool-tip when mouse goes to iconLabel only. If mouse is in labelItem tool-tip should not show. import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListCellRenderer; import javax.swing.plaf

Shared data between two comboboxes

冷暖自知 提交于 2019-12-10 17:53:57
问题 I need to share data between two(or maybe more) comboboxes, but I want to choose elements independently. For example, if I choose Object1 in first comboBox, my second ComboBox also chooses Object1, because they have same model(DefaultComboBoxModel and this model also manages chosen objects). But I don't want this behavior. I want to choose objects in my comboBoxes independently. When I choose object in first comboBox my second comboBox shouldn't change. At this moment I'am thinking about

Select all text in editable JComboBox and set cursor position

心不动则不痛 提交于 2019-12-10 14:35:42
问题 public class CursorAtStartFocusListener extends FocusAdapter { @Override public void focusGained(java.awt.event.FocusEvent evt) { Object source = evt.getSource(); if (source instanceof JTextComponent) { JTextComponent comp = (JTextComponent) source; comp.setCaretPosition(0); comp.selectAll(); } } } jComboBox.getEditor().getEditorComponent().addFocusListener(new CursorAtStartFocusListener()); As you see from code above I want to select all text in editable JComboBox and set cursor position to

JCombo AutoComplete - Pattern or Reverse Lookup

不问归期 提交于 2019-12-10 13:26:04
问题 I'm using the auto-complete decorator in the swingx library: AutoCompleteDecorator.decorate( myComboBox ); Which is pretty sweet. However, it only searches forward from the start of the typed text. So if my combo contains: [Apple, Banana, Grape, Orange] typing 'an' in "strict" mode will not show any results. In non-strict mode nothing is searched either. I'd like it to match 'Banana' & 'Orange' since both items contain my typed text. Are there any auto-complete libraries that allow for this

Detecting JComboBox editing

主宰稳场 提交于 2019-12-10 12:45:52
问题 I have a JComboBox, once every second I want to retreive a set of strings from a database and set those strings to the contents of the JComboBox, and one of them as the currently selected value. But I also want the user to be able to edit the JComboBox and add a value to the database and set it as the current value. I want to the be able to detect when characters are entered into the JComboBox, so I can reset a count down which prevents updating the JComboBox as long as it's not zero. My