Vertical Repeater Table Header Cell

I used the Vertical Table Header Cell Renderer which is available on this site here It works great for me, but I need to understand how I can use some headers that are vertically aligned with multiple lines as shown in the example image (Coordinate Geometry). I tried to set strings with a matching \ n character, but I think my approach is very simplistic and flawed. Please keep it simple. Thank!


source to share

2 answers

From Joop's answer, I did this. Instead of changing the shortcut, you can save \n


In the file,

replace getTableCellRendererComponent

as follows:

    public Component getTableCellRendererComponent(JTable table, Object value,
              boolean isSelected, boolean hasFocus, int row, int column) {

          String str = (value == null) ? "" : value.toString();
            BufferedReader br = new BufferedReader(new StringReader(str));
            String line;
            StringBuilder sb = new StringBuilder("<HTML>");
            try {
                while ((line = br.readLine()) != null) {
            } catch (IOException ex) {
        super.getTableCellRendererComponent(table, sb,
                isSelected, hasFocus, row, column);
        JTableHeader tableHeader = table.getTableHeader();
        if (tableHeader != null) {
        setIcon(getIcon(table, column));
        return this;




In the beginning <html>

, enter HTML text, and use the <br>

(line break) instead \n




All Articles