Collabora Logo - Click/tap to navigate to the Collabora website homepage
We're hiring!
*

Java jcombobox get selected item index

Daniel Stone avatar

Java jcombobox get selected item index. I just need it to where when I press a button, it prints out every option in the JComboBox. JCheckBox check = new JCheckBox("Approve"); check. Means you don't get type checking provided by generics at compile time. I know how to print out whatever item is selected. 0. String item = jcombox. JComboBox がリ ストにない項目の選択を許可する場合、その結果が常に定義されるとは限りませ ん。 項目が選択されていない場合、またはユーザーがリストにない項目を指定し た場合は、-1 が返されます。 May 12, 2012 · If you want to be able to add and remove items from an existing combo box at runtime, the underlying data model for the combo box needs to be a MutableComboBoxModel. Team_ComboBox = Team_ComboBox; } } Now you can create the class main_menuhandler via the constructor and add the combobox to it. setModel(myModel) to set it. Back to JComboBox ↑; Question. addItemListener ( ItemListener l) : adds a ItemListener to JComboBox. December 1, 2011. println ("Index of item: "+jComboBox_BatteryChooser. Paso 3: Seleccionar un item en el JComboBox. getSelectedItem(); // get the selected item as an index: int selectedIndex = jobList. Try the following. The vector and combobox will both have the same number of items so id of item 10 in combobox will be item 10 in vector. The user can select a value from the drop-down list, which appears at the user's request. getModel(). getSelectedItem() method, but I don't need that, I need the ID, how can I get it to create the object "a"? Apr 27, 2019 · Below is the GUI. Object selectedValue = chooser. This is the code that I use to add Item in JComboBox: Sep 3, 2017 · Preamble: Please, please, please respect the Java naming conventions. In this example we set the JComboBox component so that user can enter their own value. The comboBox is only used to edit the cell. kodejava. out. The combo box is only active when the cell is being edited at which time its selected state is based on the data obtained from the TableModel. Mar 3, 2013 · Can anyone tell me how to get the selected item of a ComboBox to a string variable? string selected = cmbbox. By combining existing answers ( this one and this one) the proper type safe way to add an ArrayList to a JComboBox is the following: private DefaultComboBoxModel<YourClass> getComboBoxModel(List<YourClass> yourClassList) {. Array code: Oct 20, 2012 · comboBox. JComboBox is not required, so feel free to suggest a different component if it is a better choice for this task. toString(i); jComboBox1. getSelectedItem() returns a value that is wrapped by Object type so you have to cast it accordingly. E. I assume that you're clear on how to use a When you call comboBoxMonth. But I want the ID field to insert (as a foreign key) in another table. getSelectedItem()); 0. The program reformats the current date and time. package org. setName(""); For example, insert it like so in your code: public Dropdown(String selected) {. private int selectedIndex = -1; @Override. then you can get the id of item currently selected on combobox from the vector like vectorIDs. I must use selected Index method as a part of the assignment. addActionListener(new ActionListener() {. So my question is how would one populate the JComboBox so as to limit cluttering code. java: Feb 20, 2016 · private class main_menuhandler implements ActionListener {. Jul 11, 2011 · The answer really depends on what kind of items you placed into the JComboBox to begin with. java file: cbinv = new JComboBox<>(); cbinv. Check the case of things, I notice that you say the fx:id is sample, yet in your code you use Sample - and the cases must match otherwise Dec 2, 2012 · Select an item from com2. If it is not an existing item, then you'll get a String object. WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 11. getSelectedItem()); // data for each item. And this question, although very helpful, didn't provide the solution I needed. Oct 26, 2010 · 1. A ServerSocke Java Swing How to - Set selected item in JComboBox by index. HCM"); Lớp JComboBox trong Java Swing là một thành phần mà kết hợp một button, một trường có thể chỉnh sửa và một drop-down list. == compares Object reference. getSelectedItem()); // Internally calls parseInt, returns Integer Jun 1, 2015 · i have ComboBox cbx and a TabPane Contains Tabs (tab: t) and a button b1. getSelectedItem(). When the user changes a value AND presses [ENTER], the old value is removed and the new one is added. I want to be able to get the the selected name in the JComboBox and print it to a text file. return "custom label text " + value. If the thing you have in your Model is other than a String, then you need to cast it to the appropriate class, and then use the toString() method of that object. ) I'm basically using a decorator pattern here, instead of doing something Oct 31, 2013 · What I'm trying to do here is to set a label and a value to each item. getSelectedItem(); 1) Neither Combotext nor ComboText matches common Java nomenclature. I would like to populate the list and keep the program clean and tidy. addItemListener(new ItemListener() {. getSelectedItem (). getSource(); // Print the selected items and the action command. toString(); edited Dec 29, 2015 at 18:57. The combo box item is selected when the cell starts editing. addElement("TP. 1. May 25, 2012 · 5. public void actionPerformed(ActionEvent evt) {. Sep 12, 2008 · I was recently looking for this very same solution and managed to find a simple one without assigning specific variables for the last selected item and the new selected item. Just store an object in the ComboBox that has a toString() output that matches your current displayed value and a direct reference to the object in the array. ) before its visible: final JComboBox date1 = new JComboBox(date); date1. If I add some items in the database directly, I want those newly added items shown in the combo box Jul 27, 2016 · I modified this JavaFX fxml combo box selection demonstration app to add a button with an onAction method to retrieve a value from the combo box using the comboBox getValue() method and it worked fine for me. // // In this example we just place the items inside a How do I get the last or previous or unselected item and then the new item for a JComboBox? Java JComboBox Select Last Value. Click the Launch button to run the ComboBox2 Demo using Java™ Web Start ( download JDK 7 or later ). println("selected item:"+cb. Otherwise you'll get whatever object you populated the combo box with. After that I wat to set selected Item of this JComboBox but I'm not able to do this. setSelectedItem(null) GradeLevelDaoImpl gldi = new GradeLevelDaoImpl(); DefaultComboBoxModel gradeLevelModel = new DefaultComboBoxModel(gldi Mar 13, 2018 · 1. initComponents(); String [] date = new String[31]; I would like to set the JComboBox selected index to 1 (corresponding to "b"). If you are still editing the cell then the data may not be saved to the model yet. get Aug 16, 2010 · You can get the selected or typed value from a JComboBox by calling method getSelectedItem. For example if I select (component N° 2) from the JcomboBox then the image that I need to display is image2. getTheLongString()); (Or you can copy and refactor it if you don't want the generic/Java 8 stuff. You can try something like this instead: Apr 22, 2015 · I'm using a String array to populate a combo box with items. g. ToString(); MessageBox. with addItem() or insertItemAt() ) is what you can get out of it. Apr 22, 2016 · is there a way I can set it to select the last value all the time, this would solve the problem. addItem(str_rep); jComboBox1. JComboBox: getInputMap(JComponent. answered Apr 22, 2016 at 15:06. If you make the combo box editable, then the combo box includes an editable field into which the user can type a value. The editor is shared by all rows in the table. – Apr 9, 2012 · 4. It will be something like: String item = (String)comboBox. . RemoveAt(comboBox. toString(); Also, the selected item can be easily removed by using one of the following lines of code: // By item comboBox. png (j=2) Simply add ActionListener and retrieve the number from the selected item. getSource(); ic1[0] = combo2. JComboBox: addPopupMenuListener(PopupMenuListener l) 9. setSelectedItem("04"); you try to select a newly created String which is not equal to the one which is in your JComboBox. event. You need to get the data from the table which is done by using: table. Google for that class for interface information and for examples of how to use it. Given a singular selection scenario, select. For example: jComboBox1. Dec 1, 2011 · This java example shows how to get selected item of a choice or combobox . That said, here's what the javadoc of setSelectedItem() says: Sets the selected item in the combo box display area to the object in the argument. . toArray(new YourClass[0]); Feb 8, 2011 · In the actionPerformed() method you check the JComboBox's selected index (you could check the selected item, but that won't work for your switch statement) and test the returned int in your switch block. getItemAt (int i) : returns the item at index i. ComboText = jComboBox. addActionListener(e -> {. We would like to know how to convert the getSelectedItem() from JComboBox to int or any other type. Dec 25, 2012 · I'm wondering how to print out ALL the items within a JComboBox. So on click on this button b1, it adds a new tab t in the TabPane and it adds a new item in the ComboBox cbx contains the same name of the tab. Mar 26, 2015 · Java Swing JComboBox select only available item. toString(); After that you can save the Item for example: pps2. It should be comboText. If you are using a combo box with multiple options, you can use the getSelectedItem() method to find out which option is Aug 17, 2012 · Method Object JComboBox. Sep 5, 2015 · 1. If you only want your code to be executed once, just do: Dec 30, 2018 · 0. getSelectedItem(); Job selectedJob = (Job) jobList. ∟ JComboBox - Swing Combo Box Class. It does not contain the data for the cell. So whenever a new item is selected, one ItemEvent is sent for the Item that gets DeSelected, and one ItemEvent is sent for the Item that gets Selected. The OP may be leaving out a few details, because it should work. So here actionPerfomed is triggered and the comboBox. JComboBox: getItemAt Feb 9, 2017 · I would like to set it to -1 so that when the form loads, nothing is selected yet until user clicks on the drop down to select an item. So, highlight it. Simply add an ActionListener to the combo box. I currently have 2 JComboBoxes. The constructor you used is pre Java 5 style. // Get the number of items in the combo box drop-down. addActionListener(new ActionListener() {//add actionlistner to listen for change. vikrant verma. addRenderer(jComboBox, foo -> foo. Instead, what you want are a series of JCheckBox s if you want to Jan 12, 2015 · 1. After an item has been selected and submitted on a button press I want it to remove the item from the combo box. Ergo it does not get selected. Mar 3, 2016 · It will only be set on the first time the selected item/index is changed. getItemCount () : Returns the number of elements in the list. table. final YourValue value = (YourValue) object; // Of course you'd make your own label text below. Now, how can I get the count of the selected items when they click submit button and show it to the table on my result page? JComboBox doesn't support multi-selection, it only supports a single selection, that's the point. I can't figure out a much bigger problem than this, so I am going to the roots to eventually build my way up! I can't print the selected item in the combo box, currently I have an ActionListener for it: box. getValueAt(i, 0) returns a String Jun 1, 2022 · Commonly used Methods are : addItem (E item) : adds the item to the JComboBox. Jan 23, 2022 · I used JComboBox to let the voters choose who they want. JComboBox fromL = (JComboBox)e. Mar 13, 2018 at 17:01. JComboBox: addItemListener(ItemListener lis) 8. addKeyListener(); This will make sure that listener is being added to Editor of JComboBox. Dec 6, 2018 · To get the index of selected item i'm using this: public void fillData () { System. model = new DefaultComboBoxModel(ComboBoxItems); JComboBox box = new JComboBox(model); I added this combo box to a panel. That way any object pulling the selected item or dealing with comobo box can just May 23, 2023 · The code below demonstrate how to set the selected item of JComboBox and then on how to get the value of the selected item. Oct 9, 2009 · 7. 5,324 28 44. DataRowView in my MessageBox Nov 8, 2013 · Your problem is here: combo1 = (JComboBox)e. To get text from it use: comboBox. getColumnModel(). As it's written, you can use my example by saying the following: ToolTipRenderer. You can use JLabel to show the images. If you are doing something complicated, write another method that does the complex stuff then call it from the itemStateChanged() method, passing the ItemEvent variable. String value = comboBox. println("Selected Item = " + selected); } }); Suppose the object that is selected is Paul and I select after John. ItemEvent whenever the item's state changes. Usually, selecting an Item in drop down, bring the selected item to the shown area of the combo box. Iterate // from zero to the number of combo box items and get each item // of the specified index. this. edited Jun 1, 2022 at 9:25. setSelectedIndex(); You just specify the index number you want to select which would be the number of items in the combo box - 1. Jun 14, 2021 · The combobox takes numerous column-items from a table inside the database. Note that if you want the user to type in new values, you also need to make the box editable. awt Class JComboBox<E>. Jan 21, 2013 · This might be a dup - I can't find it exactly though - I'm basically simply trying to customize a JComboBox display by providing my own ListCellRenderer: targetCombo = new JComboBox(); targetCombo . The background assigned by the renderer is overriden by the selection background color of the JList that is used in the popup for the combo box. String str_rep = Integer. Jul 8, 2015 · 1. ItemListener to the JComboBox. getSelectedIndex(); To return the current selected offset in the list. You can get the selected index by calling getSelectedIndex() (but of course!) on the JComboBox. The combo box is shared by all rows in the table. getSelectedItem();`. Comparing Strings using the == sign is not the best way to check as it compares Objects and Sep 30, 2017 · No, I'm using a menuBar so each time I click a menu item I call setItems() on my recherche comboBox, also I'm getting all the items I expect in the comboBox, so it's not about not getting the items, everything works eccept for when I actually select an Item, I'm using a reload method when I click on teh menu Item, I added it to the code Apr 14, 2011 · To use this code, do something like the following: // Create your combo box as normal, passing in the array of values. camickr. setModel(new InvComboModel(con)); and the code from the InvComboModel. Jan 4, 2014 · I need to have combo boxes (JComboBox) in the first column of JTable. setSelectedIndex(-1); This solution will work better if your JcomboBox uses generics. May 18, 2020 · JComboBox comboBox = (JComboBox) event. Data. The listener will be given an java. getSelectionModel(). getSelectedIndex(); Dec 7, 2020 · Because JComboBox is a generic type. ComboBoxModelが提供されるため、このコンストラクタを使用して生成されたコンボボックスは、デフォルトのコンボ・ボックス・モデルを生成せず、挿入、削除 Mar 29, 2019 · The user selects in this case the item "Over", the Frame Pop's up, the user deal with the Frame and the informations he have to give and then close the Frame. getColumn(0). setSelectedItem(null); Once the numbers are added into the combo box, I set the selected item to null because I didn't want the combo Jul 12, 2015 · How do I change the options for a combo box depending on the selected item of a different combo box? Here is a simple example to get you started: import java. Dec 12, 2020 · @kleopatra I had no idea about getSelectionModel() method and found my own solution and tested it and it worked. The problem is that the name wont write to the text file. I am a little stuck. Remove(comboBox. However when I try to select the items in the second JComboBox it keeps returning to default. getEditor(). setSelectedIndex(-1) and comboBox. getItemAt (int i) : Returns the element at index i. He remembered that he forgot to fill one information, so he re-select the item "Over" but nothing happens because he did not change the selected item. If anObject is in the list, the display area shows anObject selected. Object selected = comboBox. swing; import javax. So all you need to do is add the proper data to the TableModel. We would like to know how to set selected item in JComboBox by index. SelectedIndex); Aug 11, 2011 · The reason is that if the combo box is editable, the selected item is not necessarily contained in the backing model and not constrained to the generic type. You don't set the index. My attempt was to remove the selected item from the String array first, remove all items from the combo box and repopulate it with the String array. ∟ getSelectedItem() - Selected Item of Combo Box. The correct way to create a JComboBox is: JComboBox<String> thickness = new JComboBox<String>(choices); Click the Launch button to run the ComboBox2 Demo using Java™ Web Start ( download JDK 7 or later ). I want to take only one of these items (from the combobox) and copy it to a JTextField. value should suffice. SelectedItem); // By Index comboBox. Insert this line of code into your program so that the jComboBox selection refreshes each time that section of code runs. swing. It does not have a current state. Habib Mhamadi. Contenido. Jul 25, 2011 · Use this code : comboBox. However I need to know if the user selects the item in case there is a username called that gets added. Jul 23, 2016 · 0. The problem is that when I want to get the value of the item selected in order to create a new object, I can't. However, this option might have some issues with the same objects in the list when getSelectionModel() is exactly what I need so I tried it instead. getSelectedItem(); System. I have a combo box that contains data from an array. getSelectedValue(); Jun 12, 2019 · System. answered Mar 13, 2018 at 16:48. Getting The Correct Position of Apr 29, 2014 · you could use a Vector to store the ids. I tried using the comboBox. System. getSelectedItem(); // do whatever you want with the values. Items. simply populate the vector with id of each item as you add the item to the combobox. getSelectedItem(); You can then use this in the ItemListener. Your code is hard to read because you're not. awt. A component that combines a button or editable field and a drop-down list. My advice is to use an IDE, that highlights some of these obvious mistakes in your editor. Say you have String [] symbols = {times, minus, plus, divide}; as an input when constructing JComboBox (see constructor JComboBox (E [] items) ) JComboBox jcb = new JComboBox(symbols); //you will see the string you selected. SelectedItem. comboBox. getEditorComponent(). To solve this we must simply give it a default selected value by calling setSelectedItem(. I can get the label as you can see, using the proveedorCombo. Perhaps a text file from which I could add topics to separately and edit more efficiently? Aug 19, 2016 · 15. 149 1 9. Pavel Bucek. Mar 9, 2015 · I have a JComboBox and an ItemListener which can detect when there is an item state change. Một chương trình khác về lớp JComboBox. getItem(); this will get the text directly from the editor, you can use it below keyReleased to get text from editor as you type. You are casting String to Integer hence its throwing ClassCastException, to get int out of a String use one of the following: Update: JComboBox. 739 1 7 15. YourClass[] comboBoxModel = yourClassList. addActionListener(new ActionListener(){. if you have an editable JComboBox<Integer> with the model [1, 2, 3], you can still type "foo" in the component and getSelectedItem() will return the String "foo" and not an object of Jul 26, 2012 · 3. Whenever you change the selection in a JComboBox, the itemStateChanged event is triggered twice, once for DESELECT of the old selected item and once for SELECT for the new selected item. If Add an java. If the object does not exist in the list, the Aug 21, 2021 · Commonly used methods: addItem (E item) : Adds the element to JComboBox. I want it to listen for whether the FIRST item in the list is selected. contains method where you see whether the first item in the combo box contains that specific word and repeat it until you find the specific index. answered Dec 30, 2018 at 15:53. Steve. well to simply get the index of selected item in a combobox you can use . Here's the code of the creation of the ComboBox in the Order. valueOf((String)IdProviderComboBox. This section provides a tutorial example on how to use the getSelectedItem() method to know which option is selected from a combo box. I have made the change but I have some issue. Oct 15, 2015 · You can get selected item from JComboBox with method . getselectedindex () method of combobox. This solved my problem, I hope it solves yours and others. however unclear the question is, there is no mention of selection - is there ;) – kleopatra. Insert Item At Specified Index In AWT Choice Or Combobox Example. Like this: String cap=jgrado. For example: chooser. println(jcb. How to get the selected Item from a JComboBox in java and compare it to a string? Hot Network Questions Oct 31, 2014 · I am using a drop down box (JComboBox) so as to select specific topics from within the GUI. The first is for some reason when I choose to calculate, it does not work and I need it to be calculated directly after choosing option from the JComboBox. However it is registering the value of the item that is selected, just not displaying the selected item in the JComboBox. May 20, 2010 · It is simple if you have your jcombobox in design mode. toString(); You're getting combo1 but calling a method on combo2 public JComboBox( ComboBoxModel < E > aModel) 項目を既存のComboBoxModelから取得するJComboBoxを生成します。. Thanks. When actionPerformed is called, you can look up the selected value and call what ever methods you need to. Syntax: YourType varName = (YourType)comboBox. Alternatively, to compile and run the example yourself, consult the example index. Dec 10, 2010 · 7. Vector comboBoxItems = new Vector(); DefaultComboBoxModel model; // ComboBox Items have gotten from Data Base initially. *; import java. myBox(evt); Jul 12, 2011 · Instead of storing items in a ComboBox and having to use the index to reference another array of values. setCellEditor(new DefaultCellEditor(comboBox)); Now, how can I get selected index of combo box in a certain cell ? table. cityName. Show(selected); This gives me System. Nov 11, 2011 · The value property of the <select> element should reflect the selected option's value. getItemCount (): returns the number of items from the list. JComboBox: addActionListener(ActionListener lis) 6. May 22, 2014 · 1. Also, to check conditions in your if / else if statements, you must use the == sign and not the = because the = operator will assign the value to the String and not compare it as you want. addItemListener ( ItemListener l) : Adds an ItemListener to JComboBox. getSelectedItem(); To return the current selected item in the list or null for no selection. JComboBox: getActionMap() 10. Check out the "paintCurrentValue" method of the BasicComboBoxUI class. That highlighting should be there permanently (which means, the highlight should not go away when the user clicks on the com1 again) EX: you select 'Food' from com2. getSelectedItem Aug 1, 2013 · 5. JComboBox: addItem(Object o) 7. May 23, 2023 · JButton button = new JButton ( "Get Items" ); final JLabel label = new JLabel ( "Items count: " ); button. When you set the SelectedItem property to an object, the ComboBox attempts to make that object the currently selected one in the list. getSource(); String fromL = (String) fromLoc. If this is the case, you might want to consider a different approach: you can register an ItemListener for each of your checkboxes. Aug 1, 2023 · El JComboBox es un componente de la interfaz gráfica de Java que permite al usuario seleccionar un item de una lista desplegable. There are 2 approaches I am aware of: Simple approach - After the call to initComponents() in the constructor add you code to build your model and call jComboBox2. getSelectedItem () : returns the item which is selected. Paso 2: Agregar elementos al JComboBox. So the constructor would look something like: public SomeClass() {. *; public class ComboBoxSelectedItem extends JFrame { public ComboBoxSelectedItem() {… Apr 27, 2019 · jCombobox : get selected index : getSelectedIndex()-------------------------------------------------+--+----------------------------------------------------- Aug 19, 2013 · You can also set the selected index to -1 after the items have been added, but before the event listener. When an item in the first JComboBox is selected, relevant items are displayed in JComboBox2. If you need to replace the value at the same position, you will have to provide your own model that supports adding values at a certain position. getValueAt(); depending on your exact requirement. setString(8,cap); or in a jtextpane: Jul 6, 2019 · Getting selected item (using the getSelectedItem() or getSelectedIndex() methods): // get the selected item as an object String selectedBook = (String) bookList. Aug 18, 2009 · 1. You just need to override the actionPerformed () method and here is the method to get the text of selected option. //Editing the text in the JComboBox and pressing the enter key should update the selected item. So the workaround would be: JComboBox comboBox = new JComboBox(); This will affect the rendering of the popup as well. Enter a new pattern by choosing one from the combo box's menu. At that time, 'One' is displayed in com1. Jan 30, 2018 · I'm building a swing application in Java. Paso 1: Crear un JComboBox. I have no idea how to go about doing this. I have a JComboBox that containts a list of Items. When the Button "Press" is clicked, it will add numbers into the combo box as below: for (int i = 0; i<10; i++) {. public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected Java Swing How to - Convert the getSelectedItem() from JComboBox to int or any other type. JcomboBox. setRenderer(new BasicComboBoxRenderer(){. In source mode, to get the selected item, the only thing that you need is converting the item selected in String. Jan 9, 2017 · You could try using the . you can get the jcombox selected items like this. 2) JComboBox can contain Object, so if you are after a String it is necessary to call jComboBox. new JComboBox(Vector items) 5. Warning: Swing is not thread safe. Whatever you put into it (eg. getValueAt(); or. if not using a selection the we can also iterate through This class represents a server-side socket that waits for incoming client connections. This way you'll always get the current jComboBox value selected currently: jComboBox. Es muy útil cuando se trata de presentar opciones al usuario y permitirle elegir una de ellas. Remarks. getSelectedItem () : Returns the element that is selected. private JComboBox<String> Team_ComboBox; public main_menuhandler(JComboBox<String> Team_ComboBox){. Highlight the item which is in com1, at the moment you select an item from com2. Simply call setIcon() to change the icon. Tại một thời điểm chỉ có một item có thể được lựa chọn từ list. This is done automatically. equals() compares String value. If you need the text that is selected on a JComboBox and you are sure it's a String and not any other object, just use something like String text = (String)myCombobox. If the object is found in the list, it is displayed in the edit portion of the ComboBox and the SelectedIndex property is set to the corresponding index. getSelectedItem () will return you Object, to covert it to int use : int idprovider = Integer. Apr 24, 2013 · then get the SelectedItem from the JComboBox. Share Mar 2, 2013 · wrapper objects with overridden toString (instead of a proper renderer) are evil - here it might appear as halfway justifyable because you seem to need another property for anothe view which is a home-grown problem, because the factoring of the business object is wrong, to start with: Item itself might be the business object, and its toString overridden with a complete description instead Sep 11, 2015 · I have a school assignment to change a GUI Calculator from RadioButton to JComboBox. Apr 25, 2017 · Here's an example of this by using a custom cell renderer. toString (); I Placed this code on onclick event of a button and it worked. setSelectedIndex(0); And repeat the step or try using a for loop, it's great if your combo box contains many items. toString(); JCombobox string item (visible) and integer key (inherent) I have a database schema = which will be shown in a JCombobox as a JTable column to select a name. JTable table = new JTable(5,10); JCheckBox checkbox = new JCheckBox(); table. It is a list of usernames, with the first item always being by default. public String toString(final Object object) {. Sep 3, 2012 · As far as I understand, you want to get the index of a selected JCheckBox in order to respond appropriately on a user's action. getSelectedIndex ()); } However all the time the result of function fillData () is always 0. mz ai ov yo qy ks ws lz vz dj

Collabora Ltd © 2005-2024. All rights reserved. Privacy Notice. Sitemap.