[cp-patches] FYI: JComponent fixlet
This makes JComponent.scrollRectToVisible() behave more elegantly when there are non-JComponents in the tree. This can be important, because there actually are some of these even in Swing (like the CellRendererPane). 2006-08-17 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (scrollRectToVisible): Handle intermediate non-JComponents more gracefully. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.142 diff -u -1 -2 -r1.142 JComponent.java --- javax/swing/JComponent.java 29 Jul 2006 22:33:51 - 1.142 +++ javax/swing/JComponent.java 17 Aug 2006 15:11:18 - @@ -2568,25 +2568,25 @@ // This is step 4 from above comment. KeyboardManager maintains mappings // related to WHEN_IN_FOCUSED_WINDOW bindings so that we don't have to // traverse the containment hierarchy each time. if (KeyboardManager.getManager().processKeyStroke(current, keyStroke, e)) e.consume(); } protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) - { + { if (isEnabled()) { Action act = null; Object cmd = null; InputMap map = getInputMap(condition); if (map != null) { cmd = map.get(ks); if (cmd != null) { if (cmd instanceof ActionListenerProxy) act = (Action) cmd; @@ -2732,27 +2732,43 @@ RepaintManager.currentManager(this).addInvalidComponent(this); } } /** * Calls codescrollRectToVisible/code on the component's parent. * Components which can service this call should override. * * @param r The rectangle to make visible */ public void scrollRectToVisible(Rectangle r) { -Component p = getParent(); -if (p instanceof JComponent) - ((JComponent) p).scrollRectToVisible(r); +// Search nearest JComponent. +int xOffs = getX(); +int yOffs = getY(); +Component p; +for (p = getParent(); p != null ! (p instanceof JComponent); + p = p.getParent()) + { +xOffs += p.getX(); +yOffs += p.getY(); + } +if (p != null) + { +r.x += xOffs; +r.y += yOffs; +JComponent jParent = (JComponent) p; +jParent.scrollRectToVisible(r); +r.x -= xOffs; +r.y -= yOffs; + } } /** * Set the value of the [EMAIL PROTECTED] #alignmentX} property. * * @param a The new value of the property */ public void setAlignmentX(float a) { if (a 0.0F) alignmentX = 0.0F; else if (a 1.0)
[cp-patches] FYI: JComponent fixlet
Hi, this makes my new JComponent mauve test pass. It protects the preferredSize field by creating a new Dimension object from it before returning the value. (Sidenote: yes, all the getPreferredSize() mauve tests should be 'ported' to getMinimumSize() and getMaximumSize() also and JComponent be fixed. I expect similar (expected) behaviour for these methods. I'll do this asap). 2005-12-15 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (getPreferredSize): Protect the preferredSize field from modification by creating a new Dimension object from it before returning the value. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.93 diff -u -r1.93 JComponent.java --- javax/swing/JComponent.java 12 Dec 2005 13:21:23 - 1.93 +++ javax/swing/JComponent.java 15 Dec 2005 17:47:24 - @@ -1294,7 +1294,7 @@ { Dimension prefSize = null; if (preferredSize != null) - prefSize = preferredSize; + prefSize = new Dimension(preferredSize); else if (ui != null) { ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: JComponent fixlet
Hi all, I committed the attached patch which makes the new JComponent Mauve test pass. 2005-12-12 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (getPreferredSize): Don't check for the minimumSize. According to a mauve test, this is not necessary. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.92 diff -u -r1.92 JComponent.java --- javax/swing/JComponent.java 8 Dec 2005 10:56:35 - 1.92 +++ javax/swing/JComponent.java 12 Dec 2005 13:19:48 - @@ -1305,12 +1305,7 @@ if (prefSize == null) prefSize = super.getPreferredSize(); -// make sure that prefSize is not smaller than minSize -if (minimumSize != null prefSize != null - (minimumSize.width prefSize.width -|| minimumSize.height prefSize.height)) -prefSize = new Dimension(Math.max(minimumSize.width, prefSize.width), - Math.max(minimumSize.height, prefSize.height)); + return prefSize; } ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: JComponent fixlet
I removed an unneeded warning in JComponent. We used to print out this warning when a component has no UI installed. This probably was useful in the early days when some components didn't have a UI class yet or something like that. Today such a warning is completely superfluous and confuses some users. Also, it actually is completely legal to have a component without an UI class. 2005-12-06 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (updateUI): Removed unneeded warning. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.90 diff -u -r1.90 JComponent.java --- javax/swing/JComponent.java 23 Nov 2005 15:39:11 - 1.90 +++ javax/swing/JComponent.java 6 Dec 2005 16:26:14 - @@ -2740,7 +2740,7 @@ */ public void updateUI() { -System.out.println(update UI not overwritten in class: + this); +// Nothing to do here. } public static Locale getDefaultLocale() ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: JComponent fixlet
Hi, I put the paint() call in paintDoubleBuffered() inside a try-finally block so that the flags are correctly cleaned up when an exception is thrown in paint(). 2005-11-15 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (paintDoubleBuffered): Put paint() call inside a try-finally block to correctly recover the double-buffering flag when an exception is thrown inside the paint() call. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.85 diff -u -r1.85 JComponent.java --- javax/swing/JComponent.java 15 Nov 2005 21:49:32 - 1.85 +++ javax/swing/JComponent.java 15 Nov 2005 23:05:37 - @@ -1918,9 +1918,15 @@ g2 = getComponentGraphics(g2); g2.setClip(r.x, r.y, r.width, r.height); isPaintingDoubleBuffered = true; -paint(g2); -isPaintingDoubleBuffered = false; -g2.dispose(); +try + { +paint(g2); + } +finally + { +isPaintingDoubleBuffered = false; +g2.dispose(); + } // Paint the buffer contents on screen. g.drawImage(buffer, 0, 0, this); ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: JComponent fixlet
I committed the attached fix that moves the getComponentGraphics() fetch from paintComponent() to paint(). Some simple tests show that this is the right thing and it also fixes a problem with an app I have here. 2005-11-09 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (paint): Fetch a new componentGraphics here instead of paintComponent. (paintComponent): Don't fetch the componentGraphics here. This must be done in paint. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.77 diff -u -r1.77 JComponent.java --- javax/swing/JComponent.java 8 Nov 2005 13:53:59 - 1.77 +++ javax/swing/JComponent.java 9 Nov 2005 14:41:55 - @@ -1685,10 +1685,11 @@ { if (g.getClip() == null) g.setClip(0, 0, getWidth(), getHeight()); -paintComponent(g); -paintBorder(g); -paintChildren(g); -Rectangle clip = g.getClipBounds(); +Graphics g2 = getComponentGraphics(g); +paintComponent(g2); +paintBorder(g2); +paintChildren(g2); +Rectangle clip = g2.getClipBounds(); if (clip.x == 0 clip.y == 0 clip.width == getWidth() clip.height == getHeight()) RepaintManager.currentManager(this).markCompletelyClean(this); @@ -1785,7 +1786,7 @@ Graphics g2 = g; if (!(g instanceof Graphics2D)) g2 = g.create(); -ui.update(getComponentGraphics(g2), this); +ui.update(g2, this); if (!(g instanceof Graphics2D)) g2.dispose(); } ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: JComponent fixlet
I fixed the putClientProperty method, so that if a null value is specified, the corresponding key is removed from the Hashtable. Otherwise we would get a NPE here. 2005-07-21 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (putClientProperty): If value == null, remove the key from the Hashtable, otherwise we would get an NPE here. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.53 diff -u -r1.53 JComponent.java --- javax/swing/JComponent.java 21 Jul 2005 08:26:09 - 1.53 +++ javax/swing/JComponent.java 21 Jul 2005 14:31:43 - @@ -451,7 +451,10 @@ */ public final void putClientProperty(Object key, Object value) { -getClientProperties().put(key, value); +if (value != null) + getClientProperties().put(key, value); +else + getClientProperties().remove(key); } /** ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: JComponent fixlet
JComponent.getPreferredSize lets the ComponentUI override a manually set preferredSize. This is not allowed. The priority is as follows: (0. constrained by minimumSize) 1. user set preferredSize 2. ComponentUI preferredSize 3. Container preferredSize (LayoutManager) 4. Component preferredSize This is fixed. 2005-06-27 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (getPreferredSize): Don't let the UI replace a manually set preferred size. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.46 diff -u -r1.46 JComponent.java --- javax/swing/JComponent.java 20 Jun 2005 14:35:53 - 1.46 +++ javax/swing/JComponent.java 27 Jun 2005 14:57:18 - @@ -1022,12 +1022,13 @@ if (preferredSize != null) prefSize = preferredSize; -if (ui != null) +else if (ui != null) { Dimension s = ui.getPreferredSize(this); if (s != null) prefSize = s; } + if (prefSize == null) prefSize = super.getPreferredSize(); // make sure that prefSize is not smaller than minSize ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: JComponent fixlet and formatting fix
The attached patch fixes alignmentX and alignmentY to be 0.5 instead of 0.0. It also fixes various tab vs space formatting. I know that I should have sent this as two patches but accidently I committed all my day's work at once with MediaTracker. Sorry for that. 2005-04-12 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java: Modified alignmentX and alignmentY to be 0.5 instead of 0.0. Untabified the file. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- javax/swing/JComponent.java 16 Feb 2005 12:36:22 - 1.35 +++ javax/swing/JComponent.java 12 Apr 2005 19:48:43 - 1.36 @@ -175,7 +175,7 @@ * @see javax.swing.OverlayLayout * @see javax.swing.BoxLayout */ - float alignmentX = 0.0f; + float alignmentX = 0.5f; /** * A value between 0.0 and 1.0 indicating the preferred vertical @@ -190,7 +190,7 @@ * @see javax.swing.OverlayLayout * @see javax.swing.BoxLayout */ - float alignmentY = 0.0f; + float alignmentY = 0.5f; /** * The border painted around this component. @@ -1137,9 +1137,9 @@ */ public JToolTip createToolTip() { - JToolTip toolTip = new JToolTip(); - toolTip.setComponent(this); - toolTip.setTipText(toolTipText); +JToolTip toolTip = new JToolTip(); +toolTip.setComponent(this); +toolTip.setTipText(toolTipText); return toolTip; } @@ -1173,14 +1173,14 @@ toolTipText = null; return; } - + // XXX: The tip text doesn't get updated unless you set it to null // and then to something not-null. This is consistent with the behaviour // of Sun's ToolTipManager. - + String oldText = toolTipText; toolTipText = text; - + if (oldText == null) ToolTipManager.sharedInstance().registerComponent(this); } @@ -1428,7 +1428,7 @@ g2 = doubleBuffer.getGraphics(); g2.setClip(g.getClipBounds()); } - + g2 = getComponentGraphics(g2); paintComponent(g2); paintBorder(g2); @@ -2273,7 +2273,7 @@ this.verifyInputWhenFocusTarget = verifyInputWhenFocusTarget; firePropertyChange(verifyInputWhenFocusTarget, - ! verifyInputWhenFocusTarget, - verifyInputWhenFocusTarget); + ! verifyInputWhenFocusTarget, + verifyInputWhenFocusTarget); } } ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches