Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: JAVA Image Icon and JButton resizing problem

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JAVA Image Icon and JButton resizing problem

    Hi everyone,

    I am stuck on a JAVA problem again.

    I want to figure out how to do a ImageIcon resize.

    Here is my following code:

    ImageIcon imageClickForMovies = new ImageIcon("clickForMovies1.GIF");
    JButton buttonClickForMovies = new JButton(imageClickForMovies);

    If anyone can explain to me how to resize the ImageIcon and the Jbutton, that would be great. By the way, I am a very simple-minded person. So, please explain instructions carefully, so that it is in an understandable manner for me.

    - Nathe


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: JAVA ImageIcon and JButton resizing problem -- please go easy on me. :)?

    Hello Nathe,

    What type of layout are you using? The different layouts will effect how you resize these components.

    Here is a really good tutorial on layouts that leads onto how to size swing components and set their position:

    A Visual Guide to Layout Managers (The Java™ Tutorials > Creating a GUI with JFC/Swing > Laying Out Components Within a Container)

    Here is a quick method you can try first:

    JButton button = new JButton ("Click me");
    button.setSize(100,100);
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. How to Add ActionListener to a JButton in Swing?
    By JavaPF in forum Java Swing Tutorials
    Replies: 17
    Last Post: April 24th, 2013, 05:14 PM
  2. [SOLVED] Error "TitleChanger is abstract; cannot be instantiated"
    By Uzual in forum AWT / Java Swing
    Replies: 2
    Last Post: May 26th, 2009, 11:23 AM
  3. Java GUI problem in paintComponent?
    By Richard_ in forum AWT / Java Swing
    Replies: 2
    Last Post: May 1st, 2009, 08:19 AM
  4. [SOLVED] JAVA JList Problem in visual images
    By antitru5t in forum AWT / Java Swing
    Replies: 4
    Last Post: April 15th, 2009, 03:09 PM