JScrollPane scrollbar look

I'm working with JList which is in JScrollPane and would like to change the look of scrollbars. Like buttons, knob and tracker. How to do that.
I apreciate any help/

Hi,
You can use the UIManager put method for that and replace the Thumbs by a new class of yours that extends JScroll bar thumbs and overrid the paint method of the Thumb...
JRG

Similar Messages

  • How to make ScrollBar look independent from ScrollPane in JScrollPane???

    I have a JScrollPane. I am trying to add border to ScrollBar so ScrollBar looks seprate from pane.
    Is there anyother way to do this so ScrollBar look seprate from scrollPane?? thanks in advance!!!
    thanks
    amit

    Please don't repost a question as a new thread when someone has taken the time to answer your identical question already. At least post in the existing thread if you need to comment or add something.
    http://forum.java.sun.com/thread.jsp?forum=57&thread=159987

  • 10g: Enabled list items and scrollbars look disabled

    Hi,
    Is there any way to change the way list items and scrollbars look in 10g?
    Enabled list items and scrollbars look disabled to me (the list button on the list item and the arrow buttons on the scrollbars are greyed out).
    Visual attributes doesn't seem able to control this.

    Nope you're pretty much stuck with the look and feel of the decoratiosn unless you want to create your own pluggable component - this would give you more control but you'd have to consider if it's worth the investment.

  • My JScrollPane scrollbar defaults to the bottom not top

    Hi,
    I have a slight problem with a JScrollPane in that it appears to default the scrollbar to the bottom when the scrollbar is visible. I basically have a panel on a JFrame containing a JTextArea within a JScrollPane.
    Does anyone know how I can make it default to the top ? I think I found a method that works on JScrollBar but can't seem to find one for JScrollPane.
    Thanks,
    Andy

    I've just tried this and it works great, thanks for that.
    I was looking for methods in JScrollPane to control the bar, never thought of the JTextArea class having the answer

  • JScrollPane scrollbar eats unnecessary space

    Hi all,
    i have a problem with the horizontal scrollbar of a JScrollPane.
    My code is like this:
    JPanel toolbarsPanel = new JPanel();
    toolbarsPanel.setLayout(new BoxLayout(toolbarsPanel,BoxLayout.Y_AXIS));
    JPanel northToolbarPanel = new JPanel();
    northToolbarPanel.setLayout(new BoxLayout(northToolbarPanel,BoxLayout.X_AXIS));
    JToolBar jToolBarMainCommands = new JToolBar();
    jToolBarMainCommands.setLayout(new BoxLayout(jToolBarMainCommands,BoxLayout.X_AXIS));
    JScrollPane mainCommandsScrollPane;
    mainCommandsScrollPane = new JScrollPane(jToolBarMainCommands,JScrollPane.VERTICAL_SCROLLBAR_NEVER,JScrollPane.H
    ORIZONTAL_SCROLLBAR_AS_NEEDED);
    northToolbarPanel.add(mainCommandsScrollPane,BorderLayout.WEST);
    toolbarsPanel.add(northToolbarPanel);
    (the rest of the code includes 3 more toolbars; in total there are 2 toolbars in the upper side and 2 toolbars in the botom side of the toolbarsPanel)
    The problem is that the size of the toolbar (or the scrollpane that contains it) includes the size occupied by the horizontal scrollbar in spite of the horizontal scrollbar not appering. And there is more, when the horizontal scrollbar appears the previous size get smaller and don't include space required for the scrollbar, overlapping the scrollbar upon the toolbar.
    How can i compact my toolbar when the horizontal scrollbar is not needed and how can i show the scrollbar underneath the toolbar without overlapping with it.

    Hi all,
    i have a problem with the horizontal scrollbar of a JScrollPane.
    My code is like this:
    JPanel toolbarsPanel = new JPanel();
    toolbarsPanel.setLayout(new BoxLayout(toolbarsPanel,BoxLayout.Y_AXIS));
    JPanel northToolbarPanel = new JPanel();
    northToolbarPanel.setLayout(new BoxLayout(northToolbarPanel,BoxLayout.X_AXIS));
    JToolBar jToolBarMainCommands = new JToolBar();
    jToolBarMainCommands.setLayout(new BoxLayout(jToolBarMainCommands,BoxLayout.X_AXIS));
    JScrollPane mainCommandsScrollPane;
    mainCommandsScrollPane = new JScrollPane(jToolBarMainCommands,JScrollPane.VERTICAL_SCROLLBAR_NEVER,JScrollPane.H
    ORIZONTAL_SCROLLBAR_AS_NEEDED);
    northToolbarPanel.add(mainCommandsScrollPane,BorderLayout.WEST);
    toolbarsPanel.add(northToolbarPanel);
    (the rest of the code includes 3 more toolbars; in total there are 2 toolbars in the upper side and 2 toolbars in the botom side of the toolbarsPanel)
    The problem is that the size of the toolbar (or the scrollpane that contains it) includes the size occupied by the horizontal scrollbar in spite of the horizontal scrollbar not appering. And there is more, when the horizontal scrollbar appears the previous size get smaller and don't include space required for the scrollbar, overlapping the scrollbar upon the toolbar.
    How can i compact my toolbar when the horizontal scrollbar is not needed and how can i show the scrollbar underneath the toolbar without overlapping with it.

  • Setting JScrollPane scrollbar status

    JScrollPane scrollR = new JScrollPane(textareavariable);
    scrollR.setVerticalScrollBarPolicyJScrollPane.
    VERTICAL_SCROLLBAR_ALWAYS};
    I need toset the vertical scrollbar at the bottom of the textarea so that the user will always to view the last record.
    How do I do that?
    Thank you!

    Is what you said what you really want? You've described a scrollbar that the user can't manipulate - taken literally the user will never be able to see anything except that bottom records.
    As a guess, you want the user to see the bottom record sometimes, but also to be able to scroll othertimes, no? When do you want the user to see the bottom record?

  • JScrollPane in a JFrame scrollbars visible but not functional no thumbtabs

    Here is the code that I compiled and run on J2SE v. 1.4.2 (runtime b28). I looked through the various related articles and nothing seems to help with this issue. The scrollbars appear along with the panel but the thumbtabs are not present. Any help would be appreciated.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test {
      public static void main(String[] args){
        Test rce = new Test();
        JFrame frame = new JFrame("Test Scroll");
        JScrollPane scrollBar = new JScrollPane();
        scrollBar.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollBar.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        Component  rcePage = rce.createComponents();
        scrollBar.getViewport().add(rcePage, null);
        frame.getContentPane().add(scrollBar, null);
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.pack();
        frame.setSize(400, 400);
        frame.setVisible(true);
      public Component createComponents() {
        JPanel pan = new JPanel();
        JLabel label = new JLabel("This is a Test!");
        pan.setBorder(BorderFactory.createEmptyBorder(
            0, //top
            0, //left
            0, //bottom
            0) //right
        pan.setLayout(null);
        label.setBounds(100, 100, 80, 20);
        pan.add(label);
        return pan;
    }

    This is a very common mistake. When you put a JPanel in a scrollpane, the scrollpane will use the panel's preferred size to determine if scrolling is needed or not. If the panel is using a LayoutManager this is generally done for you automatically. But in your case you set the layout to null, and then it is your responsibility to make sure that the getPreferredSize() method of the panel returns the correct size.
    One way to fix this in the code you posted would be to override the getPreferredSize() of the panel, like so:
        public Component createComponents() {
            JPanel pan = new JPanel() {
                public Dimension getPreferredSize() {
                    return getSize();
        }Then the scrollbars will appear if you make the frame smaller.
    But what I really suggest is that you use a LayoutManager.

  • How to add seprator to ScrollBar in JScrollPane?

    I have a JScrollPane. I am trying to add border to ScrollBar so ScrollBar looks seprate from pane.
    Is there anyother way to do this so ScrollBar look seprate from scrollPane?? thanks in advance!!!
    thanks
    amit

    Border b = ...; // your border here
    UIManager.put( "ScrollBar.border", b);http://www.gargoylesoftware.com/papers/plafdiff/ScrollBar.html

  • Customizing the scrollbar for jScrollpane Component

    Hi,
    Am trying to customize my jScrollpane scrollbars. Would like to at least customize colors.
    Anyone know how to do this? Or know anywhere to read up about this. I am using the Sun One Studio and can't seem to do this at all.
    thanks

    I have the same problem.
    So far I have only managed to change the background of the scrollbars.
    jScrollPane.getVerticalScrollBar().setBackground(color);
    Does anyone know how to further customize the scrollbar?

  • Disable scrollbar when content is lower than viewport ?

    Hi,
    I have a vertical scrollbar always showed (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS),
    but I want it to be disabled when the content in the viewport is lower than the viewport's height.
    Take for example Chrome browser in Windows: when u open up Google, the content of the page is quite low in height and the scrollbar in Chrome will be disabled. As soon as you have enough content on the page the scrollbar will be active.
    How can I achieve this ?
    Thanks

    Hello,
    It's not really a problem, I just realize it is a SWING limitation, (...)
    Almost all app have this behaviour; it isn't really nice visually.I don't have Chrome, and haven't seen this behavior anywhere so far (but admittedly, I'm way behind in terms of GUI fashion).
    The behavior that I'm used to (and that Swing designers apparently believed to be the norm too), is that a scrollbar disappears when the width of the view does not justify it ( SCROLLBAR_AS_NEEDED ). Using SCROLLBAR_ALWAYS implies that you want the scrollbar there, no matter whether the view's width deserves it. How the scrollbar looks in this case sounds like a Look and Feel choice instead (I only have oldish OSs, but maybe you know an Operating System where this behavior is the norm? In this case yes, it is a limitation of the corresponding Swing L&F).
    maybe there was some workaround.Considering this is not in the OS LAF, this can be "manually coded", by listeneing to resizing events and accordingly changing the scrollbar's appearance.
    Assuming the "disabled" scrollbar appearance is what you're after (no idea, it's just an example, if that doesn't suit your need you may do something else in the placeholder code), here is a, admittedly rather dense, workaround.
    Notice how the vertical and horizontal scrollbar looks different (I only applied the workaround to that latter).
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class TestDisableScrollBar extends JPanel
        private static final String SHORT_TEXT = "text";
        private static final String LONG_TEXT = "texttexttexttexttexttexttexttexttexttexttextte";
        private static void createAndShowGUI()
            JFrame frame = new JFrame("Demo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JTextArea textarea = new JTextArea(5, 5); // just to take up some space.
            final JLabel label = new JLabel(SHORT_TEXT);
            JPanel view = new JPanel();
            view.setLayout(new GridLayout(2, 1));
            view.add(label);
            view.add(textarea);
            final JScrollPane widget = new JScrollPane(view, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            widget.getHorizontalScrollBar().setEnabled(false);
            widget.getViewport().addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    widget.getHorizontalScrollBar().setEnabled(
                            widget.getViewport().getWidth()<
                            widget.getViewport().getView().getWidth());
            frame.getContentPane().add(widget, BorderLayout.CENTER);
            JButton alternateText = new JButton("Switch width");
            alternateText.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    label.setText(label.getText().equals(SHORT_TEXT)?
                        LONG_TEXT : SHORT_TEXT);
            frame.getContentPane().add(alternateText, BorderLayout.SOUTH);
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
      }

  • Problem with window repaint and scrollbars in edit mode (LabVIEW 8.0.1)

    I am running LabVIEW 8.0.1 in Windows XP SP3.  For my main VI, I ran into a strange problem about 5 months ago.  The front panel window - in both edit mode and run mode - stopped repainting itself on the right side which is most visible when you scroll up and down, but also visible with overlapping windows.  Coincident with the repaint problem, both scrollbars look disabled with greyed-out arrows and no boxes in the bars that you can click and drag to scroll the window.  The scrollbars still partially work if you hover the mouse over them and roll the mouse wheel but clicking and dragging doesn't work. 
    The front panel has lots of controls and indicators including tab-control containers and is larger in the horizontal and vertical directions so both scrollbars should be active.  But I deleted all elements on the front panel and everything in the block diagram and the problem persists.  So the problem is not directly related to some control/indicator display.
    I saved the simple VI with this problem (using a wide text line and a tall rounded box to test), then created a new VI and copied the two elements to the new VI.  This new VI does not have the repaint and scrollbar problem.  The two VIs differ slightly in memory usage and in revision number (the bad one is revision 1785 and the good one is revision 3), but otherwise the two VIs are identical.  I attached both VIs to this posting.  When you first open the bad VI, you'll see the disabled scrollbars whereas the good VI has active scrollbars.  To replicate the repaint problem, scroll the window up and down with your mouse wheel.  If it's fine when you first open the VI, click on another window, then click back on the VI window and try the mouse wheel again.  This clicking-away-and-back always causes the repaint problem for me.  I tried the VIs on two different computers both running Windows XP SP3 and LabVIEW 8.0.1 with identical results.
    Here's what I discovered from troubleshooting with the simple VIs:
    * scrollbars always disabled
    * repaint problem in main window for window widths larger then 680 pixels
    * repaint problem in main window menu toolbar for widths larger than 646 pixels
    * entire window becomes disabled for window widths larger than 1348 pixels
    * can repaint window by minimizing and restoring, but only repaints that one time
    * scrollbar boxes sometimes flicker into view but then disappear
    * scroll left and right by hovering mouse over horizontal scrollbar and using mouse wheel
    I found something similar on this forum (thread: Problem with front panel refresh) - it might be related to the CAR about the panel being offset internally.  I don't have access to LabVIEW 8.5 or later and don't plan to upgrade - I haven't tried the trial version as that user did.  I could try to copy and paste my entire block diagram to a new VI but the VI is so large I'm afraid something would break, plus I don't want this to happen again in a few months.  The problem seemed to occur after a certain number of saves (or revision number).  I save backup copies often and when the problem first happened, I was able to go back to a previous version, make the missing changes and save it with no problems, but this only delayed the problem and it came up later.  So maybe it's the revision number.  It didn't seem related to a particular addition or modification in the front panel or diagram.
    The image attached shows the repaint and scrollbar problems in the bad VI.
    This brings up a question I have - if this problem is a bug and was fixed in 8.5 and later, is there a way to apply bug fixes to earlier versions?  Or do I have to pay for an upgrade to fix such bugs?
    Solved!
    Go to Solution.
    Attachments:
    RepaintTest_Bad.gif ‏27 KB
    Test Repaint - From Bad VI, scrollbar and repaint problems.vi ‏7 KB
    Test Repaint - From Blank VI, no problems.vi ‏5 KB

    Seems something got corrupted with this VI. Copy things over to a fresh VI and things should be OK.
    See also this recent report of a similar issue.
    LabVIEW Champion . Do more with less code and in less time .

  • Why does my cover flow scroll bar look like THIS?

    here you can see how very often the scrollbar looks like. is there any known reason for that? when I change the size of the cover flow part of the window it changes back to normal. but very often, even in full screen view, the scroll bar looks this blurred...
    any suggestions?
    thanks,
    bensch
    MacBook 2 GHz   Mac OS X (10.4.8)  
    MacBook 2 GHz   Mac OS X (10.4.8)  

    it should be sharp & clear, not blurry
    Quit jiggling the camera when you take the picture?
    (Yes, I know it was a screen shot and not a camera.)
    I'll load up iTunes 7 later tonite and see what happens.

  • Coverflow Scrollbars - bad resolution

    When I use Coverflow in iTunes, the resolution of the horizontal scrollbar is in stark contrast to the clear, crisp resolution of everything else. Within the iTunes black area, the scrollbar looks blurry. When I use Coverflow in full screen mode, the playback controls and the full-screen button appear clear and crisp, but the scrollbar and the volume control bar appear very blurry.
    With Apple now expanding the Coverflow mode to the Finder, I hope this issue gets fixed quickly - it's been around ever since Coverflow was introduced.

    Yeah, pretty much everyone who has a Macbook has this problem. I went to the Apple store a few days ago, and I found out that this problem was ONLY native to the Macbook, which is shameful, because it's the most widely bought Apple computer. I hope it gets addressed quickly!
    -Ian B.

  • Make a JScrollBar only update its JScrollPane when the user releases it?

    Hi
    I have a JTable inside a JScrollpane. The JTable gets its data from my TableModel using the getValueAt method in the normal way. It is almost working fine. The one thing left to improve is that I don�t want the JTable to keep trying to get its data while the scrollbar is still being dragged. This is primarily because the latency in fetching the data makes the UI unresponsive - the table model does not keep all rows in memory at one time, but keeps a page of data in memory.
    So, just to clarify, I want the behaviour to be that when the user is still adjusting the value of the scroll bar, the thumb position of the scroll bar moves, but the rows displayed in the JTable do not update. When the user releases the scrollbar, the rows should then update.
    I have almost acheived this by having a second, independent scroll bar on the frame, and an adjustment listener listening for events, like this
    public void adjustmentValueChanged(AdjustmentEvent e){
    if (e.getSource() == scrManual){
    if (!scrManual.getValueIsAdjusting()){
      JScrollBar scrTable = scrPaneResults.getVerticalScrollBar();
    int iManValue = scrManual.getValue();
    int iManMax = scrManual.getMaximum();
    float fManWhere = (float)iManValue / (float)iManMax;
    int iTblMax = scrTable.getMaximum();
    int iTblNewValue = (int)(iTblMax * fManWhere);
      scrTable.setValue(iTblNewValue);
    else
    throw new IllegalArgumentException("I don't know how to handle the adjustment event for " + e.getSource());
    }This is actually working fine, except that I don't want there to be two scrollbars - one in the scroll pane and one extra one. But when I try to make the scrollpane's scrollbar invisible, it remains visible.
    Can anyone tell me either
    (a) how to just have a normal JScrollPane scrollbar, but have it only update its viewport when the value is no longer adjusting (ie scrollbar has been released)
    (b) how to make the JScrollPane's scrollbar still effective, but invisible.
    (c) if the JScrollPane has a no scrollbars policy, how to instead in the code I posted above, set the ScrollPane's position directly.
    Whichever is easiest.
    Thanks for your help
    Mark

    Oh how embarassing! I already asked this question before, and answered it myself! Sorry - I think I am losing the plot
    I�ve hacked it. Turns out that the jScrollPane has a getXXXScrollBar method, which even when you�ve hidden the scrollbars, still works. You just use another scroll bar, register a listener for the mouse released event, and update the jScrollPane�s scroll bar to match the value.

  • Trapping the addition of ScrollBar on ScrollPane.

    Hi All,
    I have a Panel in which there is a JScrollPane(with JTextArea) and a button. On the click of button we add the components dynamically to the Panel. Now since the size of the Panel(inside a frame) will remain the same therefore adding components at run time will add ScrollBar to the ScrollPane(as it is reduced in size).
    So what i have to do is to trap the moment at which the scrollbar comes into picture. That is when i keep on adding some components dynamically at run time so at some time the scrollbar will be added to scrollPane. All i have to do is display a message at the moment when the ScrollBar is visible.
    I am stuck with this for almost a day....... Please help soon

    What you can do (it's pretty ugly and I haven't tested it) is this :
    - subclass JScrollPane
    - override the createVerticalScrollBar() and createHorizontalScrollBar()
    - in both overriden methods return a subclass of JScrollPane.ScrollBar instance in which you will have overriden the setVisible(boolean aFlag) method.
    - in the setVisible method, you may test the value of the flag.

Maybe you are looking for

  • Migrated from SOA 10.1.3.1 to 10.1.35, Error While Deploying an Application

    I have migrated from Application server 10.1.3.1 to 10.1.3.5 by applying patches. After that i have tried to deploy a application, I got this error Operation failed with error: [resonance:resonance] - Exception creating EntityManagerFactory using Per

  • Val.String WA01,WA02 for movement type 601

    Hi experts, can anybody explain the means of val.string WA01 and WA02. thank you ahead. eric xu

  • Java null pointer exception

    Hey guys, Im having a problem with the following code:     public void testVariable(Object a, Object b)         if(a!=null || b!=null)             Object reta = null;             Object retb = null;             String tempa = null;             String

  • Vbios request GTX980 gaming NV317MH.114 ?

    How to get the vbios nv317MH.114 ?

  • How to hide video

    i hve iphone 2g with 2.01 firmware and my itune version is 7.7 how can i hide movie i didnt download from itune ? is there any software ? how is it possible