Button text is not displayed in the JTable visualizer. What for?

I have a custom cell renderer in JTable, and it works, but instead, "x" appears on the buttons that are the cells in the table, I see "..." (three dots). What did I miss?

  /***************************************************************************
 * Listener reagujący na dodanie nowej wartości
 **************************************************************************/
private static class ButtonRenderer extends JButton implements
        TableCellRenderer {
    /***********************************************************************
     * Konstruktor
     **********************************************************************/
    public ButtonRenderer() {
        super("x");
    }

    /***********************************************************************
     * @see TableCellRenderer#getTableCellRendererComponent(JTable, Object,
     *      boolean, boolean, int, int)
     **********************************************************************/
    public Component getTableCellRendererComponent(JTable table,
            Object value, boolean isSelected, boolean hasFocus, int row,
            int column) {
        return this;
    }

}
+3
source share
1 answer

The button size is not large enough to contain an "x" render plus an addition around it.

The solution would be to increase the table cell or decrease the padding (always assuming the button is the same size as the table cell).

+1
source

Source: https://habr.com/ru/post/1698849/


All Articles