listselectionlistener

Using values from a for loop in a function outside of it

两盒软妹~` 提交于 2019-12-11 05:30:08
问题 I need to take values that I find from inside a for loop to use in a function that isn't inside the loop, and I can't figure out how to do this. What I am hoping to accomplish is to extract values from a key in a hashmap to then plot in a JTable only if that row is selected (using a ListSelectionListener ). This way, I can avoid graphing a hundred tables which would save a lot of time. Also I am using DefaultTableModel . This is my for loop: tableMaker(model); for(Map.Entry<String

JTable cell listener?

大憨熊 提交于 2019-12-06 19:10:53
问题 I am using a JTable. I need to get a notification whenever a cell selection change. I tried to use the ListSelectionListener but I only get notification when the row selection change. If I select a new column on the same row, I don't get notify. I need to know when the cell is selected, not when the cell is changed. Is there a listener that I can use to do this ? 回答1: The easiest way to do this is to call setCellSelectionEnabled(true) , and pass a reference to your table to the listener. When

Get object from selected JTable

爷,独闯天下 提交于 2019-12-06 03:42:07
I have one JTable which show list of book and it can be filtered and sort BookSwing.java package com.bookretailer.ui; import java.awt.Component; import java.awt.EventQueue; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.RowFilter; import javax.swing.RowSorter; import javax.swing.SortOrder; import

JList - getting value from Click

佐手、 提交于 2019-12-05 02:46:29
问题 Is there any way to use ListSelectionListener or MouseAdapter to get information about selected value (if value is a String for example), is there any built-in method for that? I only know how to get proper indexes but not the content or content.toString() I'm adding element like this: { DefaultListModel listModel; listModel.addElement(name); } @Edit Thank you for you for help. I solved my problem by doing this (for future generations so they wouldn't need to search as I did): list

ListView Scrolling Issue: on Item Selection

假装没事ソ 提交于 2019-12-04 05:45:36
问题 I have Listview with which I'm trying to display my custom Adapter.Everything works fine except when I select list item and scroll it,the items which were not selected are already being selected.I don't really understand what's the issue with my listview. Here's my class: @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.select_contact_layout); getActionBar().setHomeButtonEnabled(true);

JList - getting value from Click

独自空忆成欢 提交于 2019-12-03 17:21:10
Is there any way to use ListSelectionListener or MouseAdapter to get information about selected value (if value is a String for example), is there any built-in method for that? I only know how to get proper indexes but not the content or content.toString() I'm adding element like this: { DefaultListModel listModel; listModel.addElement(name); } @Edit Thank you for you for help. I solved my problem by doing this (for future generations so they wouldn't need to search as I did): list.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent e) { System.out.println("Mouse

ListView Scrolling Issue: on Item Selection

﹥>﹥吖頭↗ 提交于 2019-12-02 13:43:01
I have Listview with which I'm trying to display my custom Adapter.Everything works fine except when I select list item and scroll it,the items which were not selected are already being selected.I don't really understand what's the issue with my listview. Here's my class: @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.select_contact_layout); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setTitle("Select Contact");

How to make delete button to delete rows in JTable?

我怕爱的太早我们不能终老 提交于 2019-12-02 11:26:03
问题 I tried to make keystroke Delete but when I select cell and press delete button it enter in the selected cell instead to delete the whole row . How I can disable Delete button to do nothing when cell is selected? noo. I have delete button on my GUI but I want to make keyboard shortcut to this button. I want to make delete button on my keyboard to call delete method. But when I press it when cell is selected it enter in the cell instead to delete the entire row 回答1: The DefaultCellEditor for

Selecting a row on a JTable shall automatically select the corresponding row on another table, but it does not work

笑着哭i 提交于 2019-12-02 10:45:09
I have a problem with the selection of rows on my JTable instances. This is what I would like to to: I want to have two equal tables with the same data in the rows. When you select a row on the first table, e g the third row, I also want the third row on the second table to be selected automatically. I have solved this by adding a ListSelectionListener to the JTable that updates a class that just hold the selected value. Then that class triggers the other JTable with the selected value from the first. What my problem is: My problem occurs when the user sorts the rows on one of the tables. Then

How to make delete button to delete rows in JTable?

我只是一个虾纸丫 提交于 2019-12-02 06:14:13
I tried to make keystroke Delete but when I select cell and press delete button it enter in the selected cell instead to delete the whole row . How I can disable Delete button to do nothing when cell is selected? noo. I have delete button on my GUI but I want to make keyboard shortcut to this button. I want to make delete button on my keyboard to call delete method. But when I press it when cell is selected it enter in the cell instead to delete the entire row trashgod The DefaultCellEditor for many JTable cell types delegates to a JTextField , which binds the Delete key to the delete-next