remove cell borders in jtable


harsh

I have my custom cell renderer and want to remove the border of the cell.
what should I do? I tried setBorder but it doesn't work.

Here is my renderer code:

public class MyTableCellRenderer extends DefaultTableCellRenderer {

    private static final long serialVersionUID = -1195682136616306875L;

    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        Component c = super.getTableCellRendererComponent(table, value,
                isSelected, hasFocus, row, column);
        if (!isSelected) {
            if (row % 2 == 0 && row != 1) {
                c.setBackground(new Color(255, 255, 150));
            } else {
                c.setBackground(Color.WHITE);
            }
        } else {
            c.setBackground(new Color(255, 230, 255));
        }
        c.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        return c;
    }
}
Devon_C_Miller:

Lines drawn between cells are not part of the cells themselves. They are drawn by the table. You can turn it off throughout the table using:

table.setShowGrid(false);

To disable only horizontal or vertical lines:

table.setShowHorizontalLines(false);
table.setShowVerticalLines(false);

Alternatively, you can change the color of the line using:

table.setGridColor(color)

Related


remove cell borders in jtable

harsh I have my custom cell renderer and want to remove the border of the cell. what should I do? I tried setBorder but it doesn't work. Here is my renderer code: public class MyTableCellRenderer extends DefaultTableCellRenderer { private static final lon

remove cell borders in jtable

harsh I have my custom cell renderer and want to remove the border of the cell. what should I do? I tried setBorder but it doesn't work. Here is my renderer code: public class MyTableCellRenderer extends DefaultTableCellRenderer { private static final lon

Remove jtable grid completely (cell borders)

636f6465: How can I completely remove the borders around cells in a wiggling JTable so that there are no gaps between cells? Here is what I have tried: table.setShowGrid(false); table.setShowVerticalLines(false); table.setShowHorizontalLines(false); and write

Remove jtable grid completely (cell borders)

636f6465: How can I completely remove the borders around cells in a wiggling JTable so that there are no gaps between cells? Here is what I have tried: table.setShowGrid(false); table.setShowVerticalLines(false); table.setShowHorizontalLines(false); and write

Remove cell editor borders in JTable (Windows LaF)

Morgan I have a JTextField based cell editor with this ugly black border (ignore the left caret): Is there a way to remove it so it looks similar to this? Kamik After creating the table, you can try the following: DefaultCellEditor editor = (DefaultCellEditor)

Remove jtable grid completely (cell borders)

636f6465: How can I completely remove the borders around cells in a wiggling JTable so that there are no gaps between cells? Here is what I have tried: table.setShowGrid(false); table.setShowVerticalLines(false); table.setShowHorizontalLines(false); and write

How to remove cell borders of a table?

gap How to remove the border of the first cell from a table via JavaScript? (eventually, as shown) var firstRow = document.getElementById("tbl1").rows[0].cells; //Get first cell //firstRow[0].style.REMOVE CELL BORDER //Get 2nd row of tbl1 var secRow = document

How to remove cell borders of a table?

gap How to remove the border of the first cell from a table via JavaScript? (eventually, as shown) var firstRow = document.getElementById("tbl1").rows[0].cells; //Get first cell //firstRow[0].style.REMOVE CELL BORDER //Get 2nd row of tbl1 var secRow = document

How to remove borders of column headers in JTable?

User 975705: My question involves removing the boundaries of column headers in a JTable. My class extends JTable, so I managed to remove all other boundaries by doing: super.setShowHorizontalLines(false); super.setShowVerticalLines(false); But that doesn't rem

How to remove borders of column headers in JTable?

User 975705: My question involves removing the boundaries of column headers in a JTable. My class extends JTable, so I managed to remove all other boundaries by doing: super.setShowHorizontalLines(false); super.setShowVerticalLines(false); But that doesn't rem

How to remove borders of column headers in JTable?

User 975705: My question involves removing the boundaries of column headers in a JTable. My class extends JTable, so I managed to remove all other boundaries by doing: super.setShowHorizontalLines(false); super.setShowVerticalLines(false); But that doesn't rem

