uimanager

Swing: remove focus border from dialogues' buttons

家住魔仙堡 提交于 2019-11-28 01:30:27
I wonder how can I remove this grey border from buttons in dialogues? For simple JButtons I found a solution - just use button.setFocusPainted(false); But is there a simple way to perform the same for all buttons in all dialogues? I tried to look through UIManager properties, but it seems that there are no suitable parameters there. Thanks in advance! from JButtons API you can to use JButton.setFocusable() and with JButton.setBorderPainted(false); from UIManager have to override key (valid for whole JVM instance) . UIDefaults defaults = UIManager.getLookAndFeelDefaults(); defaults.put("Button

How to set jframe look and feel

天大地大妈咪最大 提交于 2019-11-27 06:07:54
问题 I am kind of confused on where to put this : try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch(Exception e){ } I did not extend the JFrame class but used JFrame f = new JFrame(); Thanks :D 回答1: Most common place to put this, is right inside your static void main(String[] args) method. Like so: public static void main(String[] args) { try { UIManager.setLookAndFeel("com.sun

Customizing Tree.collapsedIcon for a single JTree

空扰寡人 提交于 2019-11-27 05:37:32
I know that you can change the Tree.collapsedIcon for a all JTrees in an application using Swing using the UImanager . For example: UIManager.put("Tree.collapsedIcon",closedcabinet); I would like the flexibility of changing the Tree.collapsedIcon for individual JTrees in the same application with the end result being that the Tree.collpasedIcon could appear differently for different trees in the same application. I know how to customize individual icons using a custom renderer. For example, I use setIcon to set the icon of a leaf, SetOpenIcon to set the icon for a node that has children when

List of Java Swing UI properties? [closed]

↘锁芯ラ 提交于 2019-11-27 04:15:52
There seem to be a ton of UI properties that can be set with UIManager.put("key", value); Is there a list somewhere of all keys that can be set? Frank It depends on the Java implementation. Here is the simple code that you can run to see all available properties and their current values. public static void main(String[] args) { UIDefaults defaults = UIManager.getDefaults(); System.out.println(defaults.size()+ " properties defined !"); String[ ] colName = {"Key", "Value"}; String[ ][ ] rowData = new String[ defaults.size() ][ 2 ]; int i = 0; for(Enumeration e = defaults.keys(); e

Swing UIManager.getColor() keys

北城余情 提交于 2019-11-27 01:49:27
问题 Is there a list somewhere of the UIManager.getColor() keys for Swing? I can't seem to find it online, just occasional references to strings like "Panel.background" and "Table.selectionBackground" . 回答1: I was looking for the same thing and found this page as well as an excellent overview of all these properties on http://nadeausoftware.com/node/85. 回答2: I don't think there is a defined standard set of keys. But you could try this bit of code to list the ones currently available in

Changing the background color of a selected JToggleButton

白昼怎懂夜的黑 提交于 2019-11-26 23:35:27
问题 I am trying to change the color of a JToggleButton when it has been selected in a reliable, look and feel independent way. If using the Metal L&F, then using the UIManager is an approach: UIManager.put("ToggleButton.selected", Color.RED); Note : Iyy pointed out that I had a typo in the property name above, but I will leave it above for people getting here, but the actual property name is supposed to be: UIManager.put("ToggleButton.select", Color.RED); However, this does not work in my current

Swing: remove focus border from dialogues' buttons

孤人 提交于 2019-11-26 23:32:00
问题 I wonder how can I remove this grey border from buttons in dialogues? For simple JButtons I found a solution - just use button.setFocusPainted(false); But is there a simple way to perform the same for all buttons in all dialogues? I tried to look through UIManager properties, but it seems that there are no suitable parameters there. Thanks in advance! 回答1: from JButtons API you can to use JButton.setFocusable() and with JButton.setBorderPainted(false); from UIManager have to override key

How to change the background color for JPanels with Nimbus Look and Feel?

萝らか妹 提交于 2019-11-26 18:34:03
问题 I want to use a different background color for all my JPanels in an application. How can I do that when using Nimbus Look and Feel? I follow Changing the Color Theme to change the color of components in Nimbus Look and Feel. It only works sometimes, randomly . If I set a PropertyChagneListener before I change the color, it is only notified once . Here is some test code: public class RedPanels extends JFrame { public RedPanels() { JPanel panel = new JPanel(); add(panel); setPreferredSize(new

Setting the Default Font of Swing Program

廉价感情. 提交于 2019-11-26 11:43:52
I was wondering how to set the default font for my entire Java swing program. From my research it appears it can be done with UIManager , something to do with LookAndFeel , but I can't find specifically how to do it, and the UIManager appears pretty complicated. Romain Hippeau try: public static void setUIFont (javax.swing.plaf.FontUIResource f){ java.util.Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get (key); if (value instanceof javax.swing.plaf.FontUIResource) UIManager.put (key, f); } } Call

List of Java Swing UI properties? [closed]

房东的猫 提交于 2019-11-26 11:07:07
问题 There seem to be a ton of UI properties that can be set with UIManager.put(\"key\", value); Is there a list somewhere of all keys that can be set? 回答1: It depends on the Java implementation. Here is the simple code that you can run to see all available properties and their current values. public static void main(String[] args) { UIDefaults defaults = UIManager.getDefaults(); System.out.println(defaults.size()+ " properties defined !"); String[ ] colName = {"Key", "Value"}; String[ ][ ]