1. JTable Design ?? coderanch.comHi folks ! I have been digging in to the javax.swing.table package latly. Im building an JTable with a column model and a tablemodel. And for each column i hava a diffrent renderer. The tablemodel is updatable with new data when the user clicks in the jtree i have. The reason why a buildt so many renderers are, that i cant ... |
2. 1.3.1_09 java version and use of JTable coderanch.com |
3. My JTable is a bit confused coderanch.comhi matthew, this may be too little and too late, but ... since i didn't see other replies... my first question might be whether you meant to add the scroller to the contentpane twice? second question might be why the scroller needs so much configuration. in most cases i can get scrolling working ok by setting preferred scrollable viewport size and ... |
4. wordwrap_JTable coderanch.com |
5. JTable coderanch.com |
6. JTable configuration coderanch.com |
7. Complexed JTable coderanch.comHi Ranchers, I need some help to develop my JTable. My Table has to display two types of data, hirarchicly. Each one has different number of columns with different names. Example: -------------------------------------------------------------- |Dept No. | Dept. Name | Location | -------------------------------------------------------------- |Emp No. | Employee Name | Salary | Benefits | -------------------------------------------------------------- |1 | Sales | Alaska | -------------------------------------------------------------- |475 | ... |
8. JTable coderanch.comimport java.awt.*; import java.io.*; import java.net.*; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.table.*; public class TableTest { public static void main(String[] args) { String[] headers = { "column 1", "column 2", "column 3", "column 4" }; int rows = 5, cols = 4; String[][] data = new String[rows][cols]; for(int row = 0; row < rows; row++) for(int col = 0; col < ... |
9. formating user input in a JTable coderanch.com |
10. JTable coderanch.com |
11. JTable coderanch.com |
12. JTable woes coderanch.comI'm not a "Swing" guy so I'm struggling with something that should be very basic and easy. I am creating a JTable using a DefaultTableModel and a DefaultTableColumnModel that I build myself (contains 14 columns). I don't feel like I should need to create a custom TableModel implementation - I just want a very basic table that will store results from ... |
13. JTable catching JMeniItem accelerators coderanch.comThere's also another strange thing happening.. I'm using JTextFields for editing the cells.. but I've overriden the method processFocusEvent so that if the editing starts, all of the text is selected, like this: JTextField field = new JTextField(){ //select the text when focus is gained.. protected void processFocusEvent(FocusEvent fe) { if (fe.getID() == FocusEvent.FOCUS_GAINED) { selectAll(); } else if (fe.getID() == ... |
14. Textbox in JTable coderanch.com |
15. JTable Custon Renderes coderanch.comHi all I am trying to implement a table with alternating row colors. For the purpose I have written following code import javax.swing.*; import java.awt.*; import javax.swing.table.*; /** * Title: *Description: *Copyright: Copyright (c) 2004 *Company: * @author not attributable * @version 1.0 */ public class TableTest extends JFrame { BorderLayout borderLayout1 = new BorderLayout(); ... |
16. JTables coderanch.comI like writing my own table model (AbstractTableModel) because it is necessary if you want to display or interact with the table in an "expected manner." Of course this is just my opinion, however I find that most of my tables are populated with strings, ints, doubles, booleans, etc. I want my doubles displayed to a particular precision. I want my ... |
17. JTable coderanch.comHi, Wht I want is an icon on the JTable header on which I click. The icon is appearing on tht clicked header but once I click on the another header,the newly clicked header should have an icon & the header on which the icon was visible should disappear. I have also used the fireTableStructureChanged()method but it gives me no effect. ... |
18. JTable coderanch.com |
19. JTable - What is wrong in coding coderanch.comHi All I m using NetBEans 3.6 IDE. I have one jTable in which when ever i load data from database it shows that 2 rows are in recordset but jTable shows only 1 row. Kindly help me where i am wrong ANAND ////////////////////// private void loadGridDetailData1() { try { clearTable(); String sql = "Select acc_code,b_i_no, amount,narration,update from cash_rec_detail where voucher_no ... |
20. JTable.updateUI() works for jdk1.2 & does not work for jdk1.4 coderanch.comHi, How come the method JTable.updateUI() works for jdk1.2 & does not work for version jdk1.4? This method shows me the table data without the need to click anywhere. But in the version jdk1.4, the data flow is same & also the code is same but it does not display the table contents till I do not click on the entity ... |
21. Nested JTables coderanch.com |
22. Sortble jTable coderanch.com |
23. JTable coderanch.comimport java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; public class RowVisibility { public RowVisibility() { JTable table = new JTable(new VisibleTableModel()); VisibilityController controller = new VisibilityController(table); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(controller.getUIPanel(), "North"); f.add(new JScrollPane(table)); f.setSize(400,400); f.setLocation(200,200); f.setVisible(true); } public static void main(String[] args) { new RowVisibility(); } } class VisibleTableModel extends AbstractTableModel { int cols, ... |
24. about JTable coderanch.comimport java.awt.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; public class ProgramaticSelection { public ProgramaticSelection() { JTable table = getTable(); table.setRowSelectionAllowed(true); table.setColumnSelectionAllowed(true); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(getUIPanel(table), "North"); f.add(new JScrollPane(table)); f.setSize(400,400); f.setLocation(200,200); f.setVisible(true); } private JTable getTable() { String[] headers = { "column 1", "column 2", "column 3", "column 4" }; int rows = 16, cols = 4; Object[][] data ... |
25. MaskFormatter in JTable coderanch.com |
26. JTables coderanch.comHi everyone, I am trying to save the contents the of the jtable together with all its fonts and everything else. The program compiles without any errors but When i try to save the contents of the JTable an exception is thrown in the tablesaveas method in the below method Please note that i am saving the jtable as an object. ... |
27. JTable coderanch.comimport 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); MyDTCR renderer = new MyDTCR(); String colNames[] = {"Name", "Age"}; Object[][] data = {{"joe","21"},{"fred","31"},{"mary","18"}}; DefaultTableModel dtm = new DefaultTableModel(data,colNames); JTable table = new JTable(dtm); TableColumn tc = table.getColumnModel().getColumn(0); tc.setCellRenderer(renderer); JScrollPane sp = new JScrollPane(table); sp.setPreferredSize(new Dimension(300,100)); getContentPane().add(sp); pack(); } public static void main ... |
28. JTable and EJB coderanch.com |
29. A special effect on JTable! coderanch.com |
30. JTable coderanch.com |
31. Detecting when a JTable's scrolled with arrows coderanch.comI have three JTables that are place in a row. Vertical scollbars of two rows are hidden and the right-most one is visible. I have listener attached to a right-most scrollbar so when a user moves it, the table scrolls and the two tables to the left of it scroll as well. Here is the listener: [B] JScrollBar mainVerticalBar = scroll.getVerticalScrollBar(); ... |
32. JTable within JTable coderanch.comHi all, I am trying to print 2 JTables on the same page by using the print() method. I am thinking of putting 2 JTables within cells of another JTable(main table) and call the print method of the main JTable. The main table contains the ff codes: import javax.swing.JFrame; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableModel; public class MainTable extends JTable { ... |
33. JTable as User's input (?) coderanch.comYour luck - I was messing with a swing tool just today. Anyways did you do a firetablecellupdated after you set the values?? Probably thats the reason its not getting updated. Anyways here is my table model - compare with the one you are having - probably it might give you some insights. class MyTableModel extends AbstractTableModel { private String[] columnNames ... |
34. JTables coderanch.comHi everyone, I am currently trying to print a multipage JTable but the the thing is on the left hand side of the JTable does not have any grid lines and i have tried to draw a rectangle around the jTable before printing it but nothing is happening. Another thing is that when the JTable goes on the next page for ... |
35. JTable Spread Sheet coderanch.com |
36. Best Practice using JTable coderanch.com |
37. Differnt components in JTable coderanch.com |
38. MultiComponent JTable coderanch.comimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class TableTest implements ActionListener { String[] one, two; // for second column comboBox JTable table; public TableTest() { one = new String[] {"A", "B", "C", "D" }; two = new String[] { "AAA", "BBB", "CCC", "DDD" }; table = getTable(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new JScrollPane(table)); f.setSize(400,160); f.setLocation(300,300); f.setVisible(true); } ... |
39. jtable popups coderanch.comhi again! another problem with my jtable: i want to get a jpopupmenu with right click on the table. the problem is, that i have checkboxes as well as textfields in the table. i only want the popup, if the component is a textfield and ONLY if the textfield is editable. how can it get the component in the selected cell? ... |
40. Subclassing JTable coderanch.comimport javax.swing.table.*; import javax.swing.*; import java.awt.Color; import java.awt.Font; import static film_titles.Colour.*; import javax.swing.event.TableModelListener; public class Table extends JTable implements TableModelListener { public Table(TableModel tm) { super(tm); this.setForeground(RED); this.setFont(new Font("Dialog", Font.PLAIN, 14)); this.setSelectionForeground(Color.WHITE); this.setSelectionBackground(BLUE); this.setGridColor(Color.GRAY); this.setRowSelectionAllowed(true); this.setCellSelectionEnabled(true); this.setRowHeight(20); this.setShowGrid(true); ///////// this.addTableModelListener(); ///////// TableColumnModel cm = this.getColumnModel(); cm.getColumn(0).setPreferredWidth(245); cm.getColumn(1).setPreferredWidth(100); cm.getColumn(2).setPreferredWidth(125); cm.getColumn(3).setPreferredWidth(40); cm.getColumn(4).setPreferredWidth(30); cm.getColumn(5).setPreferredWidth(25); } } |
41. JTable coderanch.com |
42. JTable not showing coderanch.comHi everyone. I'm trying to make a net watcher program, which detects changes in sites and shows them. I'm using vectors to store the content of the files and JTable to show the differences. However, it never refreshes(always shows old(unmodified) data). I know the vectors are changing, so the problem is after that point. I'm using Model-view-Control model, here's what happens: ... |
43. JTable with TextRenderes as TextPane coderanch.com |
44. Table in Oracle to JTable coderanch.com |
45. iamges in JTable coderanch.com |
46. JTable coderanch.com |
47. JTable Printout coderanch.com |
48. Jtable Back ground coderanch.comimport java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.plaf.ColorUIResource; import javax.swing.table.*; public class ScrollPaneBackground { private JScrollPane getScrollPane(BufferedImage image) { JViewport viewport = new ImageViewport(image); JTable table = getTable(); viewport.setView(table); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewport(viewport); return scrollPane; } private JTable getTable() { String[] colNames = { "column 1", "column 2", "column 3" }; int rows = 32, ... |
49. JTable not showing automatically at startup coderanch.commy jtable will show up normally if i use normal colors in setBackground, but it will not display properly once i use this line: mod.getcell(row,col).getcolor() . is there something wrong with my newmodel or cell class? public class Test extends JApplet { public void init() { //initialise all stuff here Container cp = getContentPane(); Random rand = new Random(); //table initialisation ... |
50. JTable Trouble coderanch.comTrue, but having a textfield hold data kinda makes it stand out (of course, if it's a different color than the rest of the table). Basically, I'm trying to redo an old project that I started with JavaScript by using Java instead. It's supposed to be a calculator-like application that does a calculation based on the "double" values in the array ... |
51. JTable usage coderanch.comHi, I am trying to build a quick and dirty kind of JTable UI, which will allow you to define relations between columns of 2 tables. So the table has 4 columns.1st one being names of the source tables in a ComboBox,2nd one should have the columns of the table selected in the 1st col (in a combobox).Same goes for the ... |
52. Witched Swing JTable!! coderanch.comHi There: I hope anyone can give me a hint on this WEIRD behavior (I am really scared!): Say you have this code somewhere: TablaAmparos tab (...) ... Amparo amparo = (Amparo) amparos.get(i); //I am sure this is an "Amparo". No ClassCast... Object [] dato = new Object[]{amparo.getCodigo(),amparo /*See: I send an "Amparo" for the second column*/ , amparo.getLimites(), amparo.getPorcentajeDeducible()+"%", ((amparo.isTomado())?"S":"N")+((amparo.isObligatorio())?"*":"")}; ... |
53. create JTable coderanch.comHi, i have a screen called search screen. I take it as a BoxLayuout.Y_AXIS for that. I used two boxes, in top box 6 searching fields are there. when the user enter any one of the 6 fields then he clicks search button. When clicks the search button now i want diplay some data(coming from database) in table format in bottom ... |
54. trouble with JTable coderanch.com |
55. JTable coderanch.comimport javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; import java.util.Random; import java.awt.*; public class TableTest { public TableTest() { String[] colNames = {"Column1", "Column2", "Column3"}; Object[][] data = generateRandomData(colNames); JTable table = new JTable(data, colNames); table.setDefaultRenderer(Object.class, new LastLineRenderer()); JFrame frame = new JFrame("TableTest"); frame.getContentPane().add(new JScrollPane(table)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(640, 480); frame.setLocationRelativeTo(null); frame.setVisible(true); } private Object[][] generateRandomData(String[] colNames) { Random r = new Random(); Object[][] data = new ... |
56. what's wrong within this code?JTable.. coderanch.comi have a txt file and inside have several lines of data. ----------------------------------------------- abc;123;weather;name;month; def;456;totto;day;month; uti;978;california;fitness;day; .... .... .... ----------------------------------------------- here is my code String output; String[] columnNames={"title" , "title", "title", "title" , " title"}; try{ br=new BufferedReader(new FileReader("text.txt")); javax.swing.table.DefaultTableModel dtm= new javax.swing.table.DefaultTableModel(columnNames, 0 ); table.setModel(dtm); String txt; StringBuffer op; int numRows; int numCols; while(output=br.readLine()) != null) { op=new StringBuffer(output); dtm.addRow(new ... |
57. JTable coderanch.com |
58. Using JTable coderanch.com |
59. JTables and java coderanch.comI have an app that has a jfilechooser. From there a user selects a file. Once they click Open, I want the contents to display in a jtable. For this,I'm using vectors for the column names and the date. The thing is the data vector won't be populated until the user selects a file. I'm using a defaulttablemodel, but am not ... |
60. JTable manipulations coderanch.com |
61. JTable method to return table body coderanch.com |
62. JTable "..." coderanch.com |
63. JTable coderanch.comDear Sir, This is working under some fixed conditions. But my cell selection is dynamically. That is, in first row some times first two columns are editable, and in second row first three columns are editable and in third row only first column is editable ... and so on... how to solve this problem ? regards francis |
64. JTable -Urgent coderanch.com |
65. how use the jtable in java applete coderanch.com |
66. JTable coderanch.com |
67. A4, A5, A3 ... to swing JTable coderanch.com |
68. Communication between two/or more JTables coderanch.com |
69. JDateChooser in JTable coderanch.compublic class DateEditor2 extends AbstractCellEditor implements TableCellEditor { JFormattedTextField ftf = new JFormattedTextField(new SimpleDateFormat("dd MMM yyyy")); public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { ftf.setValue(value); return ftf; } public Object getCellEditorValue() { try { ftf.commitEdit(); // could do this in stopCellEditing() instead of here } catch (ParseException e) { /* do nothing */ } return ftf.getValue(); ... |
70. JTable coderanch.com |
71. JTable in Linux coderanch.comjTableDetails.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { int col_Sel = jTableDetails.columnAtPoint(evt.getPoint()); int row_Sel = jTableDetails.rowAtPoint(evt.getPoint()); } public void mouseReleased(MouseEvent evt) { selRow = returnRow(); selCol = returnColumn(); boolean isPointInside = false; int sel_rowCnt = jTableDetails.getSelectedRowCount(); int sel_colCnt = jTableDetails.getSelectedColumnCount(); int col_Sel = jTableDetails.columnAtPoint(evt.getPoint()); int row_Sel = jTableDetails.rowAtPoint(evt.getPoint()); for (int i = 0; i < sel_rowCnt; i++) { for (int j ... |
72. JTable Performance coderanch.com |
73. JTable coderanch.comHi all, I have a problem with JTable. I have a table from which I get the value of a particular cell from the selected row thus: id = (String) myTable.getModel().getValueAt(myTable.getSelectedRow(), myTable.getColumnModel().getColumnIndex("column1")); The problem is I thought that by using the column name instead of an integer to get the column from the table I would avoid the problem of getting ... |
74. JTable in Headless Mode coderanch.com |
75. Setting maximum limit of characters in JTable coderanch.com |
76. JTable coderanch.com |
77. JTable coderanch.com |
78. JTABLE.. coderanch.com |
79. JTable coderanch.com |
80. regarding JTable coderanch.com |
81. JTable coderanch.compublic void mouseReleased(MouseEvent e) { Point p = e.getPoint(); JTable table = (JTable)e.getSource(); // or get it through some instance variable int column = table.columnAtPoint(p); if (column != -1) { // the columns can be moved around; map to the model's index colum = table.convertColumnIndexToModel(column); int row = table.rowAtPoint(p); // since Java 6, rows can be hidden using RowFilters. Map again ... |
82. JTable coderanch.com |
83. JTable coderanch.com |
84. Creating a basic JTable coderanch.comhi, i am using Oracle XE as the database and i have already created a small application using JTextFields which accepts the given data and ass well as displays the queried data from database. Now i want to move forward and implement JTable in a Frame but i am unable to start. Now i need a little guidance to create a ... |
85. Regarding JTable coderanch.com |
86. JTable coderanch.com |
87. JTable doubts coderanch.com |
88. JTable doubt coderanch.com |
89. JTable doubt coderanch.com |
90. JTable doubt coderanch.com |
91. JTable's setFillsViewportHeight method for Java 1.5? coderanch.com |
92. regarding JTable coderanch.com |
93. regarding JTable coderanch.comHi, Once you click on the hyperlink, you need to open an page with JTable, right? So you are just trying to open a new page in swing. I beleive you can do it in many ways. 1. pass the values as a collection to the constructor of the calling class. Then just use this collection in your table model. 2. ... |
94. Partitioning a JTable coderanch.comi am stuck up with one requirement ,so posting it here.i have an Object array containing 3 values.0th Object position contains two fields ,an integer(containing 2008) and and arraylist three elements(ie "A","B","C").likewise 1st position contains 2007 and 2nd postion contains 2006.Arraylist is same in 1st and 2nd position like the 0th position.Now in a JTable i want to display the values ... |
95. Regarding JTable coderanch.com |
96. doubt in JTable coderanch.comimport java.util.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; public class SolutionCompatibilityMatrix extends DefaultTableModel { private Object[] columnNames=null; public void setColumns(ArrayList SelectedDrugList1) { if (this.getColumnCount()==0) { Object[] columnNames1 = SelectedDrugList1.toArray(); columnNames=new Object[columnNames1.length+1]; for(int i=0;i |
97. regarding JTable coderanch.com |
98. Ask about JTable coderanch.com |
99. regarding JTable coderanch.com// assumptions: tableModel is an instance of DefaultTableModel // rs is your JDBC resultset // remove all rows and columns tableModel.setRowCount(0); tableModel.setColumnCount(0); ResultSetMetaData meta = rs.getMetaData(); int columns = meta.getColumnCount(); // JDBC is one based for (int i = 1; i <= columns) { tableModel.addColumn(meta.getColumnName(i); } while (rs.next()) { Object[] row = new Object[columns]; for (int i = 1; i <= ... |
100. JTable coderanch.com |