Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8389595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:46:16+00:00 2026-06-09T18:46:16+00:00

I want go full screen and keep everything inside in order. How should i

  • 0

I want go full screen and keep everything inside in order.

How should i put the JFrame into full screen AND rescale everything inside: images, generated drawings etc.(sth like zooming it up so the content will fit the screen).

The problem is I am making full screen app, but I don’t know on what screen it will be displayed.

This will put the frame into fullscreen, but the content will not be rescaled

   frame.dispose();
   frame.setUndecorated(true);
   frame.setLocation(0, 0);
   frame.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());
   frame.setVisible(true);
   frame.repaint();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:46:18+00:00Added an answer on June 9, 2026 at 6:46 pm

    If this really is what you want to do (see warnings from other answers), it’s not too hard to do (but takes a little time to figure out). Basically, it involves extending JPanel, and then overwriting the paint method.

    Here’s a sample that I came up with:

    import java.awt.*;
    import java.awt.image.BufferedImage;    
    import javax.swing.*;
    
    
    public class CustomPanel extends JPanel{ 
    
        Component myComponent;
    
        public CustomPanel(){
            super();
            setLayout(null);
        }
    
        /**
         * Only allows one component to be added
         */
        @Override
        public Component add(Component c){
            super.add(c);
            c.setLocation(0, 0);
            c.setSize(c.getPreferredSize());
            myComponent = c;
            return c;
        }
    
        @Override
        public void paint(final Graphics g){
    
            Dimension d = this.getSize();               
            Dimension p = myComponent.getPreferredSize();
    
            // Paints the child component to a image
            BufferedImage newImg = new BufferedImage(p.width, p.height, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2d = newImg.createGraphics();
            super.paint(g2d);
    
            // Resizes the image if necessary
            Image img;
            if(d.height > p.height && d.width > p.width){
                System.out.println("Scaled");
    
                float changePercentage = 0;
                if(d.height/p.height > d.width/p.width){
                    changePercentage = (float)d.width/(float)p.width;
                } else{
                    changePercentage = (float)d.height/(float)p.height;
                }
                System.out.println(changePercentage);
    
                int newHeight = ((Float)(p.height * changePercentage)).intValue();
                int newWidth = ((Float)(p.width * changePercentage)).intValue();
    
                img = newImg.getScaledInstance(newWidth, newHeight, 0);             
            } else{
                System.out.println("Not Scaled");
                img = newImg;
            }
    
            // Paints the image of the child component to the screen.
            g.drawImage(img, 0, 0, null);
        }
    
        public static void main(String[] args) { 
            // TODO Auto-generated method stub 
            SwingUtilities.invokeLater(new Runnable(){public void run(){
    
                JFrame frame = new JFrame("Zoom Panel"); 
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
                frame.setSize(300, 200); 
    
                CustomPanel buffer = new CustomPanel();
                JPanel content = new JPanel();
                content.add(new JLabel("Bogus"));
                content.setBackground(Color.red);
                buffer.add(content);
                frame.setContentPane(buffer);
    
                frame.setVisible(true); 
                new CustomPanel();
    
            }}); 
        } 
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

win32 windows application and want to capture full screen and remove the border of
I have a few full screen png's where I want to create regions on
I want a ListBox full of items. Although, each item should have a different
I have a <div> which I want to display full screen, but I also
I'm searching for a solution in order to keep a JFrame always on top
When a user clicks a button, I want a full screen iAd to appear,
I want to create full screen topmost (screen saver) window with MFC? How to
I want my silverlight app to run in full screen (disabling the battery/signal bar
I want to have a UIScrollView that scrolls less then the full screen so
I am Developing an app for(honeycomb)tablet , want a full screen view.how to hide

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.