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 5 of 5

Thread: How to maximize a JFrame Form?

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile How to maximize a JFrame Form?

    Hello friends..
    Posting for the first time since i am really an amateur to java.
    What i am trying to do is making a GUI based Application in Netbeans.
    I have a JFrame form in my application. Now i need to open this JFrame Form into full screen and maximized(obviouslyd different systems have different resolutions. So how to get to open my application in fullscreen on any machine??)

    Also I Would like to ask about how to put up a picture in a JPanel. I have a surface knowledge of the topic that you have to pass the image as an object but i really don't know how.
    Please help

    Thanks in Advance..
    And Thanks to all the members of the forum, You guys are doing a really Great Job helping out people with their problems.

    Regards.


  2. #2
    Junior Member Krumpir's Avatar
    Join Date
    Jul 2012
    Location
    Cape Town, South Africa
    Posts
    9
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: How to maximize a JFrame Form?

    To maximize a JFrame you need the following code.
    myFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    And to put an image in a JPanel you would create a JLabel and set the ImageIcon for that JLabel.
    someLabel.setIcon(new ImageIcon("C:\\Documents and Settings\\User\\Desktop\\image.png"));
    Check out my site -> tssolutions.net16.net

  3. The Following User Says Thank You to Krumpir For This Useful Post:

    Yogesh4591 (July 27th, 2012)

  4. #3
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to maximize a JFrame Form?

    Thanks buddy... I think that shall work cheers...
    The Maximizing worked..

    but the code to place an image ain't working

    Basically I am using a JDesktopPane to place internal frames in my Application and i want to apply Image to this JDesktopPane as a background.
    Now what happens is when i use a label inside this DesktopPane to place an image as :

    public class User extends javax.swing.JFrame 
    {
        public User() 
        {
            this.setExtendedState(JFrame.MAXIMIZED_BOTH);
            image.setIcon(new ImageIcon("D:\\Visuals\\walls\\Windows-8-Grass-Wallpaper1.jpg"));
            initComponents();
            paneltransact.setVisible(false);
            panelmastershoots.setVisible(false);
            panelmasterview.setVisible(false);
            //int height,width;
        }

    where during runtime the following error is generated:

    error3.jpg

    please help i also tried placing a panel inside the desktop pane and then placing a label inside the panel and then working out and same error showed up.
    Last edited by Yogesh4591; July 27th, 2012 at 12:26 PM.

  5. #4
    Junior Member Krumpir's Avatar
    Join Date
    Jul 2012
    Location
    Cape Town, South Africa
    Posts
    9
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: How to maximize a JFrame Form?

    Where did you initialize the JLabel? It seems like you might be missing the following.
    JLabel image = new JLabel();
    // And then then set the imageicon
    image.setIcon(new ImageIcon("D:\\Visuals\\walls\\Windows-8-Grass-Wallpaper1.jpg"));
    Check out my site -> tssolutions.net16.net

  6. #5
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to maximize a JFrame Form?

    I placed a JLabel component named "image" and it was automatically initialized inside the class(as it is done in netbeans). And then used the code :

    image.setIcon(new ImageIcon("D:\\Visuals\\walls\\Windows-8-Grass-Wallpaper1.jpg"));

    and it still ain't working... sorry...i think will have to live without an image in project...
    its okay...i can manage with that

    By the way thanks for ur efforts..

Similar Threads

  1. How to maximize a JFrame Form?
    By Yogesh4591 in forum AWT / Java Swing
    Replies: 1
    Last Post: July 26th, 2012, 12:59 PM
  2. JFrame Minimize/Maximize Refresh Issues
    By bgroenks96 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: June 18th, 2011, 08:55 PM
  3. [SOLVED] Add more components from JFrame Form
    By zecute in forum AWT / Java Swing
    Replies: 3
    Last Post: May 11th, 2011, 08:30 AM
  4. Open JFrame Form With Button
    By cardamis in forum AWT / Java Swing
    Replies: 2
    Last Post: April 12th, 2011, 04:18 AM
  5. Java Swing :Back Button from one form to another form
    By srinivasan_253642 in forum AWT / Java Swing
    Replies: 1
    Last Post: December 26th, 2009, 09:51 AM