Results 1 to 4 of 4
  1. #1
    knightwriter is offline Member
    Join Date
    Nov 2011
    Posts
    49
    Rep Power
    0

    Default Image sizing is driving me nuts!!!

    I've looked all over the internet, and I don't have any text at the moment on Java gui. I've created a .png picture file and can insert it into the jlabel with the Jframe. However when I insert the picture it doesn't resize to the dimensions of the jlabel box. When added it blows up into a huge picture causing my entire Jframe to be much larger than my computer screen when I run the application.

    Why is the image not resizing to the dimensions of the jlabel? I'm using the designer gui instead of coding all of it by hand.

    Any ideas?

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default Re: Image sizing is driving me nuts!!!

    When you read an image file you can set the dimensions of the image before you add it to the JLabel. Just check the code view and edit it yourself.

  3. #3
    knightwriter is offline Member
    Join Date
    Nov 2011
    Posts
    49
    Rep Power
    0

    Default Re: Image sizing is driving me nuts!!!

    I was hoping to be able to have the image snap to the size of the JLabel without having to do the coding, but if that's the only way, than I will do that. I'm trying to compare the Java Gui Designer with Visual Studio's Gui Designer. So far VB and Visual Studio are much easier to use in a plug and play fashion. Eventually, I will want to learn how to code everything gui related in Java. I was just interested in seeing what I could do without much coding.

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Image sizing is driving me nuts!!!

    Java GUI tools are somewhat weak and outdated compared to other modern tools. I don't think the primary focus of java is for pretty GUI apps - all of our java code runs headless on servers. When GUIs do come into play, they are generally rather ugly afterthought front ends. 99% of our guy work is done in a web presentation layer using grails or rails. For pure desktop applications, there are frameworks like Griffon which help with some of the messy swing stuff, but no matter how you slice it, swing is kind of messy and hard to work with. If you're really interested in GUI design, java might not be the best place to look (pure java anyway) and you might consider looking into a GUI package provided by someone that does just that.

    Good luck though - In your case, you can make the image auto size, but it will involve measuring the window and setting that size on-demand with action listeners. This involves code! :D

Similar Threads

  1. JTable sizing issues
    By Timmins in forum AWT / Swing
    Replies: 6
    Last Post: 04-02-2011, 02:40 AM
  2. Syntax error driving me nuts
    By CeeLove in forum Java Applets
    Replies: 2
    Last Post: 03-25-2011, 10:15 AM
  3. Panel sizing
    By sjs in forum AWT / Swing
    Replies: 5
    Last Post: 10-11-2010, 03:13 AM
  4. image does not refresh-driving me crazy
    By jambon in forum AWT / Swing
    Replies: 1
    Last Post: 04-09-2010, 04:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •