Column 1 « JTable « Java Swing Q&A





1. How to keep a single column from being reordered in a JTable?    stackoverflow.com

I have a JTable and I need to be able to reorder the columns. However I want the first column to not be able to be re-ordered. I used the following ...

2. Dependent columns in a JTable    stackoverflow.com

Hie! I have a JTable. Columns of this JTable are rendered by JComboBox. I would like to be able to change items of column 2 on the basis of values selected in ...

3. How to make a columns in JTable Invisible for Swing Java    stackoverflow.com

I have designed one GUI in which I have used one JTable from which I have to make 2 columns invisible . How should I do that ?

4. How to indicate that a column in a table is sortable (UI design question)?    stackoverflow.com

In the application that I am working on, there is tabular data (for the record, it is a Java Swing app using JTables). In some cases the data is sortable by ...

5. Merging columns in a JTable    stackoverflow.com

I am working in JTable and I have a requirement like this. Say There are 4 columns namely 10,20,30,40 Now the value usually comes like 10-20 20-30 and 30-40 So it was easy for ...

6. Using an empty column as a divider in a JTable    stackoverflow.com

I'm trying to use an empty column as a divider between pairs of columns in a JTable. Here's a picture and code for what I have so far. I know I ...

7. How to set specific column settings in JTable?    stackoverflow.com

How can I make my JTable show specific stuff for each column? Can I use an Object for more than one column? I want to have a column showing the date (dd.mm.yyyy) ...

8. Set Jtable/Column Renderer for booleans    stackoverflow.com

Right now my Boolean values for my JTable display as JCheckBoxes. This would normally be fine but I would like to display them as either an alternative String or image. I ...

9. Keeping a single column static inside a JTable    stackoverflow.com

Is there a way to keep the first column of a JTable embedded inside a JScrollPane static on scrolling the mouse horizontally.The table contains more than 50 columns.





10. miglayout question: column constraints    stackoverflow.com

I have a miglayout for a window where one of the columns was specified as grow but I need to modify that so it basically means "grow, but limit to _ ...

11. How can I fix the column in JTable so that the column is always visible    stackoverflow.com

How can I fix the column in JTable so that the column is always visible ? If I use JViewport than for the first time table is coming correct but when I ...

12. jtable columns too small    stackoverflow.com

i am very stuck. Hopefully a kind person on here can help me with a line of code to make my jtable sretch a little further across the panel its in. ...

13. miglayout question about columns    stackoverflow.com

I have some controls in columns that I would like to look like this, and there is one row that is an exception:

+----+------------------+----+--------------------+
| X1 | Y1      ...

14. getting my ovals to stack up on each column    stackoverflow.com

Possible Duplicate:
issue with my main method in my connect4 game
Hi, on my connect4 game, whenever i click on any square it places the oval on ...

15. Reusing Columns in Swing    stackoverflow.com

I'm trying to refactor some swing code. Currently there are two separate JTables, and each one has all the same columns, except the second one has an extra column. We have ...

16. Auto/best fit JTable columns, but stretch the last column    stackoverflow.com

