jcombobox

WildCard for Object<String> in Java6

时光总嘲笑我的痴心妄想 提交于 2019-12-12 18:25:27
问题 Please how to correct casting and remove warning [unchecked] unchecked cast required: T found: java.lang.Object from SSCCE import java.awt.*; import javax.swing.*; public class JComboBoxWithWildCard { private JDialog dlg = new JDialog(); private final Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon"); public JComboBoxWithWildCard() { JComboBox comboWithCustomRenderer = new FlexiComboBox<String>( "1 one", "2 two", "3 three", "4 four", "5 five", "6 six", "7 seven", "8 eight", "9 nine",

How to insert items to a jcombobox at runtime and save it

做~自己de王妃 提交于 2019-12-12 15:19:53
问题 I need to save the values in my jcombobox at the runtime. What I am trying to do is after clicking on a button, I am setting it to editable = true. Then type the value in the combobox, but it doesn't save. private void btadbknameActionPerformed(java.awt.event.ActionEvent evt) { if(evt.getSource()== btadbkname){ cb_bkname.setEditable(true); cb_bkname.getText(); cb_bkname.addItem(evt); }else{ cb_bkname.setEditable(false); } } I have already added some elements in it on the designing level, but

How do I get the previous or last item?

天涯浪子 提交于 2019-12-12 12:15:15
问题 How do I get the last or previous or unselected item and then the new item for a JComboBox ? 回答1: I assume this applies to all Objects that allow for which you to add Item Listeners to them. String[] items = {"item 1","item 2"," item 3","item 4"}; JComboBox combo = new JComboBox(items) combo.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent ie) { if(ie.getStateChange() == ItemEvent.DESELECTED) //edit: bracket was missing { System.out.println("Previous item: " + ie

How can I know when the text of an editable JComboBox has been changed?

一个人想着一个人 提交于 2019-12-12 07:09:50
问题 I have an editable JComboBox where I want to take some action whenever the text is changed, either by typing or selection. In this case, the text is a pattern and I want to verify that the pattern is valid and show the matches that result in some test data. Having done the obvious, attach an ActionHandler, I have found that, for typing, the event seems to fire unreliably, at best (selection is fine). And when it does fire as a result of typing, the text retrieved (using getEditor().getItem(),

Table does not update when selecting combobox

不羁岁月 提交于 2019-12-12 06:51:32
问题 My problem is that a JTable does not update when I select my combobox. The program I present below should delete all data ( data = null; ), when LA is selected. The table does not update. public class minimumExample extends JFrame { private JTabbedPane tabbedPane; private FilteredTabPanel filteredTabPanel; public void createTabBar() { tabbedPane = new JTabbedPane(JTabbedPane.TOP); filteredTabPanel = new FilteredTabPanel(); tabbedPane.addTab("Test", filteredTabPanel.createLayout()); add

'SwingUtilities.updateComponentTreeUI(this)' removes custom Document from JComboBox

早过忘川 提交于 2019-12-12 05:18:36
问题 I have an editable JComboBox and JTextField. Both with custom Documents. Here is the code: import java.awt.*; import javax.swing.*; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; public class SwingUtilStrangeBehav extends JFrame { public SwingUtilStrangeBehav() { JComboBox<String> combo = new JComboBox<>(new String[]{"a", "b", "c"}); combo.setEditable(true); ((JTextField)combo.getEditor().getEditorComponent())

Setting a JComboBox editor using TableModelListener

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 05:13:04
问题 I wanted to set my 2nd column as JComboBox editor using TableModelListener . Also wanted to change the Model of ComboBox in 2nd column based on selected ComboBox in 1st column. Here I implemented a Listener that's listen to 1st column. private class TableScheduleListener implements TableModelListener { //Listening for data changes. @Override public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); } if(column == 1) { for(int i = 0; i <

How to retrieve data from MYSQL to combobox in JUNG visualization

有些话、适合烂在心里 提交于 2019-12-12 03:19:50
问题 I am trying to create a JCombobox and retrieving data from the MYSQL database in JUNG visualization platform. I need to know whether i can use the same method to create a JCombo box in JUNG as we created in JAVA swing? I used the following code to create and import the data from the database. But nothing gets displayed. According to the item which is selected from Jcombo box, I've to edit the jung network. Can anyone help me this? private void mouseComboBoxActionPerformed(java.awt.event

Change JCombobox popup width [duplicate]

筅森魡賤 提交于 2019-12-12 02:42:05
问题 This question already has answers here : How can I change the width of a JComboBox dropdown list? (6 answers) Closed 5 years ago . How can I set a fixed width of a JComboboxs popup-menu that is using GridBagLayout and fill=HORIZONTAL ? One of the things I tried is to just override the getSize() method but dose not work. public class ComboBoxSize extends JFrame { public static void main(String args[]) { // THE COMBOBOX String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" };

How to change height of a jpopupmenu in a jcombobox?

百般思念 提交于 2019-12-12 01:44:07
问题 I am working on an application in which I am handling key release event over a editable 'JComboBox', where on every key release a 'JPopupMenu' of the 'JComboBox' appears. I want to increase the height so that user will be able to see more items at a glance without scrolling. Can anyone please demonstrate how to set the height of 'JPopupMenu' deliberately so that it will show considerable amount of items? So far i have tried this, but it doesn not work. combo.getComponentPopupMenu().setSize(10