tablecellrenderer

using a custom Swing JComponent in a TableCellRenderer

OK, I know how to make a simple custom JComponent. I know how to override a TableCellRenderer. I can't seem to combine the two. Here's a sample JComponent I created: public static class BarRenderer extends JComponent { final private double xmin; final private double xmax; private double xval; public BarRenderer(double xmin, double ...

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 = initColumnModel peer.setColumnModel(tcm) override protected def rendererCompon...

Designing simple cell renderer for Nimbus look and feel

I have a simple-ish cell renderer which is composed of a few JLabels (the renderer itself extends JPanel) and I'm trying to get it to render sensibly in the Nimbus look and feel. Basically what is happening is that in the lighter rows (as Nimbus has alternate row coloring), my specific cell renderer is using the table background color (...

Table Cell renderer using Nimbus and Scala

I asked this question about a problem I was seing with a cell renderer using the Nimbus look and feel and the issue has turned out to be possibly to do with Scala. Basically I have a cell renderer which extends Panel (as opposed to DefaultTableCellRenderer) and it is behaving oddly: it is not rendering the alternate row colors properly w...

Java JTable TableCellRenderer problems.

I have implemented a JTable named scrTbl in a program, and I wish to be able to vary text color in one column of this table, based on an external boolean variable called "up". My code related to this effort is as follows. TableColumn tcol = scrTbl.getColumnModel().getColumn(9); tcol.setCellRenderer(new CustomTableCellRenderer()); publ...

Custom creation of cells in a LWUIT Table in J2ME

I am trying to create a LWUIT Table in my J2ME application where all cells in one column are of a particular type e.g. TextField taking decimal input. Could anyone please suggest of achieving this or even another approach I could take? ...

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 default (cell renderer i think handles that), then on click of tickbox, unticks the box, re...

Allowing users to resize columns of JTable

Im creating a table which is dynamically changing its width. And I add columns by time as well. And I have bounded this table to a scrollpane. Here I have set the auto resizing to false in the JTable (else it will fill the whole area from the beginning). And I'm adding images to cells using cellrenderer as well. Now I need to allow use...

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 getTableCellRendererComponent() returns a Component with a random background color for each row. How co...