动作侦听器中的动作侦听器错误

MLG_NO_Scoper_DEW-DRINKER

因此,我在JButton ActionListener内有一个重命名的JFrame。以下文字是

JFrame rename = new JFrame("Rename File");

//other code
JButton renameb = new JButton();

renameb.addActionListener(new ActionListener()
    {
        @Override
        public void actionPerformed(ActionEvent e)
        {
            Console.file = namef.getText();
            dispose();


        }
    });

每当我运行它时,它只会显示以下内容:

http://sp.itbind.com/s/misha/Screen%20Shot%202016-11-17%20at%2011.05.27%20PM.png(我必须放置一个链接,因为复制粘贴无效)

一句话

更改String filen = file + ".txt";String filen = file.getText() + ".txt";

现在的根本原因Exception in thread AWT-EventQueue-0 java.lang.IllegalArgumentException是您缺少以下行

rename.setLayout(new GridBagLayout());
JFrame rename = new JFrame("Rename File");

注意:要使用,GridBagConstraints您需要设置LayoutGridBagLayout

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章