Browse Source

修改一下控件

master
xiaoxia 8 years ago
parent
commit
0d8e87ef31
  1. 9
      designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

9
designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

@ -107,14 +107,16 @@ public class UITreeComboBox extends JComboBox{
class UITreeComboBoxRenderer extends DefaultListCellRenderer { class UITreeComboBoxRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus){ int index, boolean isSelected, boolean cellHasFocus){
if(value != null){ if(tree != null ){
TreePath path = (TreePath)value; TreePath path = tree.getSelectedTreePath()[0];
tree.setAndScrollSelectionPath(path);
Object node = path.getLastPathComponent(); Object node = path.getLastPathComponent();
value = node; value = node;
TreeCellRenderer r = tree.getCellRenderer(); TreeCellRenderer r = tree.getCellRenderer();
JLabel lb = (JLabel)r.getTreeCellRendererComponent( JLabel lb = (JLabel)r.getTreeCellRendererComponent(
tree, value, isSelected, false, false, index, tree, value, isSelected, false, false, index,
cellHasFocus); cellHasFocus);
return lb; return lb;
} }
return super.getListCellRendererComponent(list, value, index, return super.getListCellRendererComponent(list, value, index,
@ -138,6 +140,9 @@ public class UITreeComboBox extends JComboBox{
setSelectedItem(paths[0]); setSelectedItem(paths[0]);
MenuSelectionManager.defaultManager().clearSelectedPath(); MenuSelectionManager.defaultManager().clearSelectedPath();
} else { } else {
tree.refreshUI();
tree.refreshTreeRoot();
repaint();
return; return;
} }

Loading…
Cancel
Save