在JButton上添加图片无法显示

在JButton上添加图片无法显示,可以正确获取到url
class TestButton extends JFrame{
    public TestButton() throws IOException {
        Container container=getContentPane();
        //获取当前类下的tx.jpg文件
        URL url=TestButton.class.getResource("tx.jpg");
        //图片变图标
        ImageIcon imageIcon=new ImageIcon(url);
        JButton bt=new JButton("Hello");

        //将图标设置在按钮上
        bt.setIcon(imageIcon);
        //图标设置悬浮窗
        bt.setToolTipText("图片按钮");

        container.add(bt);
        setVisible(true);
        setBounds(100,100,1000,400);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
}