void (String[] args) { IconLoader.activate(); final JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout()); final JPanel content = new JPanel(new BorderLayout()); frame.getContentPane().add(content, BorderLayout.CENTER); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); final JTree tree = new Tree(); TreeTestUtil.assertTreeUI(tree); content.add(tree); final Ref<BalloonImpl> balloon = new Ref<>(); tree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (balloon.get() != null && balloon.get().isVisible()) { //noinspection SSBasedInspection balloon.get().dispose(); } else { //JLabel pane1 = new JLabel("Hello, world!"); //JLabel pane2 = new JLabel("Hello, again"); //JPanel pane = new JPanel(new BorderLayout()); //pane.add(pane1, BorderLayout.CENTER); //pane.add(pane2, BorderLayout.SOUTH); //pane.setBorder(new LineBorder(Color.blue)); balloon.set(new BalloonImpl( new JLabel("Content"), Color.black, null , MessageType.ERROR.getPopupBackground(), true, true, true, true, true, true, 0, true, false, null, false, 500, 25, 0, 0, false, "This is the title", JBUI.insets(2), true, false, false, Balloon.Layer.normal, false, null, -1)); balloon.get().setShowPointer(true); if (e.isShiftDown()) { balloon.get().show(new RelativePoint(e), Balloon.Position.above); } else if (e.isAltDown()) { balloon.get().show(new RelativePoint(e), Balloon.Position.below); } else if (e.isMetaDown()) { balloon.get().show(new RelativePoint(e), Balloon.Position.atLeft); } else { balloon.get().show(new RelativePoint(e), Balloon.Position.atRight); } } } }); tree.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { System.out.println(e.getPoint()); } }); frame.setBounds(300, 300, 300, 300); frame.setVisible(true); }