Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

java - I get some wired error with JOptionPane it says IllegalArgumentException

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.

this is the code example

    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);

it says this

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...