Questions tagged [tablecellrenderer]

TableCellRenderer is a Java Swing interface that defines the method required by any object that would like to be a renderer for cells in a JTable.

TableCellRenderer is a Java Swing interface that defines the method required by any object that would like to be a renderer for cells in a JTable.

472 questions
24
votes
5 answers

Change the background color of a row in a JTable

I have a JTable with 3 columns. I've set the TableCellRenderer for all the 3 columns like this (maybe not very effective?). for (int i = 0; i < 3; i++) { myJTable.getColumnModel().getColumn(i).setCellRenderer(renderer); } The…
user
  • 6,567
  • 18
  • 58
  • 85
14
votes
2 answers

How to use Renderer for TableHeader

Even I read and test answers by @kleopatra How do I correctly use customer renderers to paint specific cells in a JTable? particular one table header color java swing about super.getTableCellRendererComponent(...) must be last code line before…
mKorbel
  • 109,525
  • 20
  • 134
  • 319
13
votes
3 answers

How to merge cell in DefaultTableModel/JTable?

I searched a lot and got some answers for this Q. but many of them referred to links which give 404 error. I want to make table like this: Is there any method in java for this?
Nikhil Chilwant
  • 629
  • 3
  • 11
  • 31
13
votes
2 answers

TableCellRenderer and how to refresh Cell background without using JTable.repaint()

is possible to refresh background based on value from outside correctly, without to force for repaint table.repaint(); Based, used and tested with great code made by kleopatra and Hovercraft Full Of Eels valid for Java6/7, because there weren't…
mKorbel
  • 109,525
  • 20
  • 134
  • 319
12
votes
3 answers

JTable Cell Renderer

I'm following some code I found, (Yes I understand how it works) It's from here :Code Link What i'm trying to do is set a cells Foreground color if the cells value is set to "yellow" Here is my Code: public class Board extends JPanel{ private…
Diesal11
  • 3,389
  • 9
  • 28
  • 29
12
votes
4 answers

How to implement dynamic GUI in swing

First of all, apologies for posting something perhaps a bit excessively specific, but I'm not very experienced with Swing, and can't seem to find good examples that fit my needs. So I'm trying to figure out the best way to implement the a dynamic…
Rolf
  • 2,178
  • 4
  • 18
  • 29
10
votes
3 answers

Why does my Java custom cell renderer not show highlighting when the row/cell is selected?

I have a custom cell renderer for a cell to do a word wrap so more content can be read. Here is the code: import java.awt.Color; import java.awt.Component; import java.awt.Insets; import javax.swing.JTable; import javax.swing.JTextArea; import…
Brian T Hannan
  • 3,925
  • 18
  • 56
  • 96
10
votes
1 answer

How to disable linewrap in JLabel even for text

Whenever JLabel contains text in tag it applies line wrap automatically (it seems). My requirement is line wrap should always be disabled for label, no matter what text it contains. I can not use JTextArea in my renderer due to legacy reasons.
niteen22
  • 351
  • 3
  • 13
10
votes
2 answers

How to use custom JTable cell editor and cell renderer

I have created a JTable with a custom table render and custom cell editor which gives the result in the image I created the panel shown in the first table cells using a separate class which extended JPanel. and add table values as, …
Harsha
  • 3,548
  • 20
  • 52
  • 75
9
votes
2 answers

Idiomatic table cell renderers in Scala

I had been using the traditional Java TableCellRenderer approach for providing the renderers in a scala.swing.Table where I declare my renderers on the table's TableColumnModel. The code for this looked like: val myTable = new Table { lazy val tcm…
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
9
votes
1 answer

How to maintain JTable cell rendering after cell edit

You guys were so awesome in point me in the right direction on my last question and I have sort of an extension of my original question here: How to set a JTable column as String and sort as Double? As I now have my price column formatted as…
titanic_fanatic
  • 593
  • 2
  • 5
  • 13
8
votes
3 answers

Swing JTable - Highlight selected cell in a different color from rest of the selected row?

I have a basic swing JTable and the requirement is that when clicked on any cell, the entire row should be highlighted, and also that the cell which was clicked should be a different color from the rest of the highlighted row. Currently, I have…
8
votes
3 answers

How to change the font size for strings in a JTable?

String columnNames[] = {"Time","MAP","ICP","CPP"}; String dataValues[][]= new String [countery] table = new JTable( dataValues, columnNames ); I am working on a table and storing string values in dataValues. I am curious to know if there is anyway…
razshan
  • 1,128
  • 12
  • 41
  • 59
8
votes
3 answers

JTable with a “close” button in the column header

I am trying to create a table with custom column headers. I want the column headers to include a button that users can click on. The function of the button will be to remove the column from the table. Essentially, I am trying to build something…
Aleksey
  • 81
  • 1
  • 2
8
votes
5 answers

How to make JTable column contain checkboxes?

Preface: I am horrible with java, and worse with java ui components. I have found several different tutorials on how to add buttons to tables, however I am struggling with adding checkboxes. I need to have a column that draws a text box ticked on…
theraven
  • 4,825
  • 3
  • 20
  • 20
1
2 3
31 32