JScrollPane - SCROLL BAR width?

I currently have a JEditorPane inside a JScrollPane
Whenever I have content that exceeds the height of the JScrollPane, I get a scroll bar on the right. Unfortunately, I think this scroll bar is a bit TOO THICK and is unsightly. Is there anway I can explicitly specify the WIDTH of this scroll bar if and when it's needed? THANKS!

Try this when creating the layout:
JScrollBar vsb = JScrollPane.getVerticalScrollBar();
Dimension sbsize = vsb.getSize();
Dimension newsbsize = new Dimension(sbsize.getWidth() - 5 , sbsize.getHeight() );
vsb.setPreferredSize(newsbsize);
You could also try setting the Maximum size using vsb.setMaximumSize(newsbsize);
Adjust the 5 in the new Dimension line to control how much smaller the witdh is from normal.

Similar Messages

  • How can I widen the vertical scroll bar width in Firefox and Thunderbird?

    How can I widen the vertical scroll bar width in Firefox and Thunderbird?

    Hello,
    Try disabling graphics hardware acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.
    You might need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    Then perform these steps:
    *Click the orange Firefox button at the top left, then select the "Options" button, or, if there is no Firefox button at the top, go to Tools > Options.
    *In the Firefox options window click the ''Advanced'' tab, then select "General".
    *In the settings list, you should find the ''Use hardware acceleration when available'' checkbox. Uncheck this checkbox.
    *Now, restart Firefox and see if the problems persist.
    Additionally, please check for updates for your graphics driver by following the steps mentioned in the following Knowledge base articles:
    * [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    * [[Upgrade your graphics drivers to use hardware acceleration and WebGL]]
    Did this fix your problems? Please report back to us!
    Thank you.

  • JScrollPane  - scroll bar not visible

    I'm writing a graphical chat application where the user presses buttons to insert images into their message. The buttons reside in a JPanel with a GridLayout. As i have more buttons than can be physically seen on the screen I'm trying to use a JScrollPane encapsulated in the JPanel so that the user can scroll down the button list to select appropriate symbols. The problem i'm having is that the scroll bars do not appear so the user can only use symbols which are visible. Here is the code for what i'm trying to acheive.
    buttonPanel.setLayout(new GridLayout(9,3));
    buttonPanel.add(Button1);
    buttonPanel.add(Button2);
    buttonPanel.add(Button3);
    buttonPanel.add(Button4);
    .....etc to around Button100
    buttonHolder.add(new JScrollPane());
    buttonHolder.setPreferredSize(new Dimension(400,400));
    buttonHolder.setMaximumSize(new Dimension(400,400));I think I'm missing something from the add JScrollPane bit but I'm not sure what exactly!
    PLEASE HELP - this is for my third year dissertation and is the last bit I need to do before it is finished.

    First, you need to add your panel to the JScrollPane object. Then you add the JScrollPane object to the frame, not the panel itself.
    As for setting the scrollbars of the JScrollPane, you could try setVerticalScrollbarPolicy() and setHorzontalScrollbarPolicy().

  • JScrollPane scroll bar trouble on rebuild

    I've been working on this for hours (about 4 hours now) without finding the right solution, so maybe someone can help. I searched through a few pages of the forum but didn't see this exact issue. And the tutorial online doesn't help much.
    I have a JPanel in a JScrollPane in a JFrame. The JFrame has it's height reduced if its over a particular size (in the test case, it gets reduced). When it first loads, it's fine. However, if I rebuild the whole JFrame (some event causes the JPanel content to change, and refresh() is called again), the window remains the same size but the vertical scroll bar extends off the bottom of the frame. If I manually resize the frame with the mouse (even by 1 pixel), the scroll bar updates and looks correct again. What is the correct way to do this? Calling revalidate() on the JScrollPane after doing the setSize() doesn't do anything. And why does it work the first time when the JFrame is first built through the Constructor?
    example code:
    public class MyFrame extends JFrame {
        public MyFrame() {
            super();
            refresh();
        private void refresh() {
            JPanel jp = new JPanel();
            jp.setLayout(new SpringLayout());
            // add some stuff to jp
            JScrollPane scrollPane = new JScrollPane(
                JScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
            scrollPane.getViewport().add(jp);
            setContentPane(scrollPane);
            pack();
            if (getHeight() > MAX_HEIGHT) {
                setSize(getWidth(),MAX_HEIGHT);
    }

    When you have changed the content, call getRootPane().validate(); instead of pack(), as in this slightly modified version of your sample program:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MyFrame extends JFrame implements ActionListener {
        private static final int MAX_HEIGHT = 100;
        public MyFrame() {
            super();
            refresh(true);
        public static void main(String[] args) {
            MyFrame myFrame = new MyFrame();
            myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            myFrame.setVisible(true);
        private void refresh(boolean pack) {
            JPanel jp = new JPanel();
            jp.setLayout(new BoxLayout(jp,BoxLayout.Y_AXIS));
            JButton refreshButton = new JButton("Refresh");
            refreshButton.setActionCommand("refresh");
            refreshButton.addActionListener(this);
            jp.add(refreshButton);
            jp.add(new JLabel("Hello"));
            jp.add(new JLabel("There"));
            jp.add(new JLabel("Why"));
            jp.add(new JLabel("Doesn't"));
            jp.add(new JLabel("Refresh"));
            jp.add(new JLabel("Work"));
            JScrollPane scrollPane = new JScrollPane(
                ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
            scrollPane.getViewport().add(jp);
            setContentPane(scrollPane);
            if (pack) {
                pack();
            else {
                getRootPane().validate();
            if (getHeight() > MAX_HEIGHT) {
                setSize(getWidth(),MAX_HEIGHT);
        public void actionPerformed(ActionEvent ae) {
            refresh(false);
    }

  • WebView  scroll-bar width  – touch screen friendly

    How can I change the width of a WebView’s scroll-bar?
    I tried to change the padding and font size as suggested at
    [ https://forums.oracle.com/forums/thread.jspa?messageID=10409262 ]
    Although it works fine with TableView, it does not work for the WebView.
    Adjusting padding and font size only increases the height of scroll-bars increment/decrement buttons but the width remains default.
    The core problem is that I have a touch-screen driver with insufficient support for JavaFX TouchEvents (no SWIPE, SCROLL etc). It means that I received only mouse pressed/released and mouse move events. For that reason, I need to make my GUI (WebView, TableView,..) more user friendly.

    Where is there a scrollbar that's related to a menu ring? I can't find it.
    One way to get a larger scrollbar:
      place a horizontal progress bar:
      change to control
      change to "no fill"
      edit it (STD if you want slider width changes to stick, TD if you're ok with copy/paste)
      show parts window
      select "Slider, Needle or Thumb"
      Make it as wide as you like
      Color it
    Oh, cool! If you find a nice picture the size you want, make the Slider that size then right click it and "import picture from clipboard".
    Are you talking about the scrollbars for the whole window?

  • Swing (JScrollPane - scroll bar) help

    Hello all..
    I am new user in Swing. Currently I am developing a program using JSCrollPane. I have to draw a kind of chart in it. Therefore as a drawing media, I used the JPanel, in which I put it inside my JScrollPane. Then.. since my graphic is long.. then I set the
    setHorizontalScrollBarPolicy value to ALWAYS. Then I put my JPanel using the following commands :
    this.jScrollPane1.setViewportView(this.jPanel2);
    this.jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Fyi, my JPanel size is set to be wider than the jScrollPane3 size. Nevertheless.. during the run time the horizontal scroll bar is not shown. I am completely loss on how to solve this. Does anyone has any clue or solution for this problem. Thank you very much in advance.
    Kariyage.

    Fyi, my JPanel size is set to be wider than the jScrollPane3 sizeYou should use panel.setPreferredSize(...) not panel.setSize(...);

  • Scroll Bar Width Adjustment

    This is a change suggestion for future releases.
    I would like to see an option to adjust the width of the scroll bars? In the library module, the scroll bars on the far left and far right are too narrow. I frequently miss the scroll bar with my mouse and the entire panel disappears.
    I am currently using Lightroom 2.1 for Windows.

    You guys aren't getting it. What Jeff is asking is HOW TO INCREASE
    THE WIDTH OF THE SLIDER BARS.
    Whether someone thinks "you really don't need to" is irrelevant. We want to center these images at higher magnifications. Just because you can put your cursor
    on the image and use the scroll wheel to make it go up and down doesn't mean you can make the image go right and left at the same time. Personally, I'd like to use the scroll wheel to zoom in and out (done in preferences, yes). But if you've ever tried to place your cursor on these narrow bars before you start
    moving the scroll wheel you know it's hell to hit those things very
    easily because they are barely 1/4" wide.
    So the question remains: How can a user increase the width
    of these narrow little bars? Is there a way to do this?
    rock

  • How to change the title bar wdith , scroll bar widths in tune with a 7" screen

    can you please help me customize my user chrome section so that I can REDUCE the WIDTH of the scroll bar ( horizontal and vertical ) . That is , at max the scroll bar can be ___ pixels of __ % of total width. ( prefer the relative reference )
    Also the title bar ( that black surrounding area that bears the minimize, maximize,close buttons ) needs its width reduced to half of what it is now. How do I do this ?

    No. That doesn't work any more. In current Firefox versions native scroll bars are used and you can't do style those via userChrome.css (user interface; chrome windows) and userContent.css (websites). You can try a large theme if you do not want to make the changes via the Control Panel

  • Scroll bars in Lion

    How do I adjust the scroll bars in Lion?  I want the scroll bars to be visible always, and wide (like they were in previous operating systems).
    In Lion, when I open a file, the scroll bar is invisible.  To get the scroll bar to appear, I have to stab blindly for the thing, until I get lucky and hit it.  Then, when the scroll bar does appear, it is excruciatingly narrow, and I have to really focus all of my mental powers in order to hit the darn thing.

    Thanks!
    I found the setting for "Show Scroll Bars."  However, I can't find the setting for the scroll-bar width.  How do I adjust scroll-bar width?

  • Scroll bars in tab canvases

    How to enable scroll bars in a tab canvas in order to scroll through the tab canvas using forms 6i
    kamal Mukhtar

    Thanks!
    I found the setting for "Show Scroll Bars."  However, I can't find the setting for the scroll-bar width.  How do I adjust scroll-bar width?

  • Scroll bar problem

    How can i attach scrollbar to my tab canvas?

    rupearlkaushal wrote:
    How can i attach scrollbar to my tab canvas?Do you show any block in the tab canvas ?
    If yes, go to the block property. Under Scrollbar section, set the following property
    Show scroll Bar: Yes
    Scroll bar canvas: your_tab_canvas
    scroll bar tab page: Tab_page_name
    scroll bar width and lengthHope this helps...
    If someone's response is helpful or correct, please mark it accordingly.

  • TileList does not recognize the size of vertical Scroll Bar

    Hi,
          I have a tileList with a custom vertical scroll bar that I made, the problem is that when the tilelist gets filled, it does not recognize that the vertical scroll bar width is not the default 16 pixels (I think the default value it's 16, but I'm not really sure) but 5 or 6 pixels, so the first time it gets filled it shows 3 columns of items (no problems with the rows). The columnWidth is set to 185, if I lower it to 180, it shows the 4 columns that I want it to show (instead of 3). I know that there is enough space because when I scroll down, and then scroll up, the fourth column appears. That's why I think that the TileList is not recognizing that the width of the vertical scroll Bar is less than the default width.
    Does anybody know how to make it recognize the new width? And how is  it that it has to take a scroll down to get it to recognize it.
    Thank you for your help.
    Sebasti'an Toro O.

    Yeah, you can try signing up for DropBox - it's a free service that allows you to sync any files between your iPhone and your computer.  More info here:  http://www.dropbox.com/about

  • Nested Scroll bars - Firefox. Lion.

    I have noticed that my pointer in Lion appears to unaware of which scroll bar I am trying to move when I have a scrollable window on a scrollable web page in Firefox. 
    In Snow Leopard the gesture controlled scrolling function knew which scroll bar I wanted to move by detecting the nearest scroll bar to the pointer.
    Can anyone tell me if this is a bug in Firefox which makes the scroll function unaware of the nearest scroll bar or have I missed a setting?

    Thanks!
    I found the setting for "Show Scroll Bars."  However, I can't find the setting for the scroll-bar width.  How do I adjust scroll-bar width?

  • How to change the width of scroll bar

    hi,
    is there some way to increase the width of the scroll bar or is it operationg system dependent?
    thanx and regards
    deepak saini

    hi
    not sure if this is the best way to do it, but it does work...
    try this...
    int newWidth = 50; //for example - this is big!!
    int h = (int)myScrollBar.getSize().getHeight();
    myScrollBar.setPreferredSize(new Dimension(newWidth, h));
    the above depends on whether your scrollbar is horizontal or vertical also. if you're using JScrollPane, call getVerticalScrollBar() to retrieve the bar (or horizontal as required).
    hope this helps
    Takis

  • JList in JScrollPane never shows horizontal scroll bar

    I have a JList inside a JScrollPane. When I add a lot of cells to the list, the vertical scroll bar appears as expected. However, if I add a cell that would require lots of horizontal space in which to render, the horizontal scroll bar never appears.
    Is there a way to make the JList take on the width of the widest rendered cell?
    Josh

    Here's some code that will demonstrate the problem. Run the code, then resize the window so that the horizontal scroll bar should appear.
    Code for jds.toys.Main:
    package jds.toys;
    import javax.swing.DefaultListModel;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    public class Main extends JFrame {
         protected DefaultListModel model;
         public Main()
              super("JList in JScrollPane");
              model = new DefaultListModel();
              model.addElement("A very very very very very very long String");
              model.addElement("A very very very very very very very long String");
              model.addElement("A very very very very very very very very long String");
              model.addElement("A very very very very very very very very very long String");
              model.addElement("A very very very very very very very very very very long String");
              model.addElement("A very very very very very very very very very very very long String");
                      JList list = new JList(model);
                      list.setSize(300,300);
                      list.setFixedCellHeight(30);
                      list.setCellRenderer(new MyCellRenderer());
                      JScrollPane scrollPane = new JScrollPane(list);
                      add(scrollPane);
                      setSize(400,400);
        public static void main(String[] args) throws InterruptedException {
             final Main m = new Main();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                     m.setVisible(true);
    Code for jds.toys.MyCellRenderer:
    package jds.toys;
    import java.awt.Component;
    import java.awt.Graphics;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.ListCellRenderer;
    public class MyCellRenderer extends JPanel implements ListCellRenderer
         private Object currentValue;
         private JList currentList;
         public MyCellRenderer()
         public Component getListCellRendererComponent(     JList list,
                                             Object value,
                                       int index,
                                       boolean isSelected,
                                       boolean cellHasFocus)
              currentValue = value;
              currentList = list;
              return this;
         public void paintComponent(Graphics g)
              int stringLen = g.getFontMetrics().stringWidth(currentValue.toString());
              int ht = currentList.getFixedCellHeight();
              g.setColor(getBackground());
              g.fillRect(0,0,stringLen,ht);
              g.setColor(getForeground());
              g.drawString(currentValue.toString(),0,ht/2);
    }

Maybe you are looking for

  • How to change Service Item using BAPI_ENTRYSHEET_CREATE.

    Hi All, There's a requirement for me to upload/ Create Entry Sheet using BAPI_ENTRYSHEET_CREATE from the source file. The Header was given to me but the Service Item, they would like the flexibility to change the existing lines that was adopted from

  • Can't download phonebook frpom iphone on ios 8.1 to mytouch sync

    My iphone 5c is ios 8.1 as of 2 days ago. I can no longer download my phonebook to MYTOUCH SYNC in my car. There was no problem before the software update.

  • Help: Crappy font display in Acrobat 9, Windows 7 x64

    I have build a new Windows 7 x64 machine. Nice and fast. Unfortunately, Adobe Acrobat 9.2 is playing up. The fonts in a number of PDFs from different sources do not display correctly; the letters are far too thin and coarsely pixelated. The same file

  • Which macbook is the best for programming?

    Ive been doing some research but I cant really figure out what to get. Ill be using it mainly for programming (Python etc.), some minor photoshop and some basic web use. Im positive I want a 13 inch screen but thats really all there is to it. I love

  • Consumer consuming slowly - High UNACK message

    I have glassfish 2.1 with OpenMQ 4.3. I have other posts related to the similar project. But I am seeing all these different symptoms, so I am putting it in different threads. I am running into this problem, where the consumers are consuming messages