There are table borders, but no cell borders

nickel The table I want to render has borders on the outside, but no borders on the inside. I know that I can PDFPCell.setBorderuse to disable borders for all cells in the table, but I also want to use borders outside the entire table. Is it possible to do thi

Print data of JTable without borders

Hartha: I need to print the data in the JTable without any border around it, I tried to achieve this by using an empty border for the JTable but still print the border around the table. dataTable = new javax.swing.JTable(); dataTable.setBorder(BorderFacto

Print data of JTable without borders

Hartha: I need to print the data in the JTable without any border around it, I tried to achieve this by using an empty border for the JTable but still print the border around the table. dataTable = new javax.swing.JTable(); dataTable.setBorder(BorderFacto

Print data of JTable without borders

Hartha: I need to print the data in the JTable without any border around it, I tried to achieve this by using an empty border for the JTable, but still print the border around the table. dataTable = new javax.swing.JTable(); dataTable.setBorder(BorderFact

TCPDF - Hide cell borders

Dunberg I am using TCPDF object in PHP to create PDF. I have a background image and I try to set some text in a specific position of it. My question is: how can I disable the border of the cell? Why does the code not work? $pdf->SetLineStyle(array('width' => 0

Unwanted table cell borders

pain table { border: solid 1px #eee; text-align: right; } tr, td, th { padding: 0; margin: 0; border: none; } th, td { width: 90px; height: 24px; line-height: 24px; padding: 0; } th { background-color: #f4f4f4; } .first-col { text-align:

Table with gradient borders and cell gradient borders

Ruslan López I would like to get a table with gradient effect on both border and div border, because they are one piece, that is, the border color of the cells should be different. So far this is what I get: table tr:first-child td { border-top: 0; } table t

Table with gradient borders and cell gradient borders

Ruslan López I want to get a table that has a gradient on both the border and the div border, because they are one piece, that is, the border color of the cells should be different. So far this is what I get: table tr:first-child td { border-top: 0; } table

Table cell borders with multiple thicknesses (or div borders)?

Andrew Truckle I know how to style the border to double on a table cell or div border . But how to do it (taken from Microsoft Word): It has thick and thin borders. Can we do this easily using HTML/CSS? Thank you. renew: Here is some sample HTML: <!DOCTYPE htm

Table with gradient borders and cell gradient borders

Ruslan López I want to get a table that has a gradient on both the border and the div border, because they are one piece, that is, the border color of the cells should be different. So far this is what I get: table tr:first-child td { border-top: 0; } table

Table cell borders with multiple thicknesses (or div borders)?

Andrew Truckle I know how to style the border to double on a table cell or div border . But how to do it (taken from Microsoft Word): It has thick and thin borders. Can we do this easily using HTML/CSS? Thank you. renew: Here is some sample HTML: <!DOCTYPE htm

Remove specific TD borders?

Splucena I wonder why it renders correctly with or without .containercss color: red;. What's going on behind the code? How can I get the second image without deleting it .container? .container table { border-collapse: collapse; border: solid 1px #000; } .c

How to remove borders with CSS?

username I'm trying to create a matrix effect using only HTML/CSS, and the way I found out is to apply a solid border and then erase some fragments at the top and bottom, does anyone know how to create this effect using only CSS (if this is possible)? Here's a

Autohotkey: remove window borders

Antonio I just want to show some text with background. Despite what I've tried, there is a lot of white space around the text. Gui, +AlwaysOnTop -Border -SysMenu -Caption Gui, Add, Text, , Some text Gui, Show, AutoSize WinSet, Style, -0xC00000, A WinSet

remove some borders

Dennis I have a widget that cannot be wrapped in another div . My question is how can I remove the border of the title/title bar but still keep it around the rest of the DIV? Example below. Just adding a border on the .body won't work because things will break

Remove table borders

Doy I want to remove the following border, but I don't know how to do it. How can I remove it using CSS? Please help me, very useful! My HTML and CSS are as follows: table { width:100%; font-size:14px; } table, th, td { border: 1px solid #00b0f0;