@Override public JComponent getContent() { if (this.obj == null) { throw new IllegalStateException("No object set."); } // TODO: Make this nicer later. if (this.obj instanceof Chapter) { Chapter c = (Chapter) this.obj; JComponent t = UIUtils.getChapterInfoPreview(c, null, this.viewer); if (t == null) { // May be a fake chapter, return null. return null; } t.setSize(new Dimension(300, Short.MAX_VALUE)); return t; } else { String firstLine = "<b><i>No description.</i></b>"; String t = (obj.getDescription() != null ? obj.getDescription().getText() : null); if ((t != null) && (t.length() > 0)) { firstLine = new Paragraph(t, 0).getFirstSentence().getText(); } JEditorPane desc = UIUtils.createHelpTextPane(firstLine, null); FormLayout fl = new FormLayout("380px", "p"); PanelBuilder pb = new PanelBuilder(fl); CellConstraints cc = new CellConstraints(); pb.add(desc, cc.xy(1, 1)); desc.setAlignmentX(Component.LEFT_ALIGNMENT); JPanel p = pb.getPanel(); p.setOpaque(true); p.setBackground(UIUtils.getComponentColor()); return p; } }