Filling out available space in JScrollPane

Hello all,
Is there a way to inform a JScrollPane that it's viewport's component should fill out the entire area of the viewport? I have a scroll pane whose viewport is a JPanel with a BoxLayout. The contents of the JPanel will change size depending on certain events. However, the JPanel at first is not very wide (it's components have a preferred size of 100), so it does not fill out the width of the viewport and is also displayed in the center of the scroll pane. Is there a way to have the JPanel fill out the entire viewport, or at least have it displayed on the left (I have set both the JViewport and JPanel's alignmentX values to 0.0 but it's still in the center)?
Thank you all for your time.

It looks like you have an intermediate panel between the viewport and the JPanel with the BoxLayout. In other words, the view is not the BoxLayout JPanel, but the intermediate one. A newly constructed JPanel will have FlowLayout and position the component top centered as displayed in your picture.
I wasn't lying when I said the JPanel should be the same size as the viewport. That's the default behavior. Example,
import javax.swing.*;
public class Demo {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
    private static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        String lines = "------------\n" +
                       "------------\n" +
                       "------------\n" +
                       "------------\n" +
                       "------------\n";
        JFrame frame = new JFrame();
        //Box musicPanel = Box.createVerticalBox();
        JPanel musicPanel = new JPanel();
        musicPanel.setBorder(BorderFactory.createEtchedBorder());
        musicPanel.setLayout(new BoxLayout(musicPanel,BoxLayout.PAGE_AXIS));
        Box tempo = Box.createHorizontalBox();
        tempo.add(new JLabel("Temp = 120"));
        tempo.add(new JButton("Change Tempo"));
        musicPanel.add(tempo);
        musicPanel.add(new JLabel("Tack 0: tuba"));
        musicPanel.add(new JTextArea(lines));
        musicPanel.add(new JLabel("Track 1: trombone"));
        musicPanel.add(new JTextArea(lines));
        musicPanel.add(new JLabel("Track 2: C_trumpet"));
        musicPanel.add(new JTextArea(lines));
        musicPanel.add(new JLabel("Track3: English_horn"));
        leftAlign(musicPanel);
        frame.setContentPane(new JScrollPane(musicPanel));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    private static void leftAlign(JComponent parent) {
        parent.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        for(java.awt.Component c : parent.getComponents()) {
            leftAlign((JComponent) c);
} If you change
frame.setContentPane(new JScrollPane(musicPanel)); to
JPanel intermediate = new JPanel();
intermediate.add(musicPanel);
frame.setContentPane(new JScrollPane(intermediate)); in the above code, then you'll get something that looks remarkably like the picture you provided.

Similar Messages

  • I feel that Apple. mac. Safari is selling out available Space on every search, and, or, we consumers are being saturated with junk mail. can't block it can't stop it from happening. Help

    I feel that Apple. mac. Safari is selling out available Space on every search, and, or
    we consumers are being saturated with junk mail. can't block it can't stop it from happening. Help

    You can use junk mail filters but setting the criteria can be a problem.
    A very good tool for blocking adware is available from Thomas Reed's site http://www.thesafemac.com Thomas is a regular contributor on ASC and a good helper.

  • Filling out empty space with a div

    http://www.elliotnewman.com/index/test5.html
    Is there a way to automatically fill the space between the two divs: "news" and "basket" with the div "spacer" ? "news" is floating to the left, and "basket" is floating to the right, so I just want the "spacer" to fill this gap.

    Forgive for me for saying this, but your code suffers from a common newbie syndrome called "division-itis"  a tendency to wrap every single page element inside its own division.  This is counter-productive.  You shouldn't use ID except for top level elements such as #header, #navbar, #content, #sidebar, #footer.  Everything else should fit inside one of those divisions.
    IMO your menu would be so much better if you simplified it and used an unordered list instead of all those divisions.
    <ul id="navbar">
    <li><a href="#">HOME</a></li>
    <li><a href="#">ABOUT</a></li>
    <li><a href="#">GALLERY</a></li>
    <li><a href="#">VISUAL EFFECTS</a></li>
    <li><a href="#">PRINT SALES</a></li>
    <li><a href="#">NEWS</a></li>
    <li><a href="#">CONTACT</a> </li>
    </ul>
    Then simply style your list to float:left and remove bullets like so.
    /* BEGIN HORIZONTAL DROP-MENU */
    #navbar ul{
    margin: 0;
    padding:0;
    #navbar li {
    list-style: none;
    font-size: 12px;
    float: left;
    /**LINK STYLES**/
    #navbar li a {text-decoration:none; display:block;}
    #navbar li a:link {color: #CCC}
    #navbar li a:hover,
    #navbar li a:active,
    #navbar li a:focus {color: #FFF; background: #333;}
    You can see a working example here (look at the code to see how it comes together)
    http://alt-web.com/DEMOS/CSS2-Horiz-Drop-Menu.shtml
    Hope this helps,
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • I am out of space on my Macbook Air and have a Time Machine Backup. I want to complete reset my mac, but wonder if I can pick and choose what I restore to my computer? Can I also use my time machine backup and external storage as well?

    I am out of space on my Macbook Air and have a Time Machine Backup. I want to complete reset my mac, but wonder if I can pick and choose what I restore to my computer? Can I also use my time machine backup as external storage as well for the files I don't need everyday?

    If you are using "Restore from Time Machine Backup" option from OS X Recovery, you can only choose from the broad categories presented.
    ... Can I also use my time machine backup as external storage as well for the files I don't need everyday?
    To be clear, if you are asking if you can use the volume containing your Time Machine backup to store additional, non-Time Machine files, the short answer is yes.
    It's not a good idea though, since the Time Machine backup will eventually fill all available space, after which it begins to remove old, "expired" backups to make room for newer ones. The presence of additional files doesn't change that fact, and Time Machine will not erase them, but you will encounter a dilemma should you want to store additional files on that volume when there is no remaining space. You will have to make room for them on your own, by deleting existing files. Furthermore, since Time Machine cannot back up its own volume, those additional files will not be backed up by Time Machine.
    The easy solution for what you describe is to purchase additional external storage. External USB hard disk drives have become very inexpensive; about $55 will buy a perfectly suitable 1 TB drive.
    You can also choose to replace your MacBook Air's internal storage with a larger capacity one. Look for a suitable replacement from OWC / MacSales:
    http://eshop.macsales.com/shop/SSD/OWC/Air-Retina
    That gets a little more expensive but it is the optimum solution.

  • Hp stream running out of space due to windows updates.

    So having had my stream 14 for a few months now it was in need of a clean up and so I decided to factory reset it and discovered a serious issue regarding lost drive space caused by windows updates.
    In factory shipped condition, the system uses some sort of system that accesses the recovery partition to use the data on the WIM I believe, either way whatever it is doing is quite clever and leaves the system with a farly impressive 19.3GB of free space left over, however this situation rapidly degrades once windows starts to update itself. 
    Allowing Windows 8.1 X64 to update to the last available 'important' update reduces the available free space down to 10.8GB, that's a massive (when taken in context of how much is available) 8.5GB of space gone just by windows performing what are supposed to be important updates, not sure how much worse it will get with time either as it appears that any updated files are expanded to fill the available space rather than stored in the WIM image.
    Do HP consider it uneccesary to update windows or are they going to take action to somehow rectify the situation by maybe providing an updated system image that will allow a more recent updated version of windows to be used in the same manner the original installation was? Or is there something I can do to perform this function?
    Any ideas?

    @Dano314 ,
    Hello and thank you for posting on the HP support forums.  The updates are put out there to resolve issues.
    If you find you are running out of space. Consider using an external hard drive.  The hard drive on your system is not made for huge file storage and so on.  
    On the other hand if you find your system is running ok then do updates when you seem to find you are running into issues.
    Thanks again for posting and have a great day.
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    D5GR
    I work on behalf of HP

  • HT5318 Ever since I updated what looked like iTunes 10.6.1 my computer has been corrupted with Malware, which has filled up all available space on my hard drive.  What do I do to get rid of the Malware?

    Ever since I updated what looked like iTunes 10.6.1 my computer has been corrupted with Malware, which has filled up all available space on my hard drive.  What do I do to get rid of the Malware?

    First, reboot. That will temporarily free up some space. According to Apple documentation, you need at least 9 GB free for normal operation. You also need enough space left over to allow for growth of your data.
    Use a tool such as OmniDiskSweeper to explore your volume and find out what's taking up the space.
    Proceed further only if the problem hasn't been solved.
    ODS can't see the whole filesystem when you run it just by double-clicking; it only sees files that you have permission to read. To really see everything, you have to run it as root.
    First, back up all data if you haven't already done so. No matter what happens, you should be able to restore your system to the state it was in at the time of that backup.
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ If you’re running Mac OS X 10.7 or later, open LaunchPad. Click Utilities, then Terminal in the page that opens.
    After installing ODS in the Applications folder, drag or copy — do not type — the following line into the Terminal window, then press return:
    sudo /Applications/OmniDiskSweeper.app/Contents/MacOS/OmniDiskSweeper
    You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning not to screw up.
    I don't recommend that you make a habit of this. Don't delete anything while running ODS as root. When you're done with it, quit it and also quit Terminal.

  • HT201364 When I try to download this I get a message that says I haven't got sufficient space on my startup disk. I have checked my available space on the disc and I have only 3GB free out of 500. I have hardly anything on my mac - how can this be?

    When I try to download this I get a message that says I haven't got sufficient space on my startup disk. I have checked my available space on the disc and I have only 3GB free out of 500. I have hardly anything on my mac - how can this be?

    Freeing Up Space on The Hard Drive
      1. See Lion/Mountain Lion's Storage Display.
      2. You can remove data from your Home folder except for the /Home/Library/ folder.
      3. Visit The XLab FAQs and read the FAQ on freeing up space on your hard drive.
      4. Also see Freeing space on your Mac OS X startup disk.
      5. See Where did my Disk Space go?.
      6. See The Storage Display.
    You must Empty the Trash in order to recover the space they occupied on the hard drive.
    You should consider replacing the drive with a larger one. Check out OWC for drives, tutorials, and toolkits.
    Try using OmniDiskSweeper 1.8 or GrandPerspective to search your drive for large files and where they are located.

  • Getting out of space warning with 500  gb available?

    My wifes computer keeps generating an error message that the boot disk is out of space, yet she has over 500 gb of available space. Anyone got a clue as to what is going on?

    I was able to grab a screenshot before my wife cleared the message. The message is as follows:
    So, it looks like it may have something to do with the swap file, although as I stated above, I ran a verification of the hard drive and eveything checked out fine. Anyone got any suggestions?

  • Greyed Out "Free Space" in Disk Utility

    Hi
    I have a problem with my main Logical Volume Group / Partition. So My main Logical Volume Group (Macintosh HD) was separated into 2 partitions. I decided to delete the second one, and once the process started in Disk Utility, it crashed. Now if I look at the Logical Volume Group, it is separated in two, first one being Macintosh HD, and the second one is greyed out and is "Free Space".
    Now If I look at the info of my Logical Volume Groupe, it says "Capacity 853,07 GB / Available 115 KB" when in actuality I have a 1TB fusion Drive, If I look at the Macintosh HD PARTITION, it says "Capacity 844,56GB / Available 252.99GB" which evidently doesn't add up. The "Free Space" is supposedly 267,78GB...
    I tried "filling" that free space with a new partition, but when I apply the changes to the partition layout, nothing happens, and it reverts back to being greyed out and empty. (I tried both in Disk Utility, and in Disk Utility while in Recovery Mode, and I've also Repaired the volume and the partition)
    How can I either force-create a partition with that free space, so that I can use all of my actual HDD space, or completely erase that "Free Space" and have my Macintosh HD partition fill the whole Logical Volume Group. (I tried erasing the free space of the Macintosh HD volume, but it didn't change anything.
    Hopefully, there is a way to do it without having to back up my whole Macintosh HD partition, and reformatting my whole computer...
    Thanks

    If you wish to delete data, the best option would be to encrypt everything on the drive (locking everything with a password)  and then erasing the drive.   This would atleast scramble the left over data.   The problem is that SSDs have a wear controlling firmware that distribute the load accordingly, so the entire drive wears evenly.   Secure erase wouldnt work since secure erase works by first erasing the refrences to the data, and then writing 0s over the left over data.   Since the firmware distributes the load differently each time, there is no guarantee that the data would be covered in 0s.  

  • Image size to fill out the IE window

    Hello,
    I have a view with a menu on the left and a view container on the right side.
    In the view container a linked another view.
    That only constist of an image. I want this image to fill out the whole space available in the IE.
    if somwbody has a low monitor resultion, it should be rezised to fill out everything and if somebody has a high resultion its the same. I dont want any "scroll bars" in the IE because the picture is to big nor I want empty space because the picture is displayed smaller than the window of the IE.
    I have tried everything out. I put the image in a transparent container with "stretch", i set high and width for the transparent container and the picture to 100% but nothing really works.
    As soon as I set high of the image to 100% it zero pixel. But if I set an value with px, em or ex I define the size and rezising is not done. And I cant see what the option "adjust image size" really does. I cant see any difference by (un)-checking it.
    Is there any way to tell an object to be exactly that size the IE has? Is webdynpro able to recognize the monitor resolution and render an object to exactly that size?
    Thanks for your help!

    Thanks for the quick answer!
    It does not work.
    I can only see a very thin horizontal like. The image gets "compressed" to about 3 pixel and the line is as long as the image is wide (so no vertical sizing as well).
    I tried it with WinXP SP3 and IE8.
    I tried it with WinXP SP3 and IE6.
    I tried it with my own PC via VPN to make sure its no nasty setting to our company desktop and I have only Windows, Office, SAP GUI on it. Nothing else.
    Always the same result. As soon as I set the height of the image to 100% I get only a thin horizontal line.
    You were able to accomplish. So I tried FireFox portable - and it works!
    My lesson learned is that a picture can only be re-sized to a smaller size but not expanded. Thats no problem, I could use a 1600x1200 pixel graphic and then its made smaller.
    But we have to use IE because thats the companies standard and SAPs as well.
    We have the application running on a NetWeaver 2004s BI 7.0 machine. No EHP1. System got latest patches 3-4 month ago.
    I cant believe that the SAP machine is the problem, because FireFox renders the graphik the same as your screenshots show.
    Do you have any idea what the problem could be? Or could it be some kind of customizing/parameter problem within SAP? I have the problem since over 1 year and always thought its just a bug getting solved somewhen by a patch...

  • Blu-Ray Fit Contents to available space

    I made my first blu-ray disc in PreEl, and I tried to add as many raw video clips exported from my Canon Vixia HF200 as would fit on the disc.  On the Share->Blu-Ray settings, it said the space required was 22.89 GB, and I then checked the "Fit Contents to available space" box, which changed the Space Required to 23.30 GB.  The disc came out ok, but I discovered there was about 7GB left unused, and it is visually obvious the burner didn't use the last 1/2 inch or so of space on the bottom of the disc.
    Is there a better way to try to utilize all the available disc space?  In this case, my goal is to archive as many original video files as possible onto a disc.  However, I have tried to group them together and add menu markers to them, so I don't end up with 200+ chapters on the disc.
    I plan to actually edit and create videos more in the future, but for now I'm thinking in terms of getting many hours ofHD video off my hard drive and making multiple backup copies to blu-ray discs.

    Neale,
    Unless things have changed, and this could be by version, or a difference between BD and DVD-Video, PrE uses a 2-Pass VBR Transcoding scheme. What this means is that PrE measures what it thinks the size will be, then runs the first pass. This pass basically samples the motion in the Timeline, and stores data to be used in the next pass. Then, on the second pass, that info is used to assign a higher Bit-Rate to areas of high motion, and lower Bit-Rate to areas of less motion. It is not until PrE is completely done with the second pass, that it knows for sure, how large the file will be, as the Bit-Rates will be altered, as needed throughout the process.
    The multi-pass Transcoding is how Hollywood crams so much high-quality material onto a DVD, or BD. There Transcoding software will do maybe 9-Passes, or even more, and then the operator can tweak things as required. This results in a variable Bit-Rate that is the ultimate for every segment of the Timeline - not 1 MB/s more than is needed, and very high motion at the best possible Bit-Rate to keep that smooth. Never too much, and never too little. Sort of a Goldie Locks situation, and run by highly-trained professionals, who do nothing else all day long, using software that costs more than a Mercedes E-Class.
    As for the BD-Data, one is not Transcoding to produce that. If there is any Transcoding, it would first be done by the user, and then the resultant files would just be Copied over to the BD-Data disc. As you say, one would calculate the number of files, times their size, and subtract that from the capacity, adding more, or subtracting some, to fill the BD-Data.
    Hunt

  • Available Space on My Time Capsule

    So I have almost filled my time capsule 1TB, so I was deleting a couple things to make space to add a new item. When I deleted the other things, the available space number didn't change and I made sure to also empty it out of the "time capsule" related trash. When I tried to add the new items they wouldn't transfer over due to not enough space. The things I deleted were bigger than the stuff I was trying to add. Is this a common error or most likely just a product defect?

    Rozloff wrote:
    I drag my movies from their folder under my user tab and drop them right into "Time Machine Backups" that is listed under the "Devices" tab, is that a problem?
    Probably.
    When you open the TC via the Finder, you should see a "Data" folder. That's where you should be putting your files, not the sparse bundle (it's name includes your computer name) that contains your backups. See this post by Jolly Giant: http://discussions.apple.com/thread.jspa?messageID=11349464&#11349464
    Via the Finder, double-click the +sparse bundle+ to mount it; then double-click the +Time Machine Backups+ disk image to open it. It will contain a folder named Backups.backupdb. Do NOT touch anything inside that folder: those are your backups, with a complex structure that will be hopelessly corrupted if anything is moved, changed, or deleted.
    If your other stuff is inside the sparse bundle, but outside the Backups.backupdb folder, you may be ok. Drag it out of the sparse bundle, to the Data folder.
    Then, very carefully, "compact" the sparse bundle, per the pink box in #12 of the Frequently Asked Questions *User Tip,* also at the top of the +Time Machine+ forum.
    Then go into Time Machine's "Star Wars" display and browse your backups. Make sure you can navigate to different ones; also restore a few items from a few different backups (especially the most recent one), but to an +alternate location,+ such as your desktop (see #17 in the FAQ Tip). If all that works, and backups continue to work, your backups may be intact.
    But eventually, keeping your other data on the TC that way will cause problems, as per #Q3 in the Using TIME MACHINE with a TIME CAPSULE *User Tip*

  • Onedrive for business "the server is out of space"

    hi,
    - on premise SharePoint server 2013
    - dedicated "my site" web application.
    - the sites collection has the right quotas
    - the server has a lot of space available.
    OneFor Business client app have a strange behaviour:
    - I synch small files < 1mb: works
    - I synch one file of 300 mb, the client app (OneDrive for b) give me "the server is out of space"
    - I remove my "300mb" file from my client and I synch one file of 50mb: works
    - I synch other 10 files of 50mb and WORKS
    - I retry to synch the file of 300mb and the client app give me "the server is out of space"
    - I remove the file with the error and I try to synch a smaller file like 250 or 200 mb, same error.
    - I try to synch other files of 50, 60, 70mb that added more than 300mb and WORKS!
    what is the problem ?

    Have you looked at Site Quotas on the MySites in Central Administration on the SharePoint server, as well as Database size to validate that there isn't database size restrictions in place, and lastly, free space on the volume holding the database files
    on the SQL Server?
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • My MacBook Pro is almost out of space on my startup disk?? The computer is only a month old!!

    I have a new MacBook Pro, and I also got the iphone 5 for Christmas.  I wanted to upload all the pics/videos off of the old iPhone onto my MacBook before restoring it and setting up the new iPhone.  Once I started the import process, halfway through, I got a notice saying I was getting close to running out of space of my startup disk.  This seems weird to me.  I am new to Mac systems, and am trying to find where I can see how much memory I am using, how much I have available.  Can someone help me?
    I feel very computer illiterate!!!

    Would you please post these two displays from your MBP:
    This is found >About This Mac>More Info...>Storage.  (the Apple icon  is in the left hand corner of your menu bar)
    Click on the HDD icon in the upper left hand corner of your desktop, COMMAND I (the letter i).  The icon will probably be labeled McIntosh HD.
    Ciao.

  • How can I stop partially filled out "Contact Us" websites from disappearing

    If I want to contact a supplier to complain about a problem with his goods, on his website I find a form "Contact Us". This form usually has mandatory lines for my name, e-mail, address, phone number, etc.which must be filled out. Then the subject matter is supposed to be typed up in the space provided on the Form.
    Many times such a Form suddenly disappears from the screen, before my typing is complete. Some of such disappearances are triggered by hitting the "Return" on the keyboard, when I want to start a paragraph. Obviously such a website is set up to understand this button only as "Enter" (because there is no proper "SENT" button) and thus sends the form up line uncompleted.
    In any case, it suddenly disappears from my computer. The recipient will have no idea what the incomplete form is really about, and thus will not respond. What is really troubling is that when I go to my FF History and reload the form, or reload from the back-button, the form will only re-appear totally empty, and all my previous typing on the same form is lost.
    Is there a way to set FF Preferences to prevent the disappearance of the completed content?
    If not, there should be, both to stop the whole thing from happening over and over again, and secondly to provide an e-mail like record of what comment was sent by me.
    MacbookAir/Mac 10.8.3/ Firefox 21.0

    As long as a text area has focus then the Enter key should add a new line.<br />
    If you are in a single line input field then the Enter key will submit the form.
    It is best to use the Tab key to move to the next field when filling a form.
    * https://support.mozilla.org/kb/Pressing+Tab+key+does+not+select+menus+or+buttons#os=mac
    * http://kb.mozillazine.org/accessibility.tabfocus

Maybe you are looking for

  • Edit in Adobe Photoshop is not working

    Hi, I have this strange problem with Lightroom/Photoshop integration. It is easier to describe what is working than what is not. When I select a single JPG or PSD photo from Lightroom integration works ok. I can open the photo directly as "Edit in Ad

  • How do you keep the same URL connection connected continuously?

    I am trying to extract information from a web page, but it puts a cust_id in the middle of the URL. It generates the cust_id randomly everytime you use the site. I connect to the initial URL to find the cust_id, I substring that to the new URL and th

  • SOA 10.1.3.3 Application server cannot use db 11.1.0.6.0 for orabpel user

    RDBMS Version: 11.1.0.6.0 Operating System and Version: win 2000 sp4 Error Number (if applicable): Product (i.e. SQL*Loader, Import, etc.): SOA Suite Application Server 10grel3 Product Version: 10.1.3.3 SOA 10.1.3.3 Application server cannot use db 1

  • HT1688 Can't get texts from Android, SMS or MMS

    Can't get texts from Android, SMS or MMS

  • Workbook in webtemplate

    hello friends, can u please tell me that can we create a web tamplate for workbook..? i have created a workbook and saved 2 queries in that. now i want to execute the same workbook on qweb so i will be able to view both view on web.. please tell me h