|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Newbie - setting column alignment in JXTreeTableGreetings,
I am new to the swingx libraries and am trying to set the alignment for a column in a treetable. I have searched high and low with no luck so would appreciate any help. Here is a snippet of what I'm trying to do: JXTreeTable tree = new JXTreeTable(); .... TableColumn column = tree.getColumnModel().getColumn(1); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setAlignmentX(Component.CENTER_ALIGNMENT); column.setCellRenderer(renderer); Thanks, Kip [Message sent by forum member 'kip' (kip)] http://forums.java.net/jive/thread.jspa?messageID=287769 --------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@... For additional commands, e-mail: jdnc-help@... |
|
|
Re: Newbie - setting column alignment in JXTreeTableHi. Highlighters are good for UI stuff:
[code] import java.awt.Component; import javax.swing.JLabel; import javax.swing.SwingConstants; import org.jdesktop.swingx.decorator.AbstractHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; import org.jdesktop.swingx.decorator.HighlightPredicate; /** * * @author Martin Miller */ public class AlignmentHighlighter extends AbstractHighlighter implements SwingConstants { public int alignment; public AlignmentHighlighter(int alignment) { this(alignment, null); } public AlignmentHighlighter(int alignment, HighlightPredicate predicate) { super(predicate); this.alignment = alignment; } protected Component doHighlight(Component renderer, ComponentAdapter adapter) { applyAlignment(renderer, adapter); return renderer; } protected void applyAlignment(Component renderer, ComponentAdapter adapter) { ((JLabel)renderer).setHorizontalAlignment(alignment); } } [/code] Example Usage: [code] addHighlighter(new AlignmentHighlighter(AlignmentHighlighter.CENTER, new ColumnHighlightPredicate(**column #***))); [/code] [Message sent by forum member 'martinm1000' (martinm1000)] http://forums.java.net/jive/thread.jspa?messageID=287940 --------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@... For additional commands, e-mail: jdnc-help@... |
|
|
Re: Newbie - setting column alignment in JXTreeTablejdnc-interest@... schrieb:
> I am new to the swingx libraries and am trying to set the alignment for a column in a treetable. I have searched high and low with no luck so would appreciate any help. > > how about reading the javadoc of the classes in the renderer package ;-) Alignment is (arguably, Martin - Highlighters are fine as well :-) part of the default visual configuration and can be set in SwingX default renderers like [code] treeTable.getColumn(1).setCellRenderer( new DefaultTableRenderer(null, JLabel.CENTER)); [/code] (Note to myself: add constructors which take alignment as single parameter) > DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); > renderer.setAlignmentX(Component.CENTER_ALIGNMENT); > - don't use core default renderers (they don't play nicely with SwingX Highlighters) - the not-working of the alignmentX has nothing to do with SwingX (I think you should read up on the difference between alignmentX vs. horizontalAlignment :-) HTH Jeanette --------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@... For additional commands, e-mail: jdnc-help@... |
|
|
Re: Newbie - setting column alignment in JXTreeTableCan't remember if this was ever mooted before but have you thought about logging or throwing a RTFMException<g> if anyone tried to attach one of the default core renderers to a JXComponent? or would that be taking the whole imperial thing too far? ;)
Aren't they OK if you don't use highlighters nor painters or the column sorting? [Message sent by forum member 'osbald' (osbald)] http://forums.java.net/jive/thread.jspa?messageID=288333 --------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@... For additional commands, e-mail: jdnc-help@... |
| Free Forum Powered by Nabble | Forum Help |