jcombobox

Having several JComboBoxes with different values in a JTable

给你一囗甜甜゛ 提交于 2019-12-02 05:29:43
I want to create a JTable where in a specific column named "Tools" a JComboBox should be accommodated. the values of the JComboBox should differ for each row. In the constructor I have the following piece of code: public Table(List<Software> software_list) throws TransformerFactoryConfigurationError, TransformerException, Exception { //****** create an 2D array object containing the emulators list data to be sent to the table model ****** software_list_to_array = new Object[software_list.size()][5]; for(int x = 0; x < software_list_to_array.length; x++){ software_list_to_array[x][0] = software

Java Swing, JComboBox drop down list change listener before clicking

北战南征 提交于 2019-12-02 05:11:41
问题 I have a JComboBox which has a list of midi files, I wonder if the following is doable : when I click on the JComboBox, a drop down list opens up, when I move the mouse on to a midi file, it plays a 10 second sample sound, so I know what the file contains before I click and select that file , so if I have 50 midi files, I can open the list and move the mouse up and down the list without clicking on it, but still play the 10 second samples from the file the mouse points to, then after I decide

Alter JComboBox popup size without disturbing Look and Feel?

房东的猫 提交于 2019-12-02 03:53:25
I'm looking for a way to alter the width of a JComboBox's popup. Basically, the popup should be as wide as the widest combobox entry requires, not as wide as the combobox currently is. The only way I know how to achieve this is creating a custom instance of ComboBoxUI and set that on the JComboBox (Example code demonstrates the goal: Top Combobox shows wide popup, Bottom is the default behavior). However since this replaces the UI of the ComboBox, it may look odd on some L&F's (For example with WinXP Luna theme the ComboBox looks like Classic theme). Is there a way to achieve this behavior in

Share data source for two comboboxes

老子叫甜甜 提交于 2019-12-02 03:24:00
I have multiple comboboxes in my GUI which all need to have the data. This data will change at random so a quick way to keep all values synced is needed. I encountered DefaultComboBoxModel which actually fits quite perfect. Only thing is, that I need the comboboxes to be independent of each other - meaning: if I select a value on one, all others shouldn't change. I've done a bit of research and read the standard java tutorials but none tell me really how to achieve this with the DefaultComboBoxModel. This example here exactly illustrates what I need: Sharing the Data Model between two

Set Value and Label to JComboBox

醉酒当歌 提交于 2019-12-02 03:05:01
问题 I have a JComboBox where the items are the results of a query. The combo shows all the categories names taken from a query, right? Ok, it works. Now I need to give each item a value, which would be the ID of the product. This is what I've got so far: final JComboBox proveedorCombo = new JComboBox(); contentPanel.add(proveedorCombo); ProveedorDAO dao = new ProveedorDAO(); List<Proveedor> proveedor = dao.getAll(); Object[][] elementos = new Object[proveedor.size()][2]; for (int i = 0; i <

Immediate update to JCombobox in Java

不问归期 提交于 2019-12-02 02:48:43
A person wishes to add a NEW Job to the database. A Combobox list the existing employers already in the database for the new Job to be added against. But if an employer is not present customers have the option click on a button to add an employer. Once added that employer should immediately be displayed in the textfield. I am trying to achieve the above scenario with my coding and mysql database, but cant think of the logic to do so... Table Employer CREATE TABLE "Employer" ("employerID" INTEGER PRIMARY KEY NOT NULL , "name" CHAR, "industry" CHAR, "contact1" CHAR, "contact2" CHAR, "email" CHAR

JComboBox only show one item from database

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 00:43:12
I'm trying to display database item into a JComboBox and this is my code. public static void checkItemName(){ Connection conn = SQLite.SQLite(); String sql = "select itemname from item"; try{ Statement statement = conn.createStatement(); ResultSet resultSet = statement.executeQuery(sql); while (resultSet.next()){ String list = resultSet.getString("itemname"); purcItemName.addItem(list); conn.close(); } } catch (SQLException lol){ System.out.println(lol.toString()); } } I did declare static JComboBox purcItemName; and purcItemName = new JComboBox(); The method/function will be called then user

Set Value and Label to JComboBox

匆匆过客 提交于 2019-12-02 00:31:10
I have a JComboBox where the items are the results of a query. The combo shows all the categories names taken from a query, right? Ok, it works. Now I need to give each item a value, which would be the ID of the product. This is what I've got so far: final JComboBox proveedorCombo = new JComboBox(); contentPanel.add(proveedorCombo); ProveedorDAO dao = new ProveedorDAO(); List<Proveedor> proveedor = dao.getAll(); Object[][] elementos = new Object[proveedor.size()][2]; for (int i = 0; i < proveedor.size(); i++) { Proveedor p = proveedor.get(i); elementos[i][0] = p.getId(); elementos[i][1] = p

JScrollPane on JComboBox

倾然丶 夕夏残阳落幕 提交于 2019-12-02 00:25:13
问题 I made a combobox but some of the elements are wider than the width of my box. So I tried to add a horizontal scrolpane and the only I could see is a scrolpane with a combobox inside! Certanly something I do wrong. So here is my code without the jscrolpane. issuerdocumentJComboBox=new JComboBox<>(issuermodel);//the compo box issuerdocumentJComboBox.setBounds(430, 120, 100, 30); searchDocumentesJPanel.add(issuerdocumentJComboBox); How can I add to the combobox a horizontal scrollpane? Thank

JScrollPane on JComboBox

有些话、适合烂在心里 提交于 2019-12-01 22:44:31
I made a combobox but some of the elements are wider than the width of my box. So I tried to add a horizontal scrolpane and the only I could see is a scrolpane with a combobox inside! Certanly something I do wrong. So here is my code without the jscrolpane. issuerdocumentJComboBox=new JComboBox<>(issuermodel);//the compo box issuerdocumentJComboBox.setBounds(430, 120, 100, 30); searchDocumentesJPanel.add(issuerdocumentJComboBox); How can I add to the combobox a horizontal scrollpane? Thank you! It is possible!! Here's a little program I wrote to show my solution: import java.awt.Component;