-
Bug
-
Resolution: Unresolved
-
P4
-
7, 8, 9
-
x86
-
windows_8
FULL PRODUCT VERSION :
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Owner>java -version
java version "1.8.0_71"
Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
Java HotSpot(TM) Client VM (build 25.71-b15, mixed mode)
C:\Users\Owner>
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Owner>ver
Microsoft Windows [Version 6.3.9600]
C:\Users\Owner>
A DESCRIPTION OF THE PROBLEM :
Using the native look and feel is pretty consistent with the painting of basic buttons and controls. This specific issue is about the extra focus painting on the buttons when they are focused. It is completely unnecessary and makes the controls look ugly. Without it the native look and feel looks truly more native.
This is also a common issue with GTK applications on Windows. That is unrelated to Java/Swing but the exact issue does exist in that API.
A screenshot emphasizes the difference between the Swing look and feel and Windows Forms. The highlighted button in blue shows an extra dark dotted border in the Swing version.
http://i.imgur.com/sknXVim.png
The Windows Look and Feel needs to disable focus painting by default for all the controls on which it is not required, starting with ButtonUI.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a Swing application
2) Enable the Windows look and feel
3) Create a toolbar with a few buttons
4) Click/focus on a button and notice the extra focus border
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect basic buttons and toolbar buttons to have no additional focus painting than the native Windows look and feel needs. It should have no additional focus painting.
ACTUAL -
Additional focus painting is added in the form of a dotted border to basic buttons, checkboxes, toolbar buttons, and various other controls.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class FocusPaintingBugs {
private static JButton createButton() {
JButton button = new JButton("Test");
return button;
}
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event dispatch thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("ToolBarDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JToolBar toolbar = new JToolBar();
toolbar.add(createButton());
toolbar.add(createButton());
toolbar.add(createButton());
toolbar.add(createButton());
toolbar.add(createButton());
//Add content to the window.
frame.add(toolbar, BorderLayout.NORTH);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
// Set the Windows Look and Feel
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The work around requires setting button.setFocusPainted(false); on every single control that isn't supposed to have it in order to look truly native. But this not ideal because it should be the default for what is the *native* look and feel.
SUPPORT :
YES
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Owner>java -version
java version "1.8.0_71"
Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
Java HotSpot(TM) Client VM (build 25.71-b15, mixed mode)
C:\Users\Owner>
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Owner>ver
Microsoft Windows [Version 6.3.9600]
C:\Users\Owner>
A DESCRIPTION OF THE PROBLEM :
Using the native look and feel is pretty consistent with the painting of basic buttons and controls. This specific issue is about the extra focus painting on the buttons when they are focused. It is completely unnecessary and makes the controls look ugly. Without it the native look and feel looks truly more native.
This is also a common issue with GTK applications on Windows. That is unrelated to Java/Swing but the exact issue does exist in that API.
A screenshot emphasizes the difference between the Swing look and feel and Windows Forms. The highlighted button in blue shows an extra dark dotted border in the Swing version.
http://i.imgur.com/sknXVim.png
The Windows Look and Feel needs to disable focus painting by default for all the controls on which it is not required, starting with ButtonUI.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a Swing application
2) Enable the Windows look and feel
3) Create a toolbar with a few buttons
4) Click/focus on a button and notice the extra focus border
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect basic buttons and toolbar buttons to have no additional focus painting than the native Windows look and feel needs. It should have no additional focus painting.
ACTUAL -
Additional focus painting is added in the form of a dotted border to basic buttons, checkboxes, toolbar buttons, and various other controls.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class FocusPaintingBugs {
private static JButton createButton() {
JButton button = new JButton("Test");
return button;
}
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event dispatch thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("ToolBarDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JToolBar toolbar = new JToolBar();
toolbar.add(createButton());
toolbar.add(createButton());
toolbar.add(createButton());
toolbar.add(createButton());
toolbar.add(createButton());
//Add content to the window.
frame.add(toolbar, BorderLayout.NORTH);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
// Set the Windows Look and Feel
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The work around requires setting button.setFocusPainted(false); on every single control that isn't supposed to have it in order to look truly native. But this not ideal because it should be the default for what is the *native* look and feel.
SUPPORT :
YES