jcombobox

JComboBox change shapes and colors

纵饮孤独 提交于 2019-12-25 03:48:23
问题 Right now I have a program that can move a rectangle left and right. I would like to make a JComboBox to change the shape and color of the object. public class DrawShapes extends JFrame{ //code private CanvasDrawArea canvas; // the custom drawing canvas (extends JPanel) /** Constructor to set up the GUI */ public DrawShapes() { // Panel for JComboBox and buttons JPanel btnPanel = new JPanel(new FlowLayout()); JComboBox shapes = new JComboBox(shapeName); btnPanel.add(shapes); //code for left

How do I populate a jcombobox with information from a mySQL database?

六月ゝ 毕业季﹏ 提交于 2019-12-25 03:37:29
问题 Basically the program takes customer information and dumps it in a database. In order to change information I want the user to be able to pick a customer name from a combobox, so the system can then call all the info out of the database on that customer. Accessing the database is fine, putting info in and changing it is fine.. I just cant figure out how to get the combobox to populate with all the customer names. 回答1: The simplest solution is to create an array of String from the database.

JCombobox is not displayed

半世苍凉 提交于 2019-12-25 02:52:15
问题 I am using the following code to display the particular user's details by using JCombobox to select his username from the database. The combo box is to list the user names from the table. But the combo box is not visible when i run the code. (no error though). It would be helpful if someone tell whats wrong with code. Thanks in advance. public class EmpSearchApp extends JFrame implements ActionListener { JLabel l, l1, l2, l3, l4, l5, l6, l7, l8; JButton b; JTextField tf1, tf2, tf3, tf4, tf5,

Get input text without scanner

孤街浪徒 提交于 2019-12-24 21:45:58
问题 I work on a school project and I am now wondering if it is possible to get text from JTextField with get? // Textrutor JTextField textTitel = new JTextField(null, 20); textTitel.setToolTipText("ex. Flickan som lekte med elden"); JTextField textSort = new JTextField(null, 10); textSort.setToolTipText("ex. Skräck, Action"); JTextField textDesc = new JTextField(null, 15); textDesc.setToolTipText("ex. Stieg Larsson"); // Knappar JButton addButton = new JButton("Lägg till"); // Combobox JComboBox

JTable alway can not get correct rowIndex for inner ComboBox

删除回忆录丶 提交于 2019-12-24 14:17:01
问题 I have a JTable which its one column cell is JComboBox . But when try to get row count when click the table JComboBox cell, I found the row index always return error value (alway is the last click row index). public class TableComboBoxTest extends JFrame { private JTable table; private DefaultTableModel tableModel; private Object[][] tableCells; private final String[] TABLE_COLUMNS = {"No.1"}; private final String[] YES_NO_SELECTION = {"Yes", "No"}; public TableComboBoxTest() { Container pane

Editing item in JCombobox dynamically

二次信任 提交于 2019-12-24 12:33:41
问题 I have a small problem here. I have a Swing UI with many non editable JComboBoxes. Each of the JComboBoxes are populated from a specific table from a database. The user can edit the content of each table, and what I would like to do is to update the JComboBoxes in the main JFrame according to the action (add/remove/edit) the user just did in these tables. For adding and removing items, no problem, I add or remove that item from the related JComboBoxes model and everything goes fine. But for

Need to add JCheckBox In JTable Dynamically

陌路散爱 提交于 2019-12-24 02:31:18
问题 I have two JTable . There are certain number of records in one JTable . Once the first JTable is loaded I want to load equal number of JCheckbox to be created in the second table. I have this scenario ... vl pass both the tables in method addCheckBox . private void addCheckBox(JTable procTableSrc, JTable procTableCk){ CheckBoxRenderer checkBoxRenderer = new CheckBoxRenderer(); EachRowRenderer rowRenderer = new EachRowRenderer(); int rows = procTableSrc.getRowCount(); DefaultTableModel dm =

JTable JComboBox wrong first item name

穿精又带淫゛_ 提交于 2019-12-23 20:15:25
问题 I added a Swing JComboBox to a JTable , but the label of my first item is always javax.swing.JComboBox(... What am I doing wrong? UPDATE : this is my code : import java.awt.Color; import java.awt.Dimension; import java.util.ArrayList; import javax.swing.DefaultCellEditor; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.ListSelectionModel;

How to put a JButton inside a JComboBox

杀马特。学长 韩版系。学妹 提交于 2019-12-23 20:09:38
问题 I would like to put a JButton inside a JComboBox. This button lets users browse for files. The file the user selects gets added to the JComboBox list. How do I do this? Do I use some kind of a Renderer? Thank you. EDIT: After reading more about ListCellRenderer I tried the following code: JComboBox comboBox = new JComboBox(new String[]{"", "Item1", "Item2"}); ComboBoxRenderer renderer = new ComboBoxRenderer(); comboBox.setRenderer(renderer); class ComboBoxRenderer implements ListCellRenderer

JCombobox arrow disappears

强颜欢笑 提交于 2019-12-23 13:24:22
问题 When the fill combobox in a method which is not placed in the constructor, the arrow of combobox disappears. I tried with the invokeLater method, but it did not work. private void fillProduct(){ this.VALID_FOR_PRODUCT.removeAllItems(); this.VALID_FOR_PRODUCT.addItem(new JChooseItem("ALL", "Any")); for(Product product : Product.values()){ this.VALID_FOR_PRODUCT.addItem(new JChooseItem(product.getName(), langHelper.getTrans(product.getTranslationKey()))); } } 回答1: I had the same issue, it