示例#1
0
 /** Sanity: icons updated on LF change. */
 public void testTreeIconsUpdateUI() {
   JXTree tree = new JXTree();
   DefaultTreeRenderer renderer = new DefaultTreeRenderer();
   tree.setCellRenderer(renderer);
   WrappingIconPanel before =
       (WrappingIconPanel)
           renderer.getTreeCellRendererComponent(tree, "", false, false, true, -1, false);
   Icon leaf = before.getIcon();
   assertNotNull("sanity", leaf);
   assertEquals("sanity", UIManager.getIcon("Tree.leafIcon"), leaf);
   String lf = UIManager.getLookAndFeel().getName();
   setSystemLF(!defaultToSystemLF);
   if (lf.equals(UIManager.getLookAndFeel().getName())) {
     LOG.info("cannot run test - equal LF" + lf);
     return;
   }
   SwingUtilities.updateComponentTreeUI(tree);
   WrappingIconPanel after =
       (WrappingIconPanel)
           renderer.getTreeCellRendererComponent(tree, "", false, false, true, -1, false);
   Icon leafAfter = after.getIcon();
   assertNotNull("sanity", leafAfter);
   assertFalse("sanity", leaf.equals(leafAfter));
   assertEquals("icon must be updated", UIManager.getIcon("Tree.leafIcon"), leafAfter);
 }
示例#2
0
 /**
  * base interaction with list: renderer uses list's unselected colors
  *
  * <p>currently, this test fails because the assumptions are wrong! Core renderer behaves slightly
  * unexpected.
  */
 public void testTreeRendererExtColors() {
   // prepare standard
   Component coreComponent =
       coreTreeRenderer.getTreeCellRendererComponent(tree, null, false, false, false, 0, false);
   // sanity: known standard behaviour
   assertNull(coreComponent.getBackground());
   //        assertNull(coreComponent.getForeground());
   assertNull(tree.getForeground());
   Color uiForeground = UIManager.getColor("Tree.textForeground");
   assertEquals(uiForeground, coreComponent.getForeground());
   // prepare extended
   Component xComponent =
       xTreeRenderer.getTreeCellRendererComponent(tree, null, false, false, false, 0, false);
   // assert behaviour same as standard
   //        assertEquals(coreComponent.getBackground(), xComponent.getBackground());
   assertEquals(coreComponent.getForeground(), xComponent.getForeground());
 }
示例#3
0
 /**
  * base interaction with list: renderer uses list's unselected custom colors.
  *
  * <p>currently, this test fails because the assumptions are wrong! Core renderer behaves slightly
  * unexpected.
  */
 public void testTreeRendererExtTreeColors() {
   Color background = Color.MAGENTA;
   Color foreground = Color.YELLOW;
   tree.setBackground(background);
   tree.setForeground(foreground);
   coreTreeRenderer.setBackgroundNonSelectionColor(background);
   coreTreeRenderer.setTextNonSelectionColor(foreground);
   // prepare standard
   Component coreComponent =
       coreTreeRenderer.getTreeCellRendererComponent(tree, null, false, false, false, 0, false);
   // sanity: known standard behaviour
   // background is manually painted
   assertEquals(background, coreComponent.getBackground());
   assertEquals(tree.getForeground(), coreComponent.getForeground());
   // prepare extended
   Component xComponent =
       xTreeRenderer.getTreeCellRendererComponent(tree, null, false, false, false, 0, false);
   // assert behaviour same as standard
   assertEquals(background, xComponent.getBackground());
   assertEquals(foreground, xComponent.getForeground());
 }