classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] MetalBorder.paintBorder strangeness


From: David Gilbert
Subject: Re: [cp-patches] MetalBorder.paintBorder strangeness
Date: Sat, 01 Oct 2005 21:33:23 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050728)

Mark Wielaard wrote:

Hi,

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?

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    1 Oct 2005 20:04:30 -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 do_super;
+      if (c instanceof  JTextComponent)
+       {
+         JTextComponent tc = (JTextComponent) c;
+         do_super = tc.isEnabled() && tc.isEditable();
+       }
+      else
+       do_super = false;
+
+      if (do_super)
        super.paintBorder(c, g, x, y, w, h);
      else
        {
Hi Mark,

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.


Regards,

Dave




reply via email to

[Prev in Thread] Current Thread [Next in Thread]