I have the following JTable (Actually it's a ETable from Netbeans). It stretches across the container it's in - I'd like to keep that, and not use JTable.AUTO_RESIZE_OFF





17. JTable column titles dont show up, instead they are 'A', 'B',     stackoverflow.com

I'm new at using Java GUI and i'm trying to make a table with some scoring results of my soccerteam. At first I was using the DefaultTableModel and I didnt have any ...

18. JTable - Should not move to next column after hitting return on end of a column    stackoverflow.com

The default behaviour in a JTable seems to be that if I reach the last row of a column and hit return, I am taken to the first row of the ...

19. How to make one entire column unselectable in java?    stackoverflow.com

I am doing my java project using netbeans. I want to make entire columns except one column unselectable.The user should be only able to click rows in only in one column. ...

20. Splitting columns of JTable    stackoverflow.com

I want to split the columns of a JTable in the following manner as shown in the images. enter image description here When i drag one of the columns, the ...

21. Making a column invisible in a JTable    coderanch.com

I have found this technique more helpful than setting the column width... Put all your invisible columns at the end of the data model. For example, if you have the following data: Col1 Col2 Col3 Col4 Row1: "abc", "def", "ghi", 123 Row2: "jkl", "mno", "pqr", 456 and you want to hide the third and fourth columns, all you have to do ...

22. Problem with repositioning JTable columns    coderanch.com

I'm wondering if there is a problem with moving columns of a JTable that contain other components (buttons, checkboxes, etc). My code seems to be throwing null pointer exceptions whenever a column with another component is moved but not when the columns containing only text are moved. If there is no way to stop the exceptions, then is there a way ...

23. JTableView : renaming columns    coderanch.com

24. JTable column question    coderanch.com

25. Jtable column headings    coderanch.com

I have an app that displays the result set for a given oracle query. I can successfully set the font for everything in the app except for the column headings. Has anyone have this issue before? Thanks- ------------------ "It's alive, it's alive!" -Young Frankenstien (We all are mad scientists when it comes to getting things to execute perfectly.)

26. JTable Column Heading (SOS!!!)    coderanch.com

hi all, I have a table which is generated dynamically after picking up values from a text file. The problem is the column title are very long strings say for eg: "Number Of Undebited Items Per Transaction" What happens is since the title is very long, it appears in one line thus increasing the column size Can i have the title ...

27. no moveable columns in jtable    coderanch.com

hi there, i have a very very simple problem, but i dont find something about it. i have a jtable with 5 columns. i dont want that you can move the columns ( e.g. that you move the first column behind the third column ). they should be static in the same order. any ideas? thanx in advance Steffen

28. JTable column behaviour    coderanch.com

30. Deleting all the columns in Jtable    coderanch.com

Hi, I have the results from a query and have dynamic no. of rows and columns. So, in order to populate the table, I need to delete all the previous rows and columns. Removing all the rows is fine but when it comes to removing all the columns from the table, I get the exception, "java.lang.ArrayIndexOutOfBoundsException: 2 >= 2" Can some ...

31. JTable's Column Problem    coderanch.com

32. Autoresizing table column    coderanch.com

33. JTable/Column modification    coderanch.com

34. JTable/Column modification /urgent    coderanch.com

hello friend, Thanks for u'r reply.It's working fine.Now i need one more help from u.In JTable when any column is selected i need to do one event,else that event shouldn't be triggered. Any row or column is selected means this should happen. there r isselected(rowcount,columncount) methods.But i don't have to specify the row or column count.If any row or column is ...

36. JTable: How to combine several columns    coderanch.com

38. JTable - only one read-only column    coderanch.com

39. JTable not movable column    coderanch.com

41. Stopping of Table Columns Moving    coderanch.com

43. Inserting a Column in JTable    coderanch.com

I add a column to it, and it's default position is to the end. That's alright, i'll use the move column method to move it to the position i want, that works fine... for the first one, when i add a second, using exactly the same process, the one i previously added moves to the end and my new column gets ...

44. visually sececting a column in JTable    coderanch.com

45. column margin in JTable    coderanch.com

Hi, How can I control the column margin of the header of the table ? Either use TableColumnModel.setColumnMargin() or Jtable.setIntercellSpacing() the result is same. When I view The applet in Jre1.3.1 The Column margin is set in the data cells and not in Table Header. Use any value for columnmargin, the header has always margin of 0 and the data cells ...

46. get the users input from a column    coderanch.com

Hi Davey, I may be misunderstanding your question, but I think the easiest way is to get the data from the "JTable"'s associated "TableModel". Use the "JTable" method "getModel()" to retrieve the "TableModel", then use the "getValueAt()" method (of "TableModel") to get the required data. Please see the relevant documentation (javadocs) for more details. Hope this helps. Good Luck, Avi.

47. Fixed length Table Column    coderanch.com

48. JTable Column    coderanch.com

50. Listener on columns    coderanch.com

51. JTable's columns interchange.    coderanch.com

52. Left most column locking    coderanch.com

53. Resetting columns in JTable    coderanch.com

54. visible unvisible jtable column    coderanch.com

hi.. I am in trouble with jtable columns.. My table read data from a text file and i want to select which of the table's column will be visible.I have button like table header and in case of double click i wanna make that column invisible.But the problem is i do not want to lose table data(can't use removecolumn).I tried to ...

55. Gridbag span columns problem    coderanch.com

This is directly relevent to our discussion here and is essentially the exact same issue that was causing me grief. All columns within a GridBagLayout are not necessarily the same size, they vary in size based upon the components they contain. Since your components all have the same weight it will try to give them the same amount of space, hence ...

56. Can I set up a JTable columns?    coderanch.com

Dear All, How can I set up my JTable columns to have the amount the user specifies? for example when the user types in 50 in JTextField 1 I want the JTables columns to then set to 50. How can this be done? Thanks ben import javax.swing.*; import javax.swing.table.TableModel; import java.io.*; import java.util.*; import java.lang.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; ...

57. Mergeing for column    coderanch.com

58. Column in jtable    coderanch.com

59. Columns vs letters    coderanch.com

I have a JtextArea that is 42 Columns long. When enough letters are entered by the user to fill that line of the textarea I want to count it. How can I determine how many letters will fit on the line? If I use getWidth it gives me the length in pixles. GetColums will return the number of columns, which won't ...

60. Reordering Column    coderanch.com

