public ResourceTree(ResourceTreeModel treemodel) {
    tree.setCellRenderer(new ResourceTreeRenderer());
    tree.addKeyListener(new TreeKeyListener());
    tree.addMouseListener(new TreeMouseListener());
    tree.setModel(treemodel);
    tree.putClientProperty("JTree.lineStyle", "Angled");
    tree.clearSelection();
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setRootVisible(false);
    tree.addTreeSelectionListener(this);
    tree.setShowsRootHandles(true);

    bnext.addActionListener(this);
    bprev.addActionListener(this);
    bnext.setEnabled(false);
    bprev.setEnabled(false);
    bnext.setHorizontalTextPosition(SwingConstants.LEADING);
    bnext.setMargin(new Insets(3, 1, 3, 1));
    bprev.setMargin(bnext.getMargin());

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 2));
    panel.add(bprev);
    panel.add(bnext);

    setLayout(new BorderLayout());
    add(new JScrollPane(tree), BorderLayout.CENTER);
    add(panel, BorderLayout.SOUTH);
  }
Example #2
0
  private JButton createButton(Icon icon, final int sign) {
    JButton button = new JButton(icon);
    Insets buttonMargin = new Insets(button.getMargin().top, 0, button.getMargin().bottom, 0);
    button.setMargin(buttonMargin);
    button.setFocusable(false);
    button.getInsets().right = 0;
    button.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mousePressed(MouseEvent e) {
            incActionListener.init(sign);
            incActionListener.actionPerformed(null);
            incTimer.start();
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            incTimer.stop();
          }
        });
    return button;
  }