{"id":308,"date":"2015-11-06T11:19:22","date_gmt":"2015-11-06T00:19:22","guid":{"rendered":"https:\/\/learn-java-by-example.com\/?p=308"},"modified":"2015-11-20T18:34:39","modified_gmt":"2015-11-20T07:34:39","slug":"jscrollpane-display-scroll-bars","status":"publish","type":"post","link":"https:\/\/learn-java-by-example.com\/java\/jscrollpane-display-scroll-bars\/","title":{"rendered":"How do I get a JScrollPane to always display scroll bars?"},"content":{"rendered":"

You can achieve this by setting the scroll bar policy on both the verical and horizontal scroll bars.<\/p>\n

\r\n\r\nJScrollPane scrollPane = new JScrollPane(panel);\r\n    \r\n\/\/ Force the scrollbars to always be displayed\r\n\r\nscrollPane.setHorizontalScrollBarPolicy(\r\n   JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);\r\nscrollPane.setVerticalScrollBarPolicy(\r\n   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); \r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

You can achieve this by setting the scroll bar policy on both the verical and horizontal scroll bars.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[4,15,89],"tags":[90,91],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6Yyl2-4Y","jetpack-related-posts":[{"id":25,"url":"https:\/\/learn-java-by-example.com\/slider\/learn-java-the-easy-way\/","url_meta":{"origin":308,"position":0},"title":"Learn Java the Easy Way","date":"January 1, 2011","format":false,"excerpt":"One of the easiest ways to learn Java programming is by studying examples of solutions to a variety of programming problems. \"Learn Java by Example\" is the perfect companion to anyone studying Java development, providing a wealth of example Java code to complement the coding skills being taught to you.","rel":"","context":"In "Slider"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":253,"url":"https:\/\/learn-java-by-example.com\/java\/copy-file-java-6\/","url_meta":{"origin":308,"position":1},"title":"How to copy a file using Java 6","date":"July 10, 2015","format":false,"excerpt":"Prior to Java 7, Java did not provide a standard method to copy a file. To implement copying you needed to read all bytes from source file and write to destination. The read() method will return -1 when eof is reached, otherwise it returns the number of bytes read.","rel":"","context":"In "Java"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":32,"url":"https:\/\/learn-java-by-example.com\/slider\/quality-java-code\/","url_meta":{"origin":308,"position":2},"title":"Quality Java Code","date":"June 1, 2011","format":false,"excerpt":"All our Java code is developed, tested and reviewed by developers with decades of Java experience. The code is also well commented allowing you to easily understand what is being done.","rel":"","context":"In "Slider"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":39,"url":"https:\/\/learn-java-by-example.com\/slider\/teach-yourself-java\/","url_meta":{"origin":308,"position":3},"title":"Teach Yourself Java","date":"June 1, 2011","format":false,"excerpt":"\"Learn Java by Example\" is ideal for people who want to learn Java by themselves. A perfect reference as well as providing you with a virtual tutor for when you have questions.","rel":"","context":"In "Slider"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":235,"url":"https:\/\/learn-java-by-example.com\/java\/check-java-string-integer\/","url_meta":{"origin":308,"position":4},"title":"How to check if a Java String is an integer?","date":"June 5, 2015","format":false,"excerpt":"The Integer class has a number of static methods for parsing strings. For the case where we want to check if if a string contains a valid integer we can use the method Integer.parseInt() and catch the exception that is thrown when the number cannot be parsed.","rel":"","context":"In "Java"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":339,"url":"https:\/\/learn-java-by-example.com\/java\/scanner-read-words-text-file\/","url_meta":{"origin":308,"position":5},"title":"Using Scanner to read words from text file","date":"November 20, 2014","format":false,"excerpt":"Often you need to read a file line by line. Alternatively sometimes you want to read text word by word (for example to count the occurrence of different words). The Scanner classes next() method can be used for this as shown in the following example. You can find an example\u2026","rel":"","context":"In "Java"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/posts\/308"}],"collection":[{"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":3,"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/posts\/308\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn-java-by-example.com\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}