import javax.swing.*; import javax.swing.table.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class TableColumnOrderTest extends JFrame implements MouseListener { String headers [] = {"h0", "h1"}; String data [][] = {{"a0", "b0"}, {"a1", "b1"}}; JTextArea ta1 = new JTextArea (30,5); DefaultTableModel dtm = null; JTable jt = null; TableColumnOrderTest () { Container c = getContentPane (); dtm = new DefaultTableModel (data, headers); jt ...

61. Jtable with vertical columns    coderanch.com

62. Make table column invisible    coderanch.com

Hi All, The following code make the column invisible, but also removes it from the model. table.getColumnModel().removeColumn(table.getColumnModel().getColumn(0)); How can I make the column invisible, but *not* remove it from the model, because I need to obtain the data from the invisible column later on. Also, this is not working, since when I increase column width by dragging I can see some ...

63. JTable and XP column issue    coderanch.com

jspList is aScrollPane so I can use only ScrollPaneLayout. Also I want the coumn header displayed on the column not the table header on the scrollpane because there are more columns with different headers that can be added. The fixedColumnModel is for the row headers and the mainModel is for the actual column. The fixedColumnModel overides columnName to return ""; but ...

64. Table column Heading justification    coderanch.com

65. fixed column in table    coderanch.com

66. Columns in JTable    coderanch.com

67. two questions about columns in JTable    coderanch.com

68. SWT, Provider => getColumnImage, Indent in wrong column.    coderanch.com

I don't know if I have stumbled onto a bug or if I'm somehow using the provider incorrectly. I have a provider for a TableViewer in which I'm specifying column #7 should contain an image. The strange thing is that the text shown in the first column (#0) of that row is indented with with just as much space as the ...

69. Two Column switching UI widget    coderanch.com

70. making a JTable column not visible    coderanch.com

if you want the column itself visible, something like this might work import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; class Testing extends JFrame { public Testing() { setLocation(400,100); setDefaultCloseOperation(EXIT_ON_CLOSE); MyRenderer renderer = new MyRenderer(); String colNames[] = {"ID","Name", "Age"}; Object[][] data = {{"007","joe","21"},{"008","fred","31"},{"007.5","mary","18"}}; final int COLUMN_TO_HIDE = 0; DefaultTableModel dtm = new DefaultTableModel(data,colNames); JTable table = new JTable(dtm) { public ...

71. JTable reordering fixed for only 3 column.    coderanch.com

Hello, I have jtable, which has 8 columns. I would like to fixed the reordering of my 3 column but for the rest of columns reordering is allow. I tried to use jtable.getTableHeader.reodering(flase);. But this comand fixed my all column which i dont want. Can any one please help me out or any sugesstion. thanks

72. JTable Columns    coderanch.com

Hi everyone, I am currently trying to limit the number of columns that can be added to a JTable by a user. You see at first i add the user can dynamically add Columns to the JTable like how i did below DefaultTableModel TableModel1 = new DefaultTableModel(0, 0); public void insertcolumn (JTable table2) { //This function adds a column dynamically to ...

73. JTable Columns    coderanch.com

import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class HeaderHighlight extends MouseAdapter { public void mousePressed(MouseEvent e) { JTableHeader header = (JTableHeader)e.getSource(); int colIndex = header.columnAtPoint(e.getPoint()); TableColumn col = header.getColumnModel().getColumn(colIndex); HighlightRenderer renderer = (HighlightRenderer)col.getCellRenderer(); renderer.setSelectedColumn(colIndex); header.getTable().repaint(); } private JTable getTable() { int rows = 32, cols = 3; String[] colNames = { "column 1", "column 2", "column 3" }; Object[][] ...

74. Bold all columns in a JTable    coderanch.com

75. JTable Columns    coderanch.com

import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class ComboColumn { private JScrollPane getContent() { int[][] values = { { 1, 19, 7 }, { 16, 4, 32, 12 }, { 6, 9, 4 } }; // wrap values for editor comboBoxes Object[][] options = new Object[values.length][]; for(int j = 0; j < values.length; j++) { options[j] = new Object[values[j].length]; ...

77. to point a cursor into a particular column in Table    coderanch.com

ok as per you explained it if you want to point to a particular row of the table you must use a Object[][] data as a argument to the table model and pass the data to table,you want to point to a particular row than data[i][j] in a for loop,than keep changing i & j value [0][0],[0][1] and so on.hope this ...

78. JTable column non-focusable?    coderanch.com

this might start you off (you can still d/click to edit) import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.table.*; class Testing { public void buildGUI() { JTable table = new JTable(5,3); TableColumn tc = table.getColumnModel().getColumn(1); tc.setCellRenderer(new UnfocusableRenderer()); JFrame f = new JFrame(); f.getContentPane().add(new JScrollPane(table)); f.pack(); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } class UnfocusableRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean ...

79. JTable Disable Entire Column    coderanch.com

80. Jtable column    coderanch.com

You want to change it through code? If so, you can use the setValue method in either the table or the table's model. The difference between the two is that the table's column indexes can be different from the model's column indexes. Also, please use Boolean.FALSE, Boolean.TRUE and/or Boolean.valueOf(boolean) instead of new Boolean. That will decrease the number of objects created; ...

81. Restrict the User to Move a Column in a JTable Component    coderanch.com

private int columnValue = -1; private int columnNewValue = -1; tblResults.getColumnModel().addColumnModelListener(new TableColumnModelListener() { public void columnAdded(TableColumnModelEvent e) {} public void columnMarginChanged(ChangeEvent e) {} public void columnMoved(TableColumnModelEvent e) { if (columnValue == -1) columnValue = e.getFromIndex(); columnNewValue = e.getToIndex(); } public void columnRemoved(TableColumnModelEvent e) {} public void columnSelectionChanged(ListSelectionEvent e) {} }); tblResults.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (columnValue ...

82. JTable Column Validation    coderanch.com

84. SWT: get Column from cursor position    coderanch.com

Hello i've create a treeViewer and added some columns. now i want to be able to change the columnheaders (the name of the column). since it's not possible to attach a context-menu to the headers there must be another way to do this i guess. i was thinking to get the cursors position when making a right click in a column. ...

86. Need help on Multiple Column Tree - SWT - Important    coderanch.com

Hello All, I'm very new in SWT development. Recently I am engaged with some eclipse plugin development assignment where I have to build some table with two columns, where both of the columns will contain local directory heirerchy. Let me to explain the problem , the tree will contain two TreeColumns, and both of them should display the local file directory ...

88. Columns on JTable    coderanch.com

public MyModel (Connection conn,String tableName)throws SQLException { super(); getTableContents (conn, tableName); } protected void getTableContents (Connection conn,String tableName)throws SQLException { // get metadata: what columns exist and what // types (classes) are they? DatabaseMetaData meta = conn.getMetaData(); System.out.println ("got meta = " + meta); ResultSet results =meta.getColumns (null, null, tableName, null); System.out.println ("got column results"); ArrayList colNamesList = new ArrayList(); ArrayList ...

89. JTable column help    coderanch.com

Howdy all, I've been lurking for some time now and have gotten some great help from this site. But I could not find what I was looking for in the archives. So here is where I'm asking for help. My JTable is using a data model that has a column that is used to set the row color. When I display ...

91. fix the first column    coderanch.com

Here's that all written in code, using the sharing of the TableColumnModel: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; public class Test { public static void main(String[] args) throws Exception { String[] header = new String[26]; String[][] data = new String[100][26]; for (char c = 'A'; c <= 'Z'; c++) { int index = c - 'A'; header[index] ...

92. how to make column like colspan ?    coderanch.com

93. why the columns disappear ?    coderanch.com

I developed a simple JTable using the following code. The output is abnormal that it does not have column header row. The three data rows are there though. I figured out that the problem was from "column Model" part. If I skip the "createColModel" step and just do JTable table = createTable(tableModel); Then I saw everything including data rows and column ...

94. JTable with different objects (or components) in a column    coderanch.com

Hi everybody, I have a Vector that feeds my JTable. This table has some columns, but the problem is that these columns have different objects, like strings, booleans, integers, and so on. My ideia is to insert a checkbox in boolean type cells, and insert a combobox in some cells that I choose. (my table is editable) I developed something here ...

95. JTable Sum Column    coderanch.com

96. I Can't Make Columns Wider in My JTable    coderanch.com

97. how to setsize for columns of JTable    dbforums.com

98. [SOLVED] JSpinner in JTable column    java-forums.org

With the code given below i'm getting the format Sat May 09 10:12:00 IST 2009 But I want only May 09 2009 import java.awt.Component; import java.util.Calendar; import java.util.Date; import javax.swing.AbstractCellEditor; import javax.swing.JSpinner; import javax.swing.JTable; import javax.swing.SpinnerDateModel; import javax.swing.SpinnerModel; import javax.swing.table.TableCellEditor; public class DateCellEditor extends AbstractCellEditor implements TableCellEditor { int selectedRow; int selectedColumn; JTable currentTable; Date currentDate; JSpinner spinner; protected static final ...

99. Total column issue again    java-forums.org

Thank you, Norm. I've figured out my issue. I was using 'total = total + (Float) value;' which was the problem. I had to use 'total = total + Double.parseDouble( String.valueOf( value ) );' Is this because value (an Object) is also a String? I'm confuse why I need to use String.valueOf and parse it.

100. Redisplay New JTable and Columns    java-forums.org

I am working on a little side project for myself. I want to enter some input in a text area (SQL statement), and receive the results in the output pane (Jtable). However, I cannot get it to work. The following should be runnable by anyone. Can someone tell me what I need to do to get the new column labels (a,b,c) ...