tablecellrenderer

JXTable: use a TableCellEditor and TableCellRenderer for a specific cell instead of the whole column

∥☆過路亽.° 提交于 2019-12-06 08:26:16
I have a JXTable compound of 6 columns and two of them are JCheckBox . I would like to have the following behavior: If the first checkbox is checked, the second checkbox is enabled and can be checked or not. If the first checkbox is unchecked, the second must be disabled and unchecked. I edited an image with Photoshop to show the desired result: For the CheckOne and CheckTwo columns i use a custom TableCellEditor and TableCellRenderer : public class CheckBoxCellEditor extends AbstractCellEditor implements TableCellEditor { private static final long serialVersionUID = 1L; private JCheckBox

Table Cell renderer using Nimbus and Scala

无人久伴 提交于 2019-12-06 02:53:34
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 whereas an equivalent Java program behaves just fine. If anyone is interested, here is some Scala code to run: import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel import java.awt.{Dimension, Color} import java.lang.String import javax.swing.table.

Table cells with HTML strings inconsistently rendered as multiline

久未见 提交于 2019-12-06 01:38:42
问题 Cells of one of columns in my table are HTML strings. HTML is used to provide some color indication. Usually the width of the column is enough to contain the whole string. But when it is not enough then the string is nicely cut on a word boundary. This is the desired behavior. The default cell renderer is used. I noticed that occasionally, some interaction with the table triggers the rendererer to wrap the string. As I understand, wrapping the HTML string is a normal behavior of JLabel from

Using TreeTable with different root and node types

☆樱花仙子☆ 提交于 2019-12-06 00:04:21
I have the following problem: I want to have a JTeeTable-like table component except that the roots (classes below) and the nodes of the tree are not of the same type. For instance, suppose that I have the following classes: public final class Entry { private int id; private String title; private String notes; private List<SubEntry> subEntryList; /** @see SubEntry*/ } public final class SubEntry{ private int id; private String title; private String notes; } Although these two class look similar and may motivate for a case for inheritance, they are NOT related that way . Think of it as a car

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

元气小坏坏 提交于 2019-12-05 17:44:28
问题 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 javax.swing.table.TableCellRenderer; public class TextWrapCellRenderer extends JTextArea implements TableCellRenderer { private static final long serialVersionUID = 1L; public TextWrapCellRenderer() { setLineWrap(true); setWrapStyleWord(true); setMargin

JTable color row and cell dynamically

半腔热情 提交于 2019-12-04 18:46:54
I want to make a search functionality for JTable object. I have a JTextFiled where i put my text to search. I want to change colors rows and cells which contains this text. Now i'm stuck because i have no idea how to change color dynamically. public class TableSearchCellRenderer extends DefaultTableCellRenderer { String search = ""; public void setSearch(String search) { this.search = search; } @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (table.getValueAt(row, column).equals(search)) {

JTable header background color

情到浓时终转凉″ 提交于 2019-12-04 17:34:12
I'm trying to put background color on the JTable header but it seems that it doesnt change the header's color this is my code for my JTable.. what am I doing wrong? Color headerColor = new Color(25, 78, 132); itemTable = new JTable(){ public boolean isCellEditable(int row, int column) { return false; }; Color rowColor1 = new Color(99, 154, 206); Color rowColor2 = new Color(148, 186, 231); public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component stamp = super.prepareRenderer(renderer, row, column); if (row % 2 == 0) stamp.setBackground(rowColor1); else stamp

How do I add an empty row to JTable?

我是研究僧i 提交于 2019-12-04 14:49:39
is there any way to an add empty row to jtable, where the first column is boolean, so it won't display the auto-generated checkbox? I need it to separate groups of rows. I tried using the code below, but it is NOT working: model.addRow(new Object[]{null,null,null,null}); I want make some rows completely empty so they work as separators. But in rest I would like to keep checkboxes Instead of storing Boolean.TRUE or Boolean.FALSE in the model you would need to store null. Then you have two options: Create a custom renderer that displays the Boolean values normally and recognizes the null value

Designing simple cell renderer for Nimbus look and feel

匆匆过客 提交于 2019-12-04 09:06:58
I have a simple-ish cell renderer which is composed of a few JLabel s (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 (which is much darker than both lighter and the darker row colors). In my renderer I do: if (isSelected) { setBackground(table.getSelectionBackground); } else { setBackground(table.getBackground); } If I comment this whole block of code out then then all my

Table cells with HTML strings inconsistently rendered as multiline

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 05:40:03
Cells of one of columns in my table are HTML strings. HTML is used to provide some color indication. Usually the width of the column is enough to contain the whole string. But when it is not enough then the string is nicely cut on a word boundary. This is the desired behavior. The default cell renderer is used. I noticed that occasionally, some interaction with the table triggers the rendererer to wrap the string. As I understand, wrapping the HTML string is a normal behavior of JLabel from which DefaultTableCellRenderer derives. What is not clear is why is this behavior so inconsistent and