Article View: borland.public.jbuilder.java.swing
Article #11897Re: JTable and JLabel justification problem.
From: Vasudevan Srinivasan
Date: Thu, 11 Mar 1999 00:00
Date: Thu, 11 Mar 1999 00:00
40 lines
1719 bytes
1719 bytes
Where and How are you setting tableCellRenderer to the table? The problem might be in the order of initialization The correct order should be: customCellRenderer ccr; JTable jtable1; jtable1 = new JTable(); ... ccr = new customCellRenderer(jtable1); if you initialize cutomCellRenderer during the declaration itself (before jTable1 init), you might have this problem. HTH Vasu Andy Jeffrey wrote: > Hi, > > I'm using a JTable and a JLabel as my TableCellRenderer and have set 'left' > justification. When I go to the table, the number is 'left' justified. On > the first mouse click, the integer jumps to the right and then back to left > justified on the second mouse click or a key stroke. > > This code is in the 'getTableCellRendererComponent' method as part of my > TableTableCellRenderer: > > String text = dataValues == null ? "" : dataValues.toString(); > label.setText(text); > label.setOpaque(true); > label.setHorizontalAlignment(JLabel.LEFT); > //label.setHorizontalTextPosition(JLabel.LEFT); > > Has anybody seen this behaviour and know of a workaround? > > Regards, > > Andy.
Technical Details
Message-ID:
<36E807B1.473F4558@netrisk.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7c8tk7$lmn27@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,160106612556f3ca X-Google-Attributes: gid111d45,public From: Vasudevan Srinivasan <vasudevan@netrisk.com> Subject: Re: JTable and JLabel justification problem. Date: 1999/03/11 Message-ID: <36E807B1.473F4558@netrisk.com> X-Deja-AN: 453877327 Content-Transfer-Encoding: 7bit References: <7c8tk7$lmn27@forums.borland.com> To: Andy Jeffrey <andy.jeffrey@capgemini.co.uk> Content-Type: text/plain; charset=us-ascii Organization: NetRisk Inc Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing