我收到JOptionPane的一些有线错误,内容为IllegalArgumentException [英] I get some wired error with JOptionPane it says IllegalArgumentException

查看:82
本文介绍了我收到JOptionPane的一些有线错误,内容为IllegalArgumentException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试自己做一些GUI,并在youtube上找到了一个使用它的示例.它可以在他的屏幕上显示,但不能在我的计算机上显示.

I tried to do some GUI by myself and i found an example on the youtube where one is using it. it works on his screen but not on my computer.

这是代码示例

    SP_CONVERSATION.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    SP_CONVERSATION.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    SP_CONVERSATION.setViewportView(TA_Conversation);
    MainWindow.getContentPane().add(SP_CONVERSATION);
    SP_CONVERSATION.setBounds(10, 90, 330, 180);

它是这样

Exception in thread "main" java.lang.IllegalArgumentException: invalid horizontalScrollBarPolicy
at javax.swing.JScrollPane.setHorizontalScrollBarPolicy(Unknown Source)

我对此很陌生,所以我不知道该怎么做

And i kinda new to this, so i dont know what to do

推荐答案

按如下所示将常量更改为JScrollPane,它应该可以工作.

Change the constants to JScrollPane as below, and it should work.

SP_CONVERSATION.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
SP_CONVERSATION.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

这篇关于我收到JOptionPane的一些有线错误,内容为IllegalArgumentException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