[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] MetalBorder.paintBorder strangeness
From: |
Mark Wielaard |
Subject: |
Re: [cp-patches] MetalBorder.paintBorder strangeness |
Date: |
Sun, 02 Oct 2005 17:04:04 +0200 |
Hi David,
On Sat, 2005-10-01 at 21:33 +0000, David Gilbert wrote:
> Mark Wielaard wrote:
> >Here is another patch made during a DevJam hacking session.
> >The patch made an application work. But the code looks somewhat strange
> >to me. Should paintBorder really explicitly check for a JTextComponent
> >here?
>
> This looks OK to me. Under the MetalLookAndFeel, a JTextField that is
> enabled but not editable uses the same border as a disabled JTextField.
> The only way (I think) to check the editable state is via the
> isEditable() method in JTextComponent. Roman can probably confirm this:
>
> > 2005-09-12 Roman Kennke <address@hidden>
> >
> > * javax/swing/plaf/metal/MetalBorders.java
> > (TableHeaderBorder): New inner class.
> > (TextFieldBorder.paintBorder): Only paint the active border
> > if the text field is enabled _and_ editable.
> > * javax/swing/plaf/metal/MetalLookAndFeel.java
> > (initComponentDefaults): Added default to use the new
> > TableHeaderBorder for table headers.
OK. In that case I propose it as follows (with a more meaningful boolean
name):
2005-10-01 Mark Wielaard <address@hidden>
* javax/swing/plaf/metal/MetalBorders.java (paintBorder): Check
whether Component is JTextComponent.
Roman, what do you think?
Cheers,
Mark
Index: javax/swing/plaf/metal/MetalBorders.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.24
diff -u -r1.24 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java 28 Sep 2005 12:45:32 -0000
1.24
+++ javax/swing/plaf/metal/MetalBorders.java 2 Oct 2005 15:02:13 -0000
@@ -463,8 +463,16 @@
public void paintBorder(Component c, Graphics g, int x, int y, int w,
int h)
{
- JTextComponent tc = (JTextComponent) c;
- if (tc.isEnabled() && tc.isEditable())
+ boolean enabledTextBorder;
+ if (c instanceof JTextComponent)
+ {
+ JTextComponent tc = (JTextComponent) c;
+ enabledTextBorder = tc.isEnabled() && tc.isEditable();
+ }
+ else
+ enabledTextBorder = false;
+
+ if (enabledTextBorder)
super.paintBorder(c, g, x, y, w, h);
else
{
signature.asc
Description: This is a digitally signed message part