@Override public void setBounds(int x, int y, int width, int height) { if (getHorizontalAlignment() == SwingConstants.LEADING) { // Restrict width to actual text width = Math.min(width, this.getPreferredSize().width + 4); } else { x -= 4; } super.setBounds(x, y, width, height); }
/** * see IZ#176678 do not wrap lines in TreeCellRenderer if it's html * To make html renderer not to wrap the line - just extend width * to be large enough to fit all the text... * */ @Override public void setBounds(int x, int y, int width, int height) { int strw = 0; if (width > 0 && height > 0) { cellwidth = width; cellheight = height; // Avoid html wrapping - make sure that string fits strw = (int) HtmlRenderer.renderHTML(node.getHtmlDisplayName() + ' ', scratchGraphics, x, y, width, height, getFont(), Color.black, HtmlRenderer.STYLE_CLIP, false); } super.setBounds(x, y, Math.max(width, strw) + 10, height); }