by JIDE Support » Wed Jan 28, 2009 11:14 am
I try your code and it works fine for me. Below is my testing code for your information. On one of my tests, it looks like the balloon tip was not shown when I set the position of the button in the top of the frame. However, it's actually hidden. Please try my code and feel free to let us know if you have any further issue.
- Code: Select all
import com.jidesoft.tooltip.BalloonTip;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class BalloonTipTest {
JButton ownerButton;
public BalloonTipTest() {
JFrame frame = new JFrame("Balloon Tip Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel(new GridBagLayout());
panel.setPreferredSize(new Dimension(400, 400));
ownerButton = new JButton("Click to show the Balloon Tooltip");
ownerButton.setToolTipText("Click to show the Balloon Tooltip");
ownerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BalloonTip _balloonTip = new BalloonTip(createToolTipContent());
_balloonTip.show(ownerButton, 0, 0);
}
});
panel.add(ownerButton);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.setBounds(200,200,200,200);
frame.pack();
frame.setVisible(true);
frame.toFront();
}
public static void main(String args[]) {
new BalloonTipTest();
}
private JPanel createToolTipContent() {
JPanel panel = new JPanel(new BorderLayout(12, 12));
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
panel.add(new JLabel("Test"));
JPanel fieldPanel = new JPanel(new BorderLayout(6, 6));
fieldPanel.setOpaque(false);
fieldPanel.add(new JLabel("Name:"), BorderLayout.BEFORE_LINE_BEGINS);
fieldPanel.add(new JTextField(20));
panel.add(fieldPanel, BorderLayout.AFTER_LAST_LINE);
panel.setOpaque(false);
return panel;
}
}
Thanks,
JIDE Software Technical Support Team