Painting unused part of a JScrollPane

I have a JTable inside a JScrollPane. The table usually doesn't fill the entire area of the scroll pane (but it can, which is why the scroll pane is bigger than it often needs to be). I want to paint on the part of the scroll pane which does not have table rows on it. I have the following:
legsScroller = new JScrollPane(legsTable)
  public void paintComponent(Graphics g)
    ImageIcon image = <get the image from my images jar file>
    Dimension panelSize = new Dimension(getBounds().width, getBounds().height);
    Dimension imageSize = new Dimension(image.getIconWidth(), image.getIconHeight());
    for (int i = 0; i <= panelSize.width; i += imageSize.width)
      for (int j = 0; j <= panelSize.height; j += imageSize.height)
        g.drawImage(image.getImage(), i, j, null);
legsScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
legsScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);When I run it, I can see that the painting is being done, because I see my image in the top right-hand and bottom right-hand corner components (using the nomenclature of the API page on JScrollPane). Also, there is a one-pixel wide strip of my image running down the outside of the vertical scrollbar, and a one-pixel deep strip of it running along the bottom of the horizontal scrollbar.
Whilst it's nice to know the painting is being done, the result is exactly the opposite of what I want! I only want to see my image in the unused part of the scroll pane, that is to say, the part bordered by the bottom of the table, the left of the scroll pane, and the inside edges of the two scroll bars.
Does anyone have any ideas as to how I can get hold of the unused portion of a JScrollPane?

How are you doing the 'tiling'? I hope you're making use of <tt>TexturePaint</tt> and not cluttering up your code with nested loops.Well for the case of the matte border (<tt>MatteBorder</tt>), it does all of the work for me. In the case of the tiling of the <tt>JPanel</tt> or <tt>JViewport</tt>, I would have done it using the code in my original post, which is to say I guess not the way I should have :-[  I didn't know about <tt>TexturePaint</tt>...just had a quick look, yes obviously I would use that now that I know about it :->  Thanks again                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How do paint a part of text in the textarea ?

    can i paint (in different color ) just a part of a text in the
    textatra ?
    pease help

    if you're fluent in html, you can use JEditorPane like so:
    JEditorPane j = new JEditorPane("text/html","");Then you can use html in it like this:
    j.setText("<font color=green>green</font>,<font color=red>red</font>");More information:
    http://java.sun.com/j2se/1.4/docs/api/javax/swing/JEditorPane.html

  • Chrome app becomes unusable - Part 2

    Hello,
    I had initially reported incorrectly at Chrome app becomes unusable  that the problem of the Chrome app becoming unusable had gotten fixed. The problem is still occurring. Can anyone who knows of other discussions or webpages about the issue please provide links to that content? I cannot find any other references to the issue besides the discussion that I started at the aforementioned link
    Thank you in advance of your help.

    I think there must be some conflict with another app or setting on the iPad that is causing this. Finding the conflict could be quite a task. I don't want to suggest anything too invasive or anything that will be a lot of work, but it may eventually come down to you having to backup,your iPad, restore the device to factory settings and then restore the backup.
    Have you tried closing all other apps when using Chrome just to see if there is an app causing a conflict? I would try that next, if you haven't tried it yet, and I would also reset the iPad. I would close Chrome as part of this troubleshooting procedure as well. After you close all apps and reset the device, launch Chrome again and see if that helps.
    In order to close apps, you have to drag the app up from the multitasking display. Double tap the home button and you will see apps lined up going left to right across the screen. Swipe to get to the app that you want to close and then swipe "up" on the app preview thumbnail to close it.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • JScrollPane not working? Please help

    Hi there,
    I am trying to incorporate a JScrollPane into a JList in my program, basically I make it so that JList is comprised of array of Strings. So the code looks like:
    javax.swing.JPanel          jpanelListSnps            = new javax.swing.JPanel();
    jpanelListSnps.setLayout(new java.awt.BorderLayout());
    String[] stringArray    =  new String[123] //that's the actual amount of elements in the string
    //initializing each elements of array....I will skip that part
    javax.swing.JScrollPane  jscroll  =  new javax.swing.JScrollPane(stringArray);
    jscroll.setPreferredSize(new java.awt.Dimension(30,30));
    jlistSnps.addListSelectionListener(this);
    jpanelListSnps.add(jlistSnps,"West");
    jpanelListSnps.add(jscroll  ,"East");
    jscroll.setAlignmentX(jpanelListSnps.RIGHT_ALIGNMENT);And I see the scrollbar, but I don't think the size is not properly adjusted. Also, I don't see the tab for the scrollbar. I don't know what is wrong with this code. Any suggestions or ideas would be much appreciated. Thank you in advance.
    Regards,
    Young

    JList list = new JList( stringArray );
    JScrollPane scrollPane = new JScrollPane( list );
    panel.add(scrollPane, BorderLayout.EAST);

  • Scrolling only part of the screen

    Hi,
    I have the following problem.
    1. I created a JFrame, that fills the whole screen.
    2. The frame contains two JPanels.
    Now for the problem:
    I want the top panel to hold a JPEG that is much bigger than itself, so it should contain a JScrollPane or a JViewport, because I want it to be scrollable. It seems, that I only can change the viewport, that the image scrolls downwards. For some reason the area doesn't even react when I try to change the position of the image, so that I can view the part of it that is outside of the panel. Is there anything I can do ?
    To better visualize the problem :
    Do you know the computer game civilization ? The bottom part of the screen holds menues. The uppermost part is a scrollable map. I want to create something similar.

    maybe you need a JSplitPane, split the frame into upper-lower two parts. The upper part holds the JScrollPane for the image panel, the lower part holds the second panel

  • Is it safe to paint an iPhone charger with nail polish?

    Is it safe to paint an iPhone charger with nail polish to make it easier to tell which one belongs to me?  I would like to paint the part that plugs into the wall, the top of the part that plugs into the charger, and the top of the piece that plugs into the phone.

    Not the whole charger. You might put a stripe on it, but I would suggest you not use nail polish because it's flammable.

  • When to use Paint over Photoshop?

    Im newer to Photoshop so its easier for me to throw my images into Paint to resize and crop them.
    I was curious if other community members ever use Microsoft Paint for tasks and if so what?
    Also, should I be doing this or would it benefit me to use Photoshop for resizing and croping images?  I plan on using Photoshop but I rarely have it open since I mostly use the development programs within CS5 and it takes magnitudes longer to open Photoshop than Paint.  But even with Fireworks running and the image attended for Fireworks I still through my image into paint because it seems faster.  Am I dumb? Should I give up the paint? Some hot keys for this task probably would be better ahhhh... any insight?
    Thanks,

    I do not think that I have used MS Paint, since about Windows 2.0. I did not even realize that it was still around.
    I just use PS for everything, with the exception of JPEG's, with bum header info, that PS will not open. Then, I just use either ThumbsPlus, or IrfanView, to Open, then Save with proper header info.
    I do not have any data on the Scaling (Resizing) algorithms in Paint, but would think that those in PS would be better. They do offer you a good range of choices, but maybe Paint has similar? Same when Cropping. What part of those operations do you find easier in Paint?
    Though I use PS a lot, and have for a very long time, image editing software is but a tool in a process. Using the right tool, or the one that the artist is most comfortable with, is the trick. I use Painter (now Corel) for a lot of treatments, but almost always finish up in PS. Over the decades, PS has become closer to Painter, than in days past. Still, there are treatments that I want to apply in Painter, and part of those choices will be my personnal comfort level. I might have something very similar in my newer PS, but if I know every step by heart in Painter, my comfort level rises.
    Use what you like for different operations, but I would do a visual check with an operation, like Scale/Resize. Do the same exact operation in each program, using the same base Image, and the same exact settings. Compare the results of the two programs critically.
    Good luck,
    Hunt

  • After upgrade to 10.4.x Corel Photo-Paint 11 refuses to start

    I upgraded from Mac OS X 10.3.9 to 10.4.x (currently all updates done, so version is 10.4.8).
    Anything works, beside a few minor things that got solved so far. However there is one big problem I deal with:
    I have installed Corel Draw 11 on OS X 10.3.9 and it worked great. Now I tried to open Photo-Paint 11 (part of the package). It seems to start for a few seconds, but then does not open. No error message, nothing.
    The system.log does not show any entries, same to panic.log as well as other log files I have access to.
    Interestingly all other components of Corel Draw 11 (Corel Draw itself, Corel Trace and SBProfiler) are working as they should, just not Photo Paint.
    Has anyone made same experiences and has a solution for this problem ? I know this software is old, but nevertheless works fine for me. So I would really look forward if someone can assist me.

    I got it working myself
    Maybe others are dealing with the same problem, so here is what I did:
    At Corel's support website I found no information about similar problems, just a description how to set back the current workspace to factory defaults.
    This is done by clicking at the program icon to start the software and then holding down the shift key immediately after clicking. Then a message box opens asking for confirmation.
    Although I had done some custom settings to the workspace I had nothing to lose and gave it a try. Voila
    Not sure what the reason behind is; I think that there are old configuration files existing or settings got mixed up for whatever reason.
    Before I did so, I renamed the matching *.plist file at my user's library/preferences folder to *.plist.old - but this did not bring any improvement (in fact, even no new plist file became created).

  • How to work with Alphanumeric Editor in Screen Painter?

    Hello Guys,
    I am trying to work on Screen Painter Layout and it's showing me that Graphical Screen Editor is not
    available and continue working with Alphanumeric Editor.I don't know how to work on this.Guys,
    Please let me know why is the message and what can we do about it.
    Thanks in advance,
    Sri

    Somtimes you will get this message if something got screwy with your SAPgui, for me simply closing out of SAPgui and going back in has fixed this issue.  If you do not know for sure that your SAPgui had been installed including the screen painter, then you should start there.  You will need the SAPgui installation executable, either from CDs or a downloaded file.  Run the SAPgui installation, and make sure to select the screen painter as part of the install, i believe it is under "development tools" in previous versions.  In newer versions I believe it is installed by default, but I do no for a fact that it is not this way in earlier releases, such as the 46D gui.
    So for make sure that Screen Painter has been installed with your SAPgui, if you are sure that it had been installed, perhaps it was working fine yesterday, then I would suggest first closing out SAPgui, and going back in, and trying the screen painter, If the problem persists, it may be worth it to reinstall the gui.
    Regards,
    Rich Heilman

  • Screen painter and database connectivity

    hi friends where i can found the complete tutorial for the screen painter , coding part and all stuf that is required for designing screen and then using it.
    i have searched a lot but stil not getting proper links.

    [http://abaplovers.blogspot.com/2008/03/sap-abap-module-pool-programming.html]

  • Canvas covering scrollbars in JScrollPane

    I have an image with listeners, implemented as a Canvas. I add it to a JScrollPane. When This JScrollPane is displayed, I get the Canvas overlapping the scrollbars, but still responding to MouseWheel events. Is seems that it is being painted on top of the JScrollPane instead of behind it. Is there a way to remedy this?
    Thanks in advance.
    -Nate

    nevermind
    I got it taken care of.. Stupid question.

  • Tooltip doesnt show up correctly

    I have written a small monitoring application tha shows gui components derieved from JComponent inside a JScrollpane. All the display works fine besides the fact, that tooltips from my gui components do not show up correctly when the tooltip window exceeds the boundaries of the JScrollPane. When the complete tooltip is displayed inside the JScrollpane it is displayed correctly. If its is partly outside the JScrollpane the tooltip window remains gray and no text is displayed.
    When I paint my graphics directly to the underlying component without using a JScrollPane the tooltip is displayed correctly disregarding whether its boundaries exceed the underlying components boundaries or not.
    I use JDK 1.5.07 for my development and Eclipse 3.2.
    Any help will be appreciated.
    thanks Christian

    Good attitude! I like that. It may be very productive to see what differences there are between your code that doesn't work and the one that does. If you still cannot find out what is going on, I can have a look to see if it does the same error on mine (its the least I could do by running your code). You could email it to me if you like. I'm a bit wary of spam so send an email to my sourceforge account first. My user name there is avian_freeware and that should be enough for you to get my email address there.
    Good luck!
    Jason.

  • System freezing - kt4a7-L

    Hello,
    system details.
    motherboard: kt4av
    memory:900mb pc2100
    cpu: athlon xp 2100
    bios: unknown(never flashed)
    vga:Geforce 6 6200 128mb.
    psu:600w
    The problem is that when I have the cpu fsb set to 100mhz I have no problems,although the cpu only runs as a athlon 1500. When I set the fsb to 133mhz to get the full 2100, the system radomly freezes and reboots.
    PCalert was showing faults with the voltage, so I changed the PSU, also it was showing high temp so I put a uprated cpu heatsink and fan on.still lock ups and reboots.
    please help!
    Paul

    Mostly freezing, even if it sounds strange, is due to overheating. What is the processor temp.
    Another option is that XP makes use of previously unused parts of the memory, but I don't think that is your problem. You could try with only the newest, biggest and best one.
    And start with the drivers that came with the motherboard, and if need be update from there.
    PS You might edit the thread title. kt4a7-L it isn't. DS

  • How much memory does SQL Server 2008R2 Standard use on Windows Server 2008 R2 64-bit?

    Hi,
    can anyone tell me how much RAM will really be used by SQL Server?
    72 GB are currently installed. As Windows is only able to use 32 GB is SQL Server able to use the other 40GB + the unused part of the first 32 GB?
    Thank you very much!
    BR Matthias

    Sorry, I don´t understand your post ?!
    Maybe the question is if SQL Server is able to allocate more memory than the installed Windows Version is able to?
    Since your OS is Windows Standard edition(X64) it cannot use or a process running cannot use more than 32 G of memory.
    Now SQL server can use as much memory possible but it is now limited by Windows as your OS can only see 32 G.So it would be good part from your side to go to sp_configure and set 25 G for SQL server and can leave rest for OS( it just a figure not a actual
    value i have given,actual you have to calculate by yourself or refer to below link) .
    http://mssqlwiki.com/2013/04/22/max-server-memory-do-i-need-to-configure/
    As Andrew said after 32 G what ever memory you put it is waste.
    Hope this helps
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • ASm On windows

    I want to use regular "Windows disks" for ASM.
    I have created unformated logical drives on windows. When i run dbca wizard for asm but when creating disk group i changed the disk discover path using \\.\*: for finding the logical drives i get an error
    ora-02097 parameter cannot be modified because specified value is invalid.
    ora-15031 disk specification \\.\*: matches no disks
    ora-15056 additional error message
    any One have any idea whats be the possible cause. If any one configure asm just like i am doing. Please help me. Using oracle 10g rel 2.
    Thanks

    Prepare Disks for Database Storage
    You need to configure disk storage for use with Automatic Storage
    Management (ASM). ASM storage consists of one or more disk groups, each
    of which can span multiple disks. To prepare the shared disks that you
    identified you need to create two or more logical drives, each on a different shared disk, for a total of at least 7 GB. To prepare each logical drive, perform these
    steps:
    Navigate to Start > Settings > Control Panel > Administrative Tools >
    Computer Management
    Expand the Storage folder to Disk Management
    Identify a shared disk that contains the required amount of free space
    and right click inside an unused part of an extended partition.
    Choose Create Logical Drive in the option window and a wizard presents
    pages for configuring the logical drive.
    Enter the size that you want for the partition. All of the partitions
    that you create for your ASM disk groups should include as much of the
    free space on the disk as possible. Additionally, however, the
    partitions should all be the same size.
    Choose the option Do not assign a drive letter and then choose the
    option Do not format this partition. Click Finish on the last page of
    the wizard.
    Stamp the Logical Drives for ASM
    To enable disk discovery during the database install, the logical drives
    used to store your database files must be stamped with an ASM header
    using a GUI tool called asmtoolg. All disk names created by the tool
    begin with the prefix ORCLDISK for identification purposes. Complete the
    following procedure to stamp the logical drives that you created.
    To open the tool, double-click CRS home\BIN\asmtoolg where
    Select Add or change label and click Next on the Welcome screen.
    On the Stamp Disks screen, select the disks to stamp and keep the
    default settings for Generate stamps with this prefix, then click Next.
    Click Next on the Stamp disks screen.
    Click Finish to save your work and exit from the tool.
    ~ Madrid

Maybe you are looking for