jtable

jTable row count VS model row count

限于喜欢 提交于 2019-12-20 07:21:56
问题 I have a jTable which loads data from a DB query This load produces 32 results, thus 32 rows in the TableModel With myTable.getRowCount() i correctly get 32 Then i create a new empty model and load it into the table After that, if i call myTable.getRowCount() i still get 32 But if i call myModel.getRowCount() i correctly get 0! Why there should be difference between table.getRowCount() and model.getRowCount() if my table is using the model? ... System.out.println(myTable.getRowCount()); // 32

JTable with file i/o and array list

微笑、不失礼 提交于 2019-12-20 07:14:50
问题 In my program users input words along with their corresponding definition. An example of this user defined object is [countenance, a person's face]. The user's words are stored in an array list which works with file i/o. However, each time I call the "prepareTable" method, the program adds duplicates of the words found in the text file to the array list. If you need to see more code, I can post it but for convenience/readability I only posted the prepareTable method. Why is my program

how to blink table cell continuously after false if statement in swing

荒凉一梦 提交于 2019-12-20 07:13:05
问题 In swing application, I am using DefaultTableCellRenderer to flash the table cell when the cell time is equal to system time. I wrote if statement to compare cell time with hh:mm , If both time are equal, time cells backgroung will blink on the table rows. It is blinking 60 secs only still if statement is true, But i want to continue blinking same cell after false if statement. I got the position value of blinking cell like (0,2) and (1,2). from this integer, how can i set continues blink

JTable to PDF converter

做~自己de王妃 提交于 2019-12-20 07:05:05
问题 I have a problem in Java code to convert JTable to PDF. It throws NullPointerException and same code works in another page no difference at all in both. The code private void print() { Document document = new Document(); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("jTable.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); Graphics2D g2 = cb.createGraphicsShapes(800, 500); Shape oldClip = g2.getClip(); g2.clipRect(0, 0, 800

JTable to PDF converter

放肆的年华 提交于 2019-12-20 07:04:25
问题 I have a problem in Java code to convert JTable to PDF. It throws NullPointerException and same code works in another page no difference at all in both. The code private void print() { Document document = new Document(); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("jTable.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); Graphics2D g2 = cb.createGraphicsShapes(800, 500); Shape oldClip = g2.getClip(); g2.clipRect(0, 0, 800

how to get value from ticked jcheckbox in a row from jtable

拟墨画扇 提交于 2019-12-20 06:34:07
问题 I have a table with 3 column and dynamic row based from database value and a jcheckbox in last column based on this code : TableColumn tcolumn = tabel.getColumnModel().getColumn(2); tcolumn.setCellRenderer(tabel.getDefaultRenderer(Boolean.class)); tcolumn.setCellEditor(tabel.getDefaultEditor(Boolean.class)); example of my table: ============================================ val 1 || val 2 || val 3 (checkbox) || ============================================ from FB || from DB || checkbox || from

Java: Console output in JTable

流过昼夜 提交于 2019-12-20 06:19:14
问题 The program should list Volumes in a JTable . For Example: I get this output form the vollist.java class. while (volumeIter.hasNext()) { volume = volumeIter.next(); System.out.println(volume.getName()); } Console Output: vol1 vol2 vol3 ... How can I get this console output in my JTable . table = new JTable(); table.setModel(new DefaultTableModel( new Object[][] { {null, vollist.volname(null), null, null, null}, {null, vollist.volname(null), null, null, null}, {null, vollist.volname(null),

Setting the Color on the row of the JTable using JColorChooser

六月ゝ 毕业季﹏ 提交于 2019-12-20 06:15:43
问题 I am novice to Swing. I just started Swing couple of weeks ago and I stuck at some point.. I have designed a JTable having some rows on clicking (right) it opens a popup menu which have "CHANGE ROW COLOR" option ( JMenuItem ),on clicking which JColorChooser opens up and user can choose the color and same color will be set to the selected row. Is it possible to do it? How? enter image description here enter image description here 回答1: If you want the ability to color each row separately then

Java JTable to be refreshed every 2 seconds

徘徊边缘 提交于 2019-12-20 06:01:20
问题 Hy! I am working on java app that has 2 forms. In first form my user order meals and I store his order in my database on localhost server. On second form that orders in JTable by using simple sql query. Now I want to make that my JTable is refreshed every 2 seconds, so I can automatically see when user order meal. I tried with Timers, but I am total newbie in Java programming so I would appreciate help... Here is my method that refreshes table but I just need a bit help about Timer: private

Swing renderer to display the complete text in a column creates infinite loop

老子叫甜甜 提交于 2019-12-20 05:42:25
问题 I want to render a swing table adjusting the row's height, depending on how much text is displayed in a column so that all the text is shown in the cell. The problem is that when I set the height to the row an infinite loop is created. How could I solve it? This is my renderer final class RenderTextAreaMessage extends DefaultTableCellRenderer { JTextArea textareaMessage; @Override public Component getTableCellRendererComponent(JTable aTable, Object aNumberValue, boolean aIsSelected, boolean