breadcrumbs: imrpove UI
authorNiki Roo <niki@nikiroo.be>
Fri, 24 Apr 2020 19:18:28 +0000 (21:18 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 24 Apr 2020 19:18:28 +0000 (21:18 +0200)
src/be/nikiroo/utils/ui/BreadCrumbsBar.java

index 0aea666aafb79da226422679ab508c05fc15d64a..ed20f92916d6809106bedd430c08b9da1de1526a 100644 (file)
@@ -13,7 +13,6 @@ import java.util.List;
 
 import javax.swing.AbstractAction;
 import javax.swing.BoxLayout;
-import javax.swing.JButton;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JToggleButton;
@@ -23,25 +22,28 @@ import javax.swing.event.PopupMenuListener;
 
 public class BreadCrumbsBar<T> extends ListenerPanel {
        private class BreadCrumb extends JPanel {
-               private JButton button;
+               private JToggleButton button;
                private JToggleButton down;
 
                public BreadCrumb(final DataNode<T> node) {
                        this.setLayout(new BorderLayout());
 
-                       button = new JButton(node.toString());
                        if (!node.isRoot()) {
-                               // TODO: allow clicking on root? option?
+                               button = new JToggleButton(node.toString());
                                button.addActionListener(new ActionListener() {
                                        @Override
                                        public void actionPerformed(ActionEvent e) {
-                                               setSelectedNode(node);
+                                               button.setSelected(false);
+                                               if (!node.isRoot()) {
+                                                       // TODO: allow clicking on root? option?
+                                                       setSelectedNode(node);
+                                               }
                                        }
                                });
+                               
+                               this.add(button, BorderLayout.CENTER);
                        }
 
-                       this.add(button, BorderLayout.CENTER);
-
                        if (!node.getChildren().isEmpty()) {
                                // TODO (see things with icons included in viewer)
                                down = new JToggleButton(">");
@@ -49,7 +51,6 @@ public class BreadCrumbsBar<T> extends ListenerPanel {
 
                                for (final DataNode<T> child : node.getChildren()) {
                                        popup.add(new AbstractAction(child.toString()) {
-
                                                private static final long serialVersionUID = 1L;
 
                                                @Override
@@ -60,7 +61,6 @@ public class BreadCrumbsBar<T> extends ListenerPanel {
                                }
 
                                down.addActionListener(new ActionListener() {
-
                                        @Override
                                        public void actionPerformed(ActionEvent ev) {
                                                if (down.isSelected()) {