Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...