From 0d8e87ef311570f837299ff5e75f4f0b61c0b747 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 14 Oct 2016 18:44:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=8B=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/widget/UITreeComboBox.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java index 7f55ddeafe..a3a68ee83a 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -107,14 +107,16 @@ public class UITreeComboBox extends JComboBox{ class UITreeComboBoxRenderer extends DefaultListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){ - if(value != null){ - TreePath path = (TreePath)value; + if(tree != null ){ + TreePath path = tree.getSelectedTreePath()[0]; + tree.setAndScrollSelectionPath(path); Object node = path.getLastPathComponent(); value = node; TreeCellRenderer r = tree.getCellRenderer(); JLabel lb = (JLabel)r.getTreeCellRendererComponent( tree, value, isSelected, false, false, index, cellHasFocus); + return lb; } return super.getListCellRendererComponent(list, value, index, @@ -138,6 +140,9 @@ public class UITreeComboBox extends JComboBox{ setSelectedItem(paths[0]); MenuSelectionManager.defaultManager().clearSelectedPath(); } else { + tree.refreshUI(); + tree.refreshTreeRoot(); + repaint(); return; }