jcombobox

How do I add a different JComboBox to each JTree node?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 12:12:08
问题 I have a JTree that I'm filling with skills for a Game Database programme that I'm writing. There are several categories, and subcategories (actual skills), and then levels skill below that (sometimes). Currently I'm emulating this with one skill class, some options inside, and a few enums, plus a method to check that if the skill is a category (called isCategory). Two other things to note: Different types of skill behave differently. Some are bought once, other several times, some have

JCombobox, Editor and Renderer related

孤街浪徒 提交于 2019-12-10 11:56:19
问题 As a JCombobox ListCellRenderer, I have a class like this one: class ZComboBoxRenderer extends JPanel implements ListCellRenderer{ private ZGrid grid; public ZComboBoxRenderer(ZGrid grid) { setLayout(new BorderLayout()); this.grid = grid; add(new JScrollPane(grid), BorderLayout.CENTER); } public ZGrid getGrid(){ return grid; } @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { grid.fetchSQL(); return this; }

Customizing JComboBox: “infinite loops event” when LAF is system LAF

余生颓废 提交于 2019-12-10 11:16:13
问题 I customize my JComboBox as follow. The program ran ok with default LAF, but whenever i changed the LAF to System LAF (another LAF, Nimbus, is ok), there was an infinite loop after the button was clicked. I saw that the actionPerformed method was called infinitely. Please help me solving this problem. I use jdk 1.6.0_33 I'm so sorry if there is any unclear mean. My English is not good Thanks in advance. package sig.dw.ui; import java.awt.Component; import java.awt.FlowLayout; import java.awt

JComboBox search list

你。 提交于 2019-12-10 10:29:53
问题 I w'd like make a JComboBox that contents could be searchable. I tried AutoCompleteDecorator, GlazedLists, SwingLabs, JIDE, Laf-Widget , but all of the cannot search by second keyword. For example, in this code possible search by 1st letter and this content includes just one word. this.comboBox = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); AutoCompleteDecorator.decorate(this.comboBox); If JComboBox content consists 2 or 3 words, for example: "Ester Jordi" or

How to get value that has been written in editable JComboBox?

故事扮演 提交于 2019-12-10 02:23:28
问题 I keep searching and it seems like everybody is using only the JComboBox#getSelectedItem . But my combo box is editable and the user can enter anything . The getSelectedItem method returns one of the actual items in the combo box, not a string entered in the field. If my box contains "Bar" and "Item" and user enters "Foo", I want to get "Foo"! Why getSelectedItem does not work It was pointed out that getSelectedItem does also return the string entered. It was not pointed out though, that this

Adding JCombobox in Jtable and Getting that Row and Column in Swing java

浪尽此生 提交于 2019-12-09 19:14:00
问题 I have One Jtable in which i have added JComobox like this. TableColumn sportColumn = jTable1.getColumnModel().getColumn(2); comboBox = new JComboBox(); comboBox.addItem("Snowboarding"); comboBox.addItem("Rowing"); comboBox.addItem("Chasing toddlers"); comboBox.addItem("Speed reading"); comboBox.addItem("Teaching high school"); comboBox.addItem("None"); sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); and i have added one mouse event of jtable like this. private void

How to add a drop down menu to a JTable cell

给你一囗甜甜゛ 提交于 2019-12-09 08:12:15
问题 This may be a question asked before. I searched a lot before posting here, but couldn't figure out any acceptable one. Can some one show me a way how to do this. I simply need to get a drop down menu when i click on the cell so that I'll have to select a value from that (as a way to restrict the user selection). If some one can help with this I believe it will help a lot of people out there. There are a lots of questions similar to this but no any clear answer. Please answer with a bit more

Accessing JComboBox data from separate JForm

南楼画角 提交于 2019-12-09 03:36:09
问题 I've spent a bit of time browsing Stack Overflow and the internet looking for the answer to my question, but I found all the answers hard to understand and I was quite unsure if any of them related to my problem, so I decided I needed help in the right context. I am creating a program that will give a series of solutions based on a particular type of graph inputted. I am sincerely struggling with taking the data from my JComboBox in the first JFrame, and displaying it in the second. I have

Hide JComBox Box Arrow

南楼画角 提交于 2019-12-08 19:16:40
问题 Is it possible to hide the arrow displayed in the JComboBox I tried setting: combo.getComponent(0).setSize(new Dimension(1,1)); But it doesnt seem to work 回答1: You have to create a new combobox UI for that: combo.setUI(new BasicComboBoxUI() { protected JButton createArrowButton() { return new JButton() { public int getWidth() { return 0; } }; } }); But be careful to inherited from the base UI which matches your current look and feel. For example if you are using Substance you should derive

JComboBox on a JPopupMenu

Deadly 提交于 2019-12-08 18:43:28
问题 I'm trying to use a compound Swing component as part of a Menu. Everything works just fine, apart from one detail: The component contains JComboBox es and whenever the user clicks on one of them to open its dropdown, the dropdown opens but the menu disappears. Is it possible to make the menu stay open when a JComboBox is clicked? I sub-classed JMenu . This is the corresponding code: public class FilterMenu extends JMenu { public FilterMenu(String name) { super(name); final JPopupMenu pm =