changeset 5837:1785f8335f4d

6994562: Swing classes (both JTextArea and JTextField) don't support caret width tuning Reviewed-by: rupashka, art
author VKARNAUK
date Fri, 14 Sep 2012 19:51:14 +0400
parents 77fdcd3df205
children b6ad3339f3f4
files src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java src/share/classes/javax/swing/text/DefaultCaret.java src/windows/native/sun/windows/awt_DesktopProperties.cpp src/windows/native/sun/windows/awt_DesktopProperties.h
diffstat 4 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Fri Sep 14 15:30:46 2012 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Fri Sep 14 19:51:14 2012 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -644,6 +644,9 @@
                    "released SPACE", "released"
                  }),
 
+            "Caret.width",
+                  new DesktopProperty("win.caret.width", null),
+
             "CheckBox.font", ControlFont,
             "CheckBox.interiorBackground", WindowBackgroundColor,
             "CheckBox.background", ControlBackgroundColor,
--- a/src/share/classes/javax/swing/text/DefaultCaret.java	Fri Sep 14 15:30:46 2012 +0400
+++ b/src/share/classes/javax/swing/text/DefaultCaret.java	Fri Sep 14 19:51:14 2012 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1503,9 +1503,14 @@
 
         if (caretWidth > -1) {
             return caretWidth;
+        } else {
+            Object property = UIManager.get("Caret.width");
+            if (property instanceof Integer) {
+                return ((Integer) property).intValue();
+            } else {
+                return 1;
+            }
         }
-
-        return 1;
     }
 
     // --- serialization ---------------------------------------------
--- a/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Fri Sep 14 15:30:46 2012 +0400
+++ b/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Fri Sep 14 19:51:14 2012 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,6 +70,7 @@
     GetNonClientParameters();
     GetIconParameters();
     GetColorParameters();
+    GetCaretParameters();
     GetOtherParameters();
     GetSoundEvents();
     GetSystemProperties();
@@ -636,6 +637,10 @@
     SetSoundProperty(TEXT("win.sound.start"), TEXT("SystemStart"));
 }
 
+void AwtDesktopProperties::GetCaretParameters() {
+    SetIntegerProperty(TEXT("win.caret.width"), GetIntegerParameter(SPI_GETCARETWIDTH));
+}
+
 BOOL AwtDesktopProperties::GetBooleanParameter(UINT spi) {
     BOOL        flag;
     SystemParametersInfo(spi, 0, &flag, 0);
--- a/src/windows/native/sun/windows/awt_DesktopProperties.h	Fri Sep 14 15:30:46 2012 +0400
+++ b/src/windows/native/sun/windows/awt_DesktopProperties.h	Fri Sep 14 19:51:14 2012 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,6 +64,7 @@
         void GetColorParameters();
         void GetOtherParameters();
         void GetSoundEvents();
+        void GetCaretParameters();
 
         static BOOL GetBooleanParameter(UINT spi);
         static UINT GetIntegerParameter(UINT spi);