ImageIcons in a JLabel get their top-most row of pixels cut off

Hello. I've added a "Loading..." screen to my application that basically consists of a JWindow with a background image. However, I've noticed something odd when adding an ImageIcon to a JLabel. It seems that any image I add gets its top row of pixels cut off. The small program below illustrates this.
import javax.swing.*;
import java.awt.*;
public class JLabelTest {
   static final String WINDOW_IMAGE = "my_image.jpg";
    * Create and display the loading screen
   private static void displayLoadingScreen()
      SwingUtilities.invokeLater(new Runnable() {
         public void run() {
            JWindow winLoadingScreen = new JWindow();
            ImageIcon loadingImg = new ImageIcon(WINDOW_IMAGE);
            JLabel lblImage = new JLabel(loadingImg);
            winLoadingScreen.getContentPane().add(lblImage);
            winLoadingScreen.pack();
            System.out.println("label dimensions:      " + lblImage.getSize().width + " x " + lblImage.getSize().height);
            System.out.println("image icon dimensions: " + loadingImg.getIconWidth() + " x " + loadingImg.getIconHeight());
            winLoadingScreen.setLocation(100, 100);
            winLoadingScreen.setVisible(true);
    * Entry point
    * @param args
   public static void main(String[] args)
      SwingUtilities.invokeLater(new Runnable() {
         public void run()
            displayLoadingScreen();
}(Obviously, replace my_image.jpg with something else if you'd like to run the code on your own machine.)
When I run the program with, say, an 800 x 600 resolution image, the output I get is:
label dimensions:      800 x 599
image icon dimensions: 800 x 600As you can see, the image gets "shortened" by one pixel when added to the JLabel. If you look at the image that is displayed, you can see that it's the top row that gets cut off. I've tried changing the layout of the JWindow that the JLabel is being added to, but that didn't change anything. I've tried using a number of different images in varying formats, and the same thing happens to all of them.
Any ideas? Thanks in advance.

Have you tried to set label's preferredSize manually?
What happens when you add empty border t the label with some insets?
regards,
Stas

Similar Messages

  • I downloaded an album and most of the songs cut off before they are done

    I downloaded an album and most of the songs cut off before they are done. How can i get a refund or credit for this?

    If your country's iTunes Store allows you to redownload purchased tracks, I'd delete your current copies of the dodgy tracks and try redownloading fresh copies. For instructions, see the following document:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Otherwise, I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the items that are not playing properly. If you can't see "Report a Problem" next to the items, click the "Report a problem" button. Now click the "Report a Problem" links next to the items.

  • I just bought the new HDMI cord for the IPad, it works good but a small potion of the TOP and the BOTTOM is cut off. It doesn't seem to do it for movies. My monitor is a 23 IN' acer s series.

    I just bought the new HDMI cord for the IPad, it works good but a small potion of the TOP and the BOTTOM is cut off. It doesn't seem to do it for movies(although I can't really tell. My monitor is a 23 IN' acer s series. I just installed the drivers for my monitor with no change. I think I have a CD somewhere for my monitor maybe it has some kind of program in there that can help me. I can post a picture if I need to. Thanks

    No work around that I know of.
    Apple Feedback http://www.apple.com/feedback/

  • HT203167 just downloaded a music album and most of the songs cut off half way through i redownloaded the album and have the same problem

    just purchased an album and most of the songs cut off half way through

    Try again. Delete the copies of the corrupt tracks from your iTunes library, go to the iTunes Store home page, click the Purchased link from the Quick Links section in the right-hand column, then select Music and Not on this computer. You should find download links for your tracks there. In the downloads window remove the tick (if present) from Allow simultaneous downloads.
    If the problem persists contact the iTunes Store support staff through the report a problem links in your account history, or via Contact Support.
    tt2

  • How to get the top most community given a sub community ID

    Hi,
    I have developed a custom navigation scheme with top level communities as top nav and the sub communities of the top level communities in the left nav.
    Now when the user selects a particular sub community in the left nav the top level community in the top nav should be highlighted.
    I am able to get the first level parent community of the current community but not able to recursively reach the top most community.
    I have tried the following piece of code
    IPTCommunityManager ptOM = (IPTCommunityManager) ptMgr.GetInterfaces("IPTCommunityManager");
    IPTCommunityInfo ptCommunityInfo = ptOM.CachedOpenCommunityInfo(communityID ,true);
    IPTQueryResult result = ptCommunityInfo.GetParentCommunity() ;
    I dont know how to get the communityID from result
    Any pointers in this regards will be very helpful
    Thanks

    To get community ID from the result just use this code:
    int nCommID = result.ItemAsInt(0, PT_PROPIDS.PT_PROPID_OBJECTID);
    The NavigationModel class in portalpages project has a wealth of code dealing with these types of tasks. Look around there if you don't know how to code something, it is a good source for examples.
    You would then get the CommunityInfo object for the parent community ID and call GetParentCommunity again until you reach the top. The IPTCommunityInfo objects are cached so the performance will not be too bad.

  • How to get current top-most JFrame/JDialog?

    my problem is:
    i want to show an error message(JOptionPane). it could be shown at anytime because i am using another thread to show this error message(upon receiving of the Socket). but i dunno how to specify its owner in this case since it could be shown at anytime. i think if i can get the current top-most frame/dialog, then can set it to be the message owner. is it correct and how? or got any other better choice?

    OMG

  • How to get top most rows col into a vriable.

    hi,
    i want to get the smallest
    "Tid" greater than v_Id1
    into v_b
    which method i should use both are working.
    1)
    SELECT *
    INTO v_b
    FROM ( SELECT TId
    FROM tt_T
    WHERE TId > v_Id1
    ORDER BY TId )
    WHERE ROWNUM <= 1;
    2)
    SELECT *
    INTO v_b
    FROM (SELECT Tid
    FROM ( SELECT TId
    FROM tt_T
    WHERE TId > v_Id1
    ORDER BY TId )
    WHERE ROWNUM <= 1);
    yours sinicerely
    Edited by: 944768 on Apr 28, 2013 9:35 AM

    Hi,
    944768 wrote:
    i wanted to know about the correctness of my sql.
    so please tel me which one is correct . or both are correct.You said both give the results you want, so both are correct.
    The ways Solomon posted are also correct, and they are better, because they are faster and/or easier to maintain.
    and specially about one extra bracket which i have in my 2) stmt.What do you see as the advantages and disadvantages of the 2 ways you posted?
    If 2) is better than 1), wouldn't this be even better han 2)?
    SELECT  *
    INTO      v_b
    FROM      (
             SELECT  TId
             FROM    (
                          SELECT    TId
                   FROM       (
                              SELECT  TId
                              FROM    (
                                             SELECT    TId
                                    FROM         tt_T
                                    WHERE         TId > v_Id1
                                    ORDER BY  TId
                                  WHERE   ROWNUM <= 1
    ;Why stop at 4 sub-queries?

  • CS5 64bit - top of HDR filter window cut off

    When I open the HDR toning filter the top of the HDR controls window is always hidden under the top edge of the screen.  I can't reposition the window.  This is in CS5 64bit.  When I make the same actions in CS5 32bit and in CS6, the whole of the HDR filter window is visible in the normal way.
    How can I get to see the whole HDR controls window again in CS5 64bit please?

    Looks like you're seeing the compressed version of the dialog, made for small screens.
    I take it you're not seeing an OK button over on the upper-right, even if you move the dialog to the left?
    -Noel

  • Analog video converted to digital is playing with tops of people's heads cut off?

    I am successfully converting analog to digital and capturing it in my project.  However, when I play it, the tops of people's heads are chopped off and that is not how it was recorded?  Can I fix this?

    This thread might be helpful:
    https://discussions.apple.com/thread/5590792
    Your footage is probably 4:3 and iMoive is blowing it up to fit 16:9.
    Matt
    Message was edited by: Matthew Morgan

  • Most Iphone photos are cut off when using any app (ie CVS, Shutterfly etc). Is there any way to prevent this?

    From what I've read cut off photos are due to iPhone not being 3:2 ratio, but what can I do to fix this? I take all of my photos on my iPhone and printing them out is ALWAYS a disappointment and I feel like my pictures are useless.

    If you go to Walmart they have a specific app to print your photos from your iPhone.
    Also with other stores they have good systems to print out photos from smart phones and iPhones now a days. And yes by official kiosk I meant any store with a photo printing machine, because if you print at home, size adjustments and all that are very complicated...unless you are like a professional perhaps...

  • When i go to full screen eg with bbci or google maps the top of the picture is 'cut off' by the tool bar - please let me know how i can correct this

    any advice about the above question gratefully received!
    david

    ok well that takes care of dead frontier. but my friend played on runescape.com and that blue bar is still there. so hears that I'm talking about look at the pic because that guy said it would be easier for you guy and I'm going to post this on the other post to got more answers.and i do have firefox 24.0 beta.
    o almost forgot to mention that i downloaded firefox on a different pc and that blue bar wasnt there so something is wrong with the software or something.

  • How to get Top most Manager in Org. Structure

    Hi Experts,
          I have an Organization Structure like the following:
                      [0]  MAIN ORG. UNIT
                               MANAGER9           
                              [1]  SUB ORG. UNIT1
                                     Manager1
                                     [1.1] Department1
                                               Manager2
                                               Manager3
                                               Supervisor1
                                               Supervisor2
                              [2]  SUB ORG. UNIT2
                                     Manager6
                                     [2.1] Department2
                                              Manager4
                                              Manager5
                                              Supervisor3
                                              Supervisor4
    1. I want to get the top most manager in the org. structure by looping the org. structure in workflow.
                            Here MANAGER9!!
    2. How can i get Manager1 by using the same.
    Waiting for your valuable Answer
    Thanks
    Regards
    Nizamudeen SM
    Edited by: Nizamudeen SM on Aug 26, 2008 4:08 PM

    These are the paramters to pass ..
    CALL FUNCTION 'RH_STRUC_GET'
            EXPORTING
              act_otype      = c_o
              act_objid       = w_orgunitid
              act_wegid      = 'ORGCHART'
              act_plvar        = '01'
              act_begda      = sy-datum
              act_endda      = '99991231'
            TABLES
              result_tab     = t_restab
              result_objec   = t_resobj
              result_struc   = t_reslt
            EXCEPTIONS
              no_plvar_found = 1
              no_entry_found = 2
              OTHERS         = 3.
          IF sy-subrc NE 0.
          ENDIF.
    It is not the orgunit id should be passed hear in your case it is manin orgunit ..so that it picksup the managers of child Orgunit as well.

  • How to get Top most parent Taskflow Id at runtime?

    Hi,
    I am working on a portal site and I need to get the parent Id of the current taskflow at runtime.
    Following is the code through which I get the current taskflow Id.
    ControllerContext cctx = ControllerContext.getInstance();
    ViewPortContext currentViewPort = cctx.getCurrentViewPort();
    TaskFlowContext taskFlowCtx = currentViewPort.getTaskFlowContext();
    TaskFlowId taskFlowId = taskFlowCtx.getTaskFlowId();
    String taskFlowName = taskFlowId.getFullyQualifiedName();
    But How can I get the parent Id if this taskflow is embedded within some taskflow(s). I want to get the top most parent Id.
    Your help is appreciated.
    Thanks,
    Jaykishan

    Hi, i tried this code but i'am getting ClassCastException.
    ControllerContext cctx = ControllerContext.getInstance();
    ViewPortContext currentViewPort = cctx.getCurrentViewPort();
    ChildViewPortContextImpl c = (ChildViewPortContextImpl)currentViewPort; (get error here oracle.adfinternal.controller.state.RootViewPortContextImpl cannot be cast to oracle.adfinternal.controller.state.ChildViewPortContextImpl)
    Object pViewPort = c.getParentViewPort();
    ViewPortContext parentViewPort = (ViewPortContext)pViewPort;
    String parentTaskFlowId = parentViewPort.getTaskFlowContext().getTaskFlowId().toString();
    how did you manage to make work ?

  • I am using Acrobat Reader 11.0.10 . I cant print mixed originals and also I cannot print letter size correctly . printing of first two pages ok but the rest gets cut off at the top

    How can I print from MAC with Acrobat Reader. I can't seem to get it to print correctly , first two pages of letter size works ok after the remaining pages get moved up and the printing is cut off.

    I arrived here looking for a solution!  And while reading your post the penny dropped that I didn't have a serious problem.  I have a booklet of 112 pages and all I needed to do was re-order the pages as printed so that 1 is followed by a sheet with 2 on the under-face but same side and so on.  The pages had printed back to front and needed flipping.  But then I have a duplex printer and maybe that makes a difference.  Is it to do with your manual duplexing and the order that the second pass is presented to the printer.  As my duplex sheets effectively needed flipping over each one I'm wondering if you can solve your problem with a little experimentation and re-ordering before your second pass.

  • Top of words cut off in MSword docs.

    In word docs, the top of the words are cut off. This does not happen in Quickbooks invoices.  I have cleaned & aligned cartridges, cleaned paper tray. Any suggestions

    Hi Jazpt
    Welcome to the HP Forums!
    I see that the top of words are cut off when printing from MS Word. I am happy to help you with this printing issue!
    For further assistance, I will need to know:
    The Product/Model Number of your printer. Follow instructions in this link. Finding Your HP Product Model Number.
    If you are using a Windows or Mac Operating System, and the version number. To find the exact version, visit this link. Whatsmyos.
    If the printer is connected, Wireless, Ethernet, or USB.
    If the printer is able to make copies by itself.
    If the power cable is plugged into a surge protector, or directly to the wall outlet. Issues when Connected to an Uninterruptible Power Supply/Power Strip/Surge Protector. This applies to Inkjet printers as well.
    Please see this post, Want Good Answers? Ask Good Questions, by @Bob_Headrick, so you can get the most out of these forums.  
    Hope to hear from you, and thank you for posting!
    RnRMusicMan
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to say “Thanks” for helping!

Maybe you are looking for

  • How do i send invite with 3gs and ios 6 calendar event?

    i can do it from the macbook pro but I have problem finding how to do it from the iPhone...      stupid me

  • Nokia N73

    Hi i have just bought a new Nokia N73 and i have a couple of questions and i carnt fine the answers in the manuel. 1 The light sensor on the top of the phone is blinking a blue light. why is this normal and why is it blinking. 2 As i am new to this p

  • VIEW_MAINTENANCE_CALL usage

    Hi all,      I have a requirement to maintain view V_024 from custom program. I have written following code for that     CALL FUNCTION 'VIEW_MAINTENANCE_CALL'            EXPORTING                action                               = 'U'             

  • Adobe to Word FAIL

    Hello, i have tried to convert a pdf file into word and i get this text in the created word file: To view the full contents of this document, you need a later version of the PDF viewer. You can upgrade to the latest version of Adobe Reader from www.a

  • No locationmarkers in Places PSE 11?

    Camera: Pentax K5 System: Windows 7 I used Geosetter for manually adding gps to metadata. I also used Geotag Photos pro on my Iphone. In both cases gps data is visible in metadata. In Geosetter, Flickr and (exported) Google Earth the locations of the