1. DefaultTableModel and Multiple Selections. coderanch.comimport java.awt.*; import java.awt.event.*; import java.util.Arrays; import javax.swing.*; import javax.swing.table.DefaultTableModel; public class TableModelTest { private final static Territory[][] DATA = { {new Territory("A"), new Territory("B"), new Territory("C")}, {new Territory("D"), new Territory("E"), new Territory("F")}, {new Territory("G"), new Territory("H"), new Territory("I")}, {new Territory("J"), new Territory("K"), new Territory("L")}, {new Territory("M"), new Territory("N"), new Territory("O")} }; private final static String[] COLS = { "One", "Two", ... |
2. Switch Selection between 2 JTable? coderanch.comHello, assume that i have 2 JTables in JPanel and each contain one row is it possible to switch selection between these tables in other words if i select the first table then after that i select the second table the first table will be unselected this is my attempt but not like what i need i need to switch selection ... |
3. Select maximum two rows of a table with ctrl key in swt/Jface coderanch.com |
4. one click and the whole ROW will be selected coderanch.comI beg your pardon.. im sorry to make the title unclear or irrelevant to the posted code, .. what i want in my JTable is when i click a row, that row will be highlighted, but in this case i have an image Background in my Jtable, Im having problems with that, When I tried to remove the background , I ... |
5. JTable listening for selected rows and columns by a keypress event coderanch.compublic class JTableWithMouseListenerextends extends JFrame { private JTable table; private JPanel lowerPanel; private JScrollPane scroll; public JTableWithMouseListener() { initializeInventory(); } private void initializeInventory() { lowerPanel = new JPanel(); lowerPanel.setLayout(new BorderLayout()); final String[] columnNames = {"First", "Second", "Third", "Fourth"}; final Object[][] data = new Object[100][columnNames.length]; table = new JTable(data, columnNames); table.addMouseListener(new MyMouseAdapter()); scroll = new JScrollPane(table); scroll.setBounds(0, 0, 1395, 400); lowerPanel.add(scroll); getContentPane().add(lowerPanel); ... |
6. how to deselect a selected row in a JTable ? coderanch.com |
7. Selecting multiple unconnected cells in a JTable coderanch.comDoes anyone know if multiple cells can be selected without selecting all the cells between them? So, for example, I want to select two cells, [1,1] and [1,2]. Now, when I select those two cells, I get four cells selected. I just want the two I selected. Is there any way of doing this? Thanks! |
8. Autofit selection in JTable coderanch.com |
9. How to select first row of list by default ? coderanch.com |
10. radio button selection in jtable coderanch.com |
11. JTreeTable Selection coderanch.comHi., My jtreetable is working fine but with this issue. 1) After expanding the node from the tree., the sub node gets selected only if i click in first column. I want to know if this is the feature of treetable that click on first column icon alone selects the row. 2) On Collapse, the treetable doesn't get refreshed., though it ... |
12. JTable: disable Pre selected row coderanch.com |
13. JTable: row selection based on mouse click coderanch.com |
14. Selected JTable row is not empty coderanch.com |
15. How do I get selected rows that have a check against them using check boxes in a table coderanch.comHow do I get every row in a JTable that has a a tick in the check box column? I need to read this into another text area. Here is a sample code I found on the internet that puts a check in a check box for each selected row import java.awt.BorderLayout; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JScrollPane; import ... |
16. Selecting a single cell in a JTable coderanch.comI need to find a way to select a single cell in a JTable. I know how to configure so that the user can select a single row or a single column, but how should I configure so that only one cell can be selected? If that is not possible, then how can I get the cell in a row that ... |
17. JTable selection listener doesn't listen to column changes coderanch.comJTable standardTable = new JTable(); standardTable.setCellSelectionEnabled(true); standardTable.getSelectionModel().addListSelectionListener(new ListSelect()); public class ListSelect implements ListSelectionListener{ public void valueChanged(ListSelectionEvent lse){ if (!lse.getValueIsAdjusting()){ // do stuff } } } This is a basic implementation of ListSelectionListener with cell selection enabled, so a single column is selected whenever a row is selected, and together the selections determine a cell selection, right? When nothing in the cell ... |
18. JtreeTable does not return complete selection path coderanch.com |
19. Adding checkbox to some selected row of a column. coderanch.comHello, I am having an issue related to checkbox in JTable. Although i searched it in the forum, but solution was not there and no relevant suggestion found. 1. I want to add checkbox in some selected row, i.e I have a JTable with 3 column , 1st column is checkbox, second is String and third is value like 1,2,2,1,2. Now ... |
20. JPopupMenu on a JTable Header Selection Problem coderanch.comI am working with a JPopupMenu added to a JTable's Header via the code provided. When I right click on the header column, the popup menu shows correctly, but when I select away from it (right click elsewhere), the column header remains selected. Project environment is using Java 5 on Windows XP (so , which may be part of my problem. ... |
21. JTable row selection coderanch.comI have a JTable that by default highlights the selected row when clicked, this works for my but I wanted to change the color of the font for a column. I created a TableCellRenderer for this and it works, the problem is that now when you select the row everything is highlight except for the cell that has a custome Renderer. ... |
22. Display Select Query Result in JTable coderanch.comtry { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String myDB = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/database/keys.mdb"; Connection DBConn = DriverManager.getConnection(myDB,"",""); Statement s = DBConn.createStatement(); ResultSet rs; rs = s.executeQuery("SELECT VID,Name From Main"); while ( rs.next() ) { int VID = rs.getInt("VID"); String Name = rs.getString("Name"); System.out.print(VID); System.out.println(Name); } } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); } } |
23. Pass the selected value from a JTable to a textField of a running JFrame Form coderanch.comHey there! I've tried lots of ways without success and I'm starting to lose my mind , i hope anyone have any ideas! So here's what happens: I have a GUI(Entradas) that asks the user to fill in a form with textFields, a comboBox, etc. I have a specific non-editable textField with a button towards it. The button opens a new ... |
24. How to find the selected rowindex thus extract the data-items from the NatTable Grid Item coderanch.comYes, I posted the same question in both of the forums guyz, because I'm very much eager to get the right answer till now. But, unfortunately neither of you guyz have showed me a right way to follow. I hope somebody may still show me the clue/way ahead. sorry guyz if I've misused your forum. |
25. Table Row Selection problem while adding any Image in a JTable coderanch.comThis is my code snippet- class ButtonCellRenderer extends AbstractCellEditor implements TableCellRenderer,TableCellEditor,MouseListener{ JTable table; JLabel rendererLabel ; JButton editButton ; String text = "BAKRA"; public ButtonCellRenderer(JTable table, int column) { // TODO Auto-generated constructor stub this.table = table; rendererLabel = new JLabel("value.png"); //rendererBut.setToolTipText("BUNTHAAAAAAAAAAAAAA"); rendererLabel .addMouseListener(this); TableColumnModel columnModel = table.getColumnModel(); columnModel.getColumn(column).setCellRenderer( this ); columnModel.getColumn(column).setCellEditor( this ); } public Component getTableCellRendererComponent(JTable table, Object value, ... |
26. How to select/highlight an entire row in JTextPane java-forums.orgI stumbled upon a question here when googling for a solution for my problem, it's not quite my problem, but rather close. Originally tried to post the url, but I can't post the link due to low post count. It's titled "How to select/highlight an entire row in JTextArea". So, I figured I'd try my luck and see if anyone could ... |
27. JTable Combo Box Row Selection Problem java-forums.orgI have a problem with my Table in the project. I have 10 Columns in the Table, the 4th and 10th column are significant to explain this problem. In the 10th column I have a combo box and in the 3rd Column I have a TextBox. The values for the Text Box is dependent directly on the values of the corresponding ... |
28. JTable Gridline in selected row java-forums.orgI am trying to set up a JTable so that it looks like a JList so that I can use different colours in cells and have everything nicely arranged in columns. I do not want any grid lines showing so I have table.setShowGrid(false); My problem is that when I select a row I want it highlighted but I get a white ... |
29. Problem in JTable row selection java-forums.orgHi All, I'm using JTable in my application. It has 4 columns and rows are fetched from database. 1st column contains JCheckBox to select the particular row in the table. 1st column header also contains JCheckBox. All rows in the table are selected and unselected by check and uncheck the column header JCheckBox. The problem is, If I check anyone of ... |
30. How to repaint.refresh the table (table model) with combo box selection envent java-forums.orgHi, I am working on one appliation which has one combox with some fields and one table which has one column with same fields. When i select the item from combobox, that item should not be displayed in the table.Which meand the row which has that field should not be dispalyed. In order to implement this i am using repaint. My ... |
31. Problem in row selection in JTable java-forums.orgHi, I have a Jtable in my application. For its cell rendering I have created a class which extends DefaultTableCellRenderer and overridden the method getTableCellRendererComponent. I am trying to change the background color of a particular column based on its value. But after doing that when I select a row its selection is not visible to me. Row is getting selected ... |
32. Cell selection not working in JTable java-forums.orgI have a JTable in my application that, for the most part, is working as expected, but cell selection is not. When I click on, or tab into, a cell it appears to be selected (background color change), but when I start typing the new information is appended to the existing rather than replacing it. I have setCellSelection set to true, ... |
33. JTable column header sorting direction arrows and row selection on focus loss java-forums.orgHello all, I'd like to know how to add UP/DOWN arrows to JTable column headers indicating sorting direction, like one would see in Windows Explorer in "Details" view. I would also like to know how to retain row selection (and selected index) when focus leaves JTable component. By default when focus leaves, getSelectedRow() returns -1, as if nothing was selected. Help ... |
34. Auto select JCombo box Adding to JTable java-forums.org |
35. how to get the currently selected row fo a jtable? java-forums.orghi, I was trying to use a jtable somehow as a trigger for other events like if a row gets selected another window would pop up. tried to give the table itself the mousepressed event using eclipse but when I click it, it does nothing. I was wondering how can I get the selected row on a jtable? |
36. Select a row in Jtable java-forums.orgHi, I have a situation where I have a screen which shows around 100 of record s.On this screen there is a search button ,if you specify the criterion and click on search it should highlight the record in screen with 100 of records. Search button will fire a stored procedure and find one row,that row should be highlighted.How do I ... |
37. Not able to select a column java-forums.orgHi, I have a jtable with 7 columns.I have applied user defined cell renderer to column 7th to disable it based on certain condition. When I make a selection in jtable all the columns for any particular row are selected (color changes to blue) except 7th column. Is it because of the cell renderer or I am missing something?? Thanks, |
38. Select the Header in JTable for Copy/Paste java-forums.orgI have a JTable and I can select any cell or row to do copy/paste data from it to another program (like text file). I also want to select the Header of the JTable but I cannot. Is there any way to do that? I tried cell/row/column selection but not working. Appreciate any advice. |
39. How to delete a selected row in JTable in Key Event? java-forums.org |
40. checking if a cell in JTable is selected java-forums.org |
41. Making a Table Row with JPanel Composed of JTextField and JComboBox Selectable java-forums.orgWhen populating a table row with cells made up of cell editor containg a JPanel composed of JTextField and JComboBox, I am unable to select the row. I can select a cell and do some editing in the JTextField and JComboBox, but I am unable to delete the row because the rowSelectionListener callback is not fired when clicking on the row ... |
42. result select sql in jtable java-forums.org |
43. result select sql in jtable java-forums.org |
44. Selection in JTable java-forums.orghi, i'm not a very experienced java programmer and i need some help with an assignment. i made a connection to a database and i show the records in a JTable. i've made a south panel with some labels and textfields and the intention is that when i click on a record, the information of that record is shown in the ... |
45. confusing output of a selected cell in a JTable java-forums.orgOK, I'm not at work today and had extra time, and so I did the simplification work for you. Below is your program with all the extra crap, the stuff preventing you and us from seeing the true problem, removed: Java Code: import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @SuppressWarnings("serial") public class InventoryDatabase extends JFrame { private JTable inventoryTable; private JPanel inventoryPanel; ... |
46. Jtable selection question java-forums.org |
47. row selection change in JTable java-forums.orgHi, I have a JTable with a datamodel. When the selected row changes a display has to be updated with the data from the new row. Is there a rowselectionchangelistener ? I can update it with the mouselistener and keylistener but that are 2 different event. Is there a single event that i can listen ? Kind regards |
48. JButton to detect if cell in a table is selected java-forums.orgWell, I need to make some sort of conditional check. There's a table and a delete button...so far I'd made it works so that when the table is selected the listselectionlistener will pick the data and then delete button will did the delete action after popping up delete confirmation. However as the button works on with its own listener it'll pop ... |
49. How To Know If Row Is Selected In a JTable? forums.oracle.com |
50. jtable & jcombobox (add new row once the selected object changes...) forums.oracle.comHi, I have a render Jcombobox component in a Jtable, then I need to add a row when the jcombobox changes the item selected. I set the table mode with an AbstractTableModel class and this has an addDefaultRow() method. When could I call this method to add the new row? I have tried in myjcombobox.addActionListener but it is called three times ... |
51. Re: JTable and listening to Row selection forums.oracle.com |
52. only allow x rows to be selected in a jtable forums.oracle.comhi all, i want to only allow a user to select x rows. where x is set in the code. for example if i only allow 2 rows to be selected....and the rows are: a b c d e then if the user selects a then b then c the selection is first ab, then bc (ie a is deselected when ... |
53. JTable selection vanishes on data change forums.oracle.comHow do you refresh the table? If you're using the DefaultTableModel and simply adding rows to the end, then there shouldn't be a problem. If you're replacing the model completely, or clearing and refilling it, then you'll need to take other posters' advice, and keep track of the selected row before doing this. However, if you are doing this, you should ... |
54. JTable selected Cell Fontsize forums.oracle.com |
55. How to capture Selected row in JTable forums.oracle.com |
56. How to get selected item from JCombo - When JCombo is used inside a JTable forums.oracle.com |
57. Use a button to select contents in Jtable forums.oracle.comI have a jTable which holding a data list, I need two buttons, one is 'up' and one is 'down', to move selections in the jTable. The idea is if a client don't have a mouse, they can use these two buttons to navigate through the jTable. Problem One: if the jTable is not selected, how can press a button make ... |
58. JTable Multiple cell Selection forums.oracle.comI would like to know whether JDK1.6 has fixed the bug id = 4138111 please click this link for details http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4138111 If yes please let me know how to use. I would like my JTable to behave in such a way that it Selcts only the cells user cliks. and nothing else. For example If user left clicks mouse with control ... |
59. JTable Row Selection forums.oracle.comI have a JTable which is constantly having certain rows updated. When you click and highlight the row, it highlights fine but the next update removes the highlight. I want to somehow hold this highlight. I have tried just updating the cells, but then the sorting does not sort properly. So, i was thinking of a solution where i have a ... |
60. How do you get the selected bounded entity from a select row (JTable)? forums.oracle.comIf I have a JTable which gets it's data from a bound database (lets call each row a USER) how do I get the the selected entity? For example if I had used a JList to display a list of bound entities, I could just (User)list.getSelectedIValue() which would return the selected entity object, User. Thanks! |
61. JTable: get position of selected row(s) forums.oracle.comHi, As the title may explain a bit already, I'm wondering if it's possible to retrieve the location/position of selected row(s) in a table. Say I have selected row 2 upto 5 in a table, I can detect which rows are selected, but now I like to now the X an Y position from the first and last row selected... I ... |
62. URGENT PLEASE ---How to open popup window after selecting a cell of JTable. forums.oracle.comHi, I am struck at aproblem, I am developing an applet in which I am using TabbedPanes and each tabbed panel has either tables or some key information to display. My Problem is, I have a JTable, which has informations related to a perticular record, each record may or may not have some more hidden information. If a record has a ... |
63. The columns of a selected row in a JTable forums.oracle.com |
64. About renderers and cell selection in JTable forums.oracle.comHi, i would like to do the following: when a user selects a cell in the JTable, it will highlight the cell + another cell of the table i can't manage to do that ; actually my problem is that it seems the cell renderer renders the table after the cell selection, but before the "mousereleased" method of my MouseListener (which ... |
65. select row and column from header in jtable forums.oracle.com |
66. JTable cell selection forums.oracle.comIf I use dcCtrlTable_.setEnabled(false) I am not able to select any cell But I commented dcCtrlTable_.setEnabled(false) or dcCtrlTable_.setEnabled(true) not only I select the CELL but also update the content the data in that cell. I want to select the cell but do not want to update the cell data. I am using public class ListSelectionListener for getting the value at cell ... |
67. Change JTable's row color on row selection forums.oracle.comHello! Everywhere I've looked they're only explaining how to draw rows in different colors WHEN THE TABLE IS BEING CREATED, via prepareRenderer. But that is not what I am looking for. What I want is to actually change the row's color after the table has been drawn/rendered/whatsoever. For instance, when the user clicks on that row. The default behaviour is for ... |
68. how i select non contigous rows in jtable forums.oracle.comi want to select more than two rows in a jtable. suppose i have 1 to 6 rows and 5 columns. and i want to select 2nd and 4th and 6th row. how can i select these rows with all 5 columns selected. there is a option to select multiple rows is by using control button for multiple selection but it ... |
69. JTable: extended Jtable...added selection settings.. strange results forums.oracle.com |
70. JTable and SQL select forums.oracle.com |
71. How to lock JTable but still have the cells selectable? forums.oracle.com |
72. Selection problem in JTABLE forums.oracle.comI have a table which allows multiple selection it has only ONE column with string values I have 10 rows I selected rows 2,5,7. And i saved these values But when i again load the table I am not able to make the selection of these row only the last row is selected ie only 7th row mycode is something like ... |
73. Selection event in JTable... forums.oracle.com |
74. Problem with JTable row selection forums.oracle.comHi, I have a JTable in which data will be updated by a thread. When the data in JTable is static, then when a click a row, the entire row is selected. But when the data is being updated by the thread and when i click the row only cell is selected and table.getSelectedRow() returns -1. According the row selected i ... |
75. Select all (ctrl+a) in Jtable with applet forums.oracle.com |
76. select and copy JTable data to system clipboard forums.oracle.comHello, Thank you very much for the example. I do not understand in the code what I should write as Applet owner in clipboard.setContents( contents, (ClipboardOwner)owner) method? Or I could use the other methods like exportToClipboard(JTable table, clipboard, TransferHandler.COPY)? The last method should be called from the listener? I need the method suited for an applet. I would be grateful if ... |