Black Border Around Screen: Causes and How to Fix It
Have you ever turned on your computer and noticed a black border around screen content that should fill the entire display? Maybe your desktop looks smaller than usual, your external monitor has unused space around the edges, or your TV shows a shrunken computer image surrounded by black bars. In some cases, the problem only appears when you launch a game or watch a video.
The good news is that a black border doesn't automatically mean your monitor is damaged. More often than not, the cause is a resolution mismatch, an incorrect scaling setting, a TV overscan configuration, or an aspect ratio difference between your screen and the content you're viewing.
The right fix depends on where the black border appears and when it started. A border around your entire Windows desktop requires a different approach from black bars inside a movie. Similarly, if you're a developer dealing with a Java Swing window that extends beyond the visible desktop, the problem may have nothing to do with your monitor's display settings.
In this guide, we'll explain what causes black borders, how to troubleshoot them on Windows and Mac, how to fix black edges on a TV connected to a computer, and how to diagnose a specific Java window-sizing issue. By following the steps in order, you can narrow down the cause without changing settings that are already working correctly.
What Causes a Black Border Around a Monitor or TV Screen?
Before changing any settings, take a moment to identify where the border appears. Does it surround the entire desktop, appear only in a video, or show up when a particular application opens? This simple distinction can save you a lot of unnecessary troubleshooting.
A black border around a display can have several causes, and not all of them indicate a problem.
1. Incorrect Screen Resolution
Every monitor has a native resolution: the physical pixel grid its panel is designed to display. For example, a Full HD monitor typically has a native resolution of 1920 × 1080, while a 4K monitor typically uses 3840 × 2160.
When your computer outputs a resolution that doesn't match the display's native resolution, the monitor or graphics system may scale the image to fit. Depending on the scaling method and device settings, the picture may not fill the entire screen.
For instance, imagine connecting a 1920 × 1080 monitor to a PC that's outputting a lower-resolution image. If the image is displayed at its original size rather than scaled to fill the panel, unused space may appear around it. Some monitors stretch lower-resolution content across the screen, while others offer several scaling modes.
The same issue can occur after updating a graphics driver, connecting a new display, switching between display modes, or changing a game's resolution. A setting that worked with your previous monitor may not be appropriate for your current one.
What to look for: If the entire desktop appears smaller than the physical display, check the output resolution first. If the border appeared immediately after changing resolution or connecting a new monitor, resolution mismatch is a strong place to start.
2. GPU Scaling and Display Scaling
Resolution determines how many pixels your computer outputs. Scaling determines how that image or interface is sized for the available display.
These concepts are related, but they aren't interchangeable.
GPU scaling is handled by your graphics processing unit. Depending on your hardware and driver, it may stretch an image to fill the display, preserve its aspect ratio, or display it without scaling. The available options vary by graphics card, driver version, and connection type.
Display scaling in Windows or macOS is primarily concerned with the size of interface elements, such as text, icons, menus, and application windows. It helps make the desktop readable on displays with different pixel densities.
This distinction matters because changing the desktop scaling percentage won't necessarily remove a black border around the image. For example, increasing Windows scaling from 100% to 125% generally makes interface elements larger; it doesn't directly correct a GPU output that isn't filling the panel.
If your desktop resolution is correct but the picture still doesn't reach the edges, check the graphics driver's scaling options and your monitor's own display settings.
Look for options such as:
- Full-screen or Full Panel: Stretches the image to fill the display, potentially changing its proportions.
- Maintain Aspect Ratio: Preserves the original proportions, which may leave unused space around the image.
- Center Image or No Scaling: Displays the image without stretching it to fill the entire panel.
These labels are examples, not universal options. Your graphics driver may use different wording or provide only some of them.
3. TV Overscan and Underscan Settings
If you're using a TV as a computer display, overscan is one of the first settings worth checking.
Overscan is a display behavior that enlarges an image beyond the visible edges of the screen. It originated in television broadcasting, where extending the picture slightly beyond the screen edges helped hide unwanted artifacts around the image.
Modern TVs may still apply overscan or other picture-sizing adjustments to certain inputs. When overscan is enabled, the edges of the computer desktop may be cropped. This can make the taskbar, menu bar, or application controls appear cut off.
Underscan describes the opposite situation in which the displayed image occupies less than the available screen area, leaving a border around it. This can happen when the computer's output scaling and the TV's picture-size settings don't match.
The exact controls depend on the TV manufacturer and model. Look for picture-size options such as Screen Fit, Just Scan, 1:1, Full Pixel, or similar settings. Some TVs also let you assign a PC label to an HDMI input, which can change how the signal is processed.
Don't assume that every black border on a TV is caused by overscan. If the entire desktop is smaller than the panel, underscan or a mismatched scaling mode may be more relevant. If the edges of the desktop are missing, overscan is a more likely explanation.
4. Aspect Ratio Mismatch
The aspect ratio describes the relationship between an image's width and height.
A typical widescreen computer monitor uses a 16:9 aspect ratio. However, movies, older games, retro content, and some specialized displays use different proportions.
When content doesn't match the screen's aspect ratio, black bars may appear because the player or display is preserving the original image rather than stretching it.
For example, a movie with a wider cinematic aspect ratio may have horizontal black bars above and below the picture on a 16:9 monitor. Older 4:3 video may appear with vertical black bars on the sides.
In these situations, the black bars are often intentional. They allow the entire image to remain visible without distorting faces, objects, or other visual details.
Stretching the picture to remove every black bar can introduce distortion. Cropping or zooming may also remove important content near the edges.
Before changing your monitor settings, check whether the border surrounds the entire desktop or only the content inside a video player or application. If only one movie has black bars, the display itself may be working exactly as intended.
5. Monitor or Cable Configuration
The connection between your computer and monitor can also affect the available display modes.
HDMI, DisplayPort, and USB-C can support different resolutions and refresh rates depending on the devices, cable specifications, adapters, and connection path. A docking station or adapter may also affect which display modes are available.
If a black border appears after switching cables, changing ports, connecting a USB-C monitor, or adding a dock, check the entire connection chain rather than assuming the monitor has failed.
Start by confirming that:
- The monitor is using the correct input source.
- The computer recognizes the intended display.
- The output resolution matches a supported mode.
- Any adapter or dock supports the required resolution and refresh rate.
- The monitor's aspect ratio and picture-size settings are appropriate.
A cable issue doesn't automatically cause black borders. However, if changing the connection also changes the available resolution or display mode, the connection path deserves attention.
How to Fix a Black Border Around Your Screen in Windows
If you're using a Windows PC, work through the following steps in order. Start with the basic display settings before moving on to graphics drivers, monitor controls, or hardware troubleshooting.
This approach helps you identify the actual cause instead of changing several settings at once and losing track of what fixed the problem.
1. Set the Recommended Display Resolution
The first step is to make sure Windows is sending the display an appropriate resolution.
Here's how to check:
- Right-click an empty area of your desktop.
- Select Display settings.
- Choose the monitor you're troubleshooting if multiple displays are connected.
- Find the Display resolution setting.
- Select the resolution marked Recommended, when available.
- Confirm the change and check whether the desktop fills the screen.

For a typical Full HD monitor, the recommended resolution is often 1920 × 1080. A 2560 × 1440 monitor will generally use 2560 × 1440, while a 4K display will generally use 3840 × 2160. Always follow the supported mode for your specific display rather than relying on these examples alone.
If the recommended resolution is unavailable, check whether Windows has identified the monitor correctly. You may need to inspect the graphics driver, docking station, adapter, or connection cable.
Also, don't confuse resolution with refresh rate. Resolution controls the number of pixels in the image, while refresh rate controls how frequently the display updates. Both matter for overall display compatibility, but changing refresh rate alone usually won't remove a border caused by incorrect scaling.
Why this works: When Windows outputs the display's appropriate native resolution, the monitor can map the image to its pixel grid more predictably, reducing the chance of unwanted borders caused by a mismatched display mode.
2. Check Display Scaling
If the resolution is correct but the desktop looks unusually large or small, review the scaling setting.
In Windows:
- Open Settings.
- Go to System > Display.
- Select the display you want to adjust.
- Find the Scale option.
- Try the recommended percentage if you've changed it previously.

Depending on your monitor and Windows version, you may see values such as 100%, 125%, 150%, or other supported percentages.
Display scaling primarily changes the size of text, icons, and interface elements. It generally doesn't control whether the actual video signal fills the physical panel. If your desktop already reaches all four edges but the icons look too small, scaling may be the right setting to adjust. If the entire desktop is surrounded by black space, continue checking resolution and GPU scaling.
After making a change, give Windows a moment to update the interface. Some applications may need to be restarted before their content looks correct.
Important: Avoid repeatedly changing both resolution and scaling at the same time. Adjust one setting, observe the result, and then decide whether another change is necessary.
3. Adjust GPU Scaling Settings
If Windows is already using the recommended resolution and the black border remains, check your graphics driver's scaling configuration.
The steps depend on whether your computer uses NVIDIA, AMD, Intel, or another graphics solution. Laptop users may also have a hybrid graphics system in which the integrated GPU and discrete GPU handle different parts of the display pipeline.
Open the relevant graphics control application, if available, and look for display scaling options.
You may find choices similar to these:
- Full-screen scaling: Expands the image to fill the display.
- Aspect-ratio scaling: Preserves the proportions of the source image.
- No scaling: Keeps the image at its original size, which may leave empty space around it.
-
Display-managed scaling: Uses the monitor's own scaling behavior, where supported.
The exact names and locations vary by driver version, so don't worry if your control panel looks different from another user's screenshots.
If you're seeing black borders around an older game or a lower-resolution application, changing the scaling mode may help. However, if the problem affects the entire desktop, first verify that the correct display and output resolution are selected.
Also consider whether the issue began after a graphics driver update. A reset or change in driver settings may explain why a previously full-screen image now appears smaller.
4. Check Your Monitor's Aspect Ratio Settings
Your monitor has its own settings menu, often called the on-screen display (OSD). It can control features that aren't available in Windows.
Use the monitor's physical buttons or joystick to open the OSD menu. Look for options such as:
- Aspect Ratio
- Image Size
- Display Mode
- Auto Adjustment
- Wide
- Full
- Original
- 1:1
The available options depend on the monitor model and input signal.
If the monitor is set to a 1:1 or original-size mode, a lower-resolution image may occupy only part of the panel. Switching to a full-screen mode may make the image fill the display, although the result can look stretched if the source and panel have different aspect ratios.
Some monitors offer an automatic adjustment function for certain analog inputs. That feature may be useful for older VGA connections, but it generally isn't necessary for modern digital connections operating at their correct native resolution.
If you're using a portable monitor, also check whether the OSD includes image scaling or aspect ratio controls. The available functions can differ from those found on larger desktop monitors.
Make one change at a time, then return to the desktop and check the edges of the image. If you can't find a relevant option, consult the manual for your exact model rather than experimenting with unrelated picture settings.
5. Test Another Cable or Port
If the settings look correct but the border remains, test the connection.
A simple way to narrow down the problem is to change one part of the connection at a time.
For example:
- Disconnect and reconnect the cable securely.
- Try another compatible port on the computer or monitor.
- If possible, test a different cable that supports the required resolution and refresh rate.
- Temporarily bypass a docking station or adapter.
- Connect the monitor to another computer, if one is available.
Observe what changes after each test.
If the border disappears when you bypass a dock, investigate the dock's supported display modes and firmware. If the problem follows the monitor to another computer, its own configuration becomes a stronger suspect. If the same computer produces a border on multiple displays, the computer's output settings or graphics configuration deserve closer attention.
A USB-C connection deserves particular care because USB-C describes the connector shape, not a guarantee that every port supports the same display capabilities. Depending on the computer and monitor, video may rely on DisplayPort Alt Mode, Thunderbolt, USB4, or another supported implementation.
If the monitor shows no image at all rather than a picture with black borders, that's a different troubleshooting path. You can use our monitor no-signal troubleshooting guide to diagnose a missing video signal.
How to Remove Black Borders on a Mac
Mac users can encounter similar display issues when connecting an external monitor, using a TV as a display, or switching between different screen resolutions.
The main difference is that macOS presents its display configuration differently from Windows. Start with the available resolution and scaling options, then check the monitor itself.
1. Check the Display Resolution
Open Apple menu > System Settings > Displays.
Select the external display you're troubleshooting. Depending on the version of macOS and the display, you'll see resolution or scaling options that control how content is rendered on the screen.
Choose a supported setting appropriate for the monitor. If your Mac is outputting an unexpected resolution, changing to a recommended or native-resolution mode may resolve a border around the desktop.
Some displays expose a list of specific resolutions, while others use scaled interface options. The available controls depend on the Mac, macOS version, connection type, and monitor.
If you use more than one external display, confirm that you're adjusting the correct one. A resolution change on the laptop's built-in screen won't necessarily affect the external monitor.
After changing the setting, check all four edges of the desktop. If the picture now fills the panel but the text looks too large or too small, revisit the available scaling choices.
2. Review Available Display Scaling Options
macOS may offer options that prioritize a larger desktop workspace or larger interface elements, depending on the display.
These options affect the relationship between interface size and the available desktop space. They aren't necessarily equivalent to GPU scaling modes that stretch a video signal to fill a panel.
If the border surrounds the entire desktop, check whether the display is using the expected resolution and whether your connection exposes the monitor's full range of display modes.
If the desktop already fills the screen but the text and icons seem too small, a different scaling choice may improve readability without changing the physical screen coverage.
For high-resolution displays, the best option isn't always the one with the largest number shown in the interface. Choose the mode that produces the expected desktop layout and a comfortable viewing experience.
3. Check the Monitor's Own Settings
If macOS appears to be outputting the correct display mode, open your monitor's OSD menu.
Look for aspect ratio, image size, or scaling settings. If the monitor is connected to a TV, check the TV's picture-size configuration as well.
This is especially useful when the same Mac looks normal on its built-in screen but has black borders on an external display. The external monitor may be applying its own scaling behavior.
If you change a setting, check the result before adjusting anything else. You don't want to introduce stretched images or cropped content while trying to remove an unnecessary border.
4. Reconnect the External Display
If the display settings appear correct but the problem persists, reconnect the monitor.
- Disconnect the external display.
- Check the cable and adapter for loose connections.
- Reconnect the display directly to the Mac when practical.
- Reopen System Settings > Displays and review the available modes.
- If possible, test another compatible cable or port.
If you're using a hub or dock, temporarily bypass it to see whether the available display modes change. This can help isolate an issue with the connection path.
For USB-C monitors, confirm that the Mac's port, cable, adapter, and monitor support the intended video mode. A connector that physically fits doesn't necessarily support every resolution or refresh rate.
If the display works correctly when connected directly but not through a dock, focus on the dock's capabilities and configuration before changing unrelated macOS settings.
How to Fix Black Borders on a TV Connected to a Computer
Using a TV as a computer monitor can be convenient for presentations, streaming, gaming, or working with a large desktop. However, TVs often include picture-processing features that aren't designed specifically for computer interfaces.
If your desktop appears cropped or surrounded by black space, check the TV and computer together. Changing only one side may not solve the problem if both devices are applying incompatible scaling settings.
1. Check Overscan and Underscan
Start with the TV's picture-size settings.
Look for options with names such as Screen Fit, Just Scan, 1:1, Full Pixel, or similar wording. These settings may disable overscan or display the input image more directly, depending on the model.
If your TV has a PC mode or lets you label an HDMI input as a computer connection, check whether using that mode changes the image. Some TVs apply different processing to PC inputs, which can improve how text and desktop edges appear.
The correct setting depends on the symptom:
- If the edges of the desktop are cut off, investigate overscan.
- If the whole desktop appears smaller than the screen, investigate underscan or scaling.
- If black bars appear only in a movie, check the movie's aspect ratio before changing the TV.
After adjusting the setting, look at the taskbar, desktop icons, and window edges. The goal is to display the complete computer image without unwanted cropping or distortion.
2. Select the Correct Picture Size
TV manufacturers don't use one universal naming system for picture-size controls. One model may offer a PC-friendly 1:1 option, while another may use a different name or automatically adjust the image.
Open the TV's picture menu and review the available screen-size settings. If a particular mode fills the screen but makes circles look oval or text look stretched, it may be forcing the wrong aspect ratio.
A mode that preserves the original proportions may be preferable to one that fills every pixel by stretching the image.
If you're using the TV for work, prioritize correct proportions and clear text rather than simply eliminating every black area. Some black bars are part of the content itself, and removing them by zooming or stretching can reduce image quality.
3. Match the PC Output to the TV
Next, verify the computer's output resolution.
For a typical 4K TV used as a computer display, the expected mode is often 3840 × 2160, provided both the TV input and the entire connection path support it.
For a Full HD TV, 1920 × 1080 is a common native resolution. Older TVs and certain connection modes may support different combinations, so check the specifications for your device.
On Windows, open Settings > System > Display and select the appropriate display resolution. On a Mac, open System Settings > Displays and review the available modes.
If the correct mode isn't listed, check the HDMI port you're using, the cable, the adapter or dock, and the graphics driver's available output modes.
Also verify that the TV's HDMI input supports the desired resolution and refresh rate. Some TVs provide different capabilities on different ports or require a setting to enable a higher-bandwidth HDMI mode.
4. Adjust GPU Scaling
If the TV is using the appropriate resolution but the image still doesn't fill the panel, check the graphics driver's scaling settings.
Depending on your hardware, you may be able to choose between full-screen scaling, aspect-ratio preservation, and other output modes.
Try the option that matches your goal while preserving image proportions. If the TV already has a picture-size setting that correctly maps the computer's pixels to the panel, avoid applying an additional scaling adjustment without a clear reason.
If you use a desktop PC with a dedicated graphics card, check the relevant GPU control panel. If you're using a laptop, the display may be managed by integrated graphics or a hybrid graphics configuration, so the available settings may be different.
After each adjustment, verify that the full desktop is visible and that text remains sharp. If the issue occurs only on one HDMI input, test another supported input before changing more settings.
Black Borders Around Videos or Games: Is It Normal?
Not every black border is a display fault. Sometimes, the border is a normal result of the content's aspect ratio or the application's display mode.
Before changing the entire system configuration, determine whether the issue affects all content or only one video, game, or application.
1. Black Bars Caused by Video Aspect Ratio
Movies and videos aren't all recorded in the same aspect ratio.
A widescreen monitor may have a 16:9 shape, while some films use a wider cinematic frame. When the video player preserves the original proportions, horizontal black bars can appear above and below the picture.
Older 4:3 footage may show vertical black bars on a widescreen display. In both cases, the black space allows the complete image to remain visible without stretching it.
If the video itself looks correctly proportioned, these bars are usually nothing to worry about.
You can sometimes zoom or crop the video to fill more of the screen, but doing so may cut off parts of the picture. Stretching the image can distort faces and objects.
A useful test: Pause the video and look at the desktop or other windows. If those elements fill the monitor normally, your display settings probably aren't the source of the black bars.
2. Black Borders in Full-Screen Games
Games often let you select a resolution, aspect ratio, display mode, and sometimes a rendering scale. If these settings don't match your monitor, black borders may appear even when the Windows desktop looks normal.
Open the game's video or graphics settings and check:
- The selected display resolution.
- The chosen display or aspect ratio mode.
- Whether the game is running in fullscreen, borderless fullscreen, or windowed mode.
- Whether the game has a separate render-scale setting.
- Whether the graphics driver applies a custom scaling mode.
For example, a game running at a 16:9 resolution on a wider monitor may show vertical black bars if it preserves the original aspect ratio. That may be intentional rather than a malfunction.
Some older games don't support a monitor's native resolution. In that case, the game's available display modes and the graphics driver's scaling options may determine how the image is presented.
Change one setting at a time and test the result. If the problem appears only after switching to a particular resolution or refresh rate, return to a supported mode before troubleshooting the hardware.
3. Black Borders Only in One App
If black borders appear in only one application, start with that application's settings.
Video players may have zoom, fit-to-window, or aspect-ratio controls. Games may have independent resolution settings. Remote desktop tools, virtual machines, and presentation applications may also render content within a fixed-size workspace.
Changing the system-wide resolution may not fix an application-specific issue. It can also make the rest of your desktop less comfortable to use.
Try maximizing the application, checking its display preferences, and restarting it after changing a relevant setting.
If the same application displays correctly on another monitor or computer, compare its resolution and scaling configuration before assuming there's a hardware fault.
The key principle is simple: if only one application has black borders, troubleshoot that application first.
Java Swing JFrame Borders Go Slightly Off Screen: How to Fix It
The phrase maximize jframe borders go slightly off screen describes a different type of problem from a black border surrounding a monitor's desktop.
In Java Swing applications, a JFrame may appear to extend beyond the visible desktop after being maximized or manually resized. Its borders may be clipped, its dimensions may be slightly larger than expected, or its content may not align with the available screen area.
This issue is generally related to window geometry, native window decorations, display coordinates, or the way the application calculates its size. Changing a monitor's aspect ratio or GPU scaling mode is unlikely to solve an application-level window-sizing problem.
1. Why a Maximized JFrame Can Extend Beyond the Screen
A maximized Java window interacts with the operating system's window manager. The final visible bounds can depend on the screen configuration, native window decorations, and the platform's window-management behavior.
Several factors are worth checking.
Window Insets
A decorated window usually has a title bar and borders. Java exposes the dimensions of these decorations through the Insets object. These values can help explain the difference between a window's outer dimensions and its content area.
However, Insets aren't automatically the cause of every maximization problem. If your application manually adds border sizes to dimensions that already include them, the result may be an oversized window.
GraphicsConfiguration and Screen Bounds
Java's GraphicsConfiguration provides information about the graphics environment associated with a screen or display device. Applications that manually position windows should account for the screen's coordinate system and usable bounds.
This becomes especially important when multiple monitors are connected. A display may have negative coordinates relative to the primary monitor, and each screen may have a different resolution or scaling configuration.
Usable Screen Area
The full screen bounds aren't always identical to the area available for an ordinary application window. Operating-system elements such as the Windows taskbar or macOS Dock may reduce the usable area.
If you manually size a window to the full display dimensions without accounting for the available area or relying on normal maximization behavior, part of the window may end up outside the expected region.
Custom Window Decorations
Applications that use custom title bars, undecorated windows, or nonstandard frame layouts may behave differently from ordinary decorated JFrame windows. These designs require particular care when calculating dimensions and positioning controls.
The best first step is to determine whether the issue occurs with a standard Swing frame or only with your application's custom window implementation.
2. Use JFrame.MAXIMIZED_BOTH Correctly
When the goal is to maximize a standard Swing window, let the window manager handle the maximization instead of calculating the full screen dimensions manually.
Here's a basic example:
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Display Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setExtendedState(
frame.getExtendedState() | JFrame.MAXIMIZED_BOTH
);
frame.setVisible(true);
});
}
}
This example creates a standard Swing window, assigns an initial size, centers it, and requests maximization.
The important part is:
frame.setExtendedState(
frame.getExtendedState() | JFrame.MAXIMIZED_BOTH
);
JFrame.MAXIMIZED_BOTH requests maximization in both dimensions. For a normal decorated frame, the operating system generally determines the appropriate maximized bounds.
If you're already using this approach and the frame still extends beyond the visible area, inspect the rest of the code for manual calls to setBounds(), setSize(), or setLocation() that run after maximization.
Also, test the behavior on the operating systems and display configurations you support. Window decorations and display scaling can differ across environments.
3. Inspect JFrame Insets
If the window appears slightly larger than expected, inspect its actual decoration Insets after it becomes visible.
frame.setVisible(true);
java.awt.Insets insets = frame.getInsets();
System.out.println("Top: " + insets.top);
System.out.println("Left: " + insets.left);
System.out.println("Bottom: " + insets.bottom);
System.out.println("Right: " + insets.right);
The values represent the space occupied by the window's borders and title bar around its content area.
It's important to inspect them after the frame has been realized and its native decorations have been established. Before that point, the reported values may not reflect the final window decorations.
Don't automatically subtract or add these values to every window dimension. Insets are useful diagnostic information, but the correct calculation depends on whether the dimensions you're working with describe the outer window or its content area.
A common mistake is to calculate a desired window size, add the Insets, and then pass that result into an operation that already interprets the size as the outer frame dimensions. That can make the window larger than intended.
If the frame is normally maximized by the operating system, start by removing unnecessary manual size adjustments rather than trying to compensate for every pixel of decoration.
4. Check the Usable Screen Bounds
If your application needs to position or resize a window manually, inspect the screen bounds and the space available for ordinary windows.
The following example calculates the usable area for the default screen device:
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Insets;
import java.awt.Toolkit;
public class ScreenBoundsExample {
public static void main(String[] args) {
GraphicsConfiguration gc =
GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.getDefaultConfiguration();
Rectangle screenBounds = gc.getBounds();
Rectangle usableBounds = new Rectangle(screenBounds);
Insets screenInsets =
Toolkit.getDefaultToolkit().getScreenInsets(gc);
usableBounds.x += screenInsets.left;
usableBounds.y += screenInsets.top;
usableBounds.width -=
screenInsets.left + screenInsets.right;
usableBounds.height -=
screenInsets.top + screenInsets.bottom;
System.out.println("Screen: " + screenBounds);
System.out.println("Usable: " + usableBounds);
}
}
The code starts with the selected screen's bounds and adjusts the rectangle using the screen Insets reported by the toolkit.
The result can help when your application must calculate a window's position or dimensions within the usable area.
There are two important limitations.
First, this example uses the default screen device. In a multi-monitor setup, you should select the GraphicsConfiguration associated with the display where the window will actually appear.
Second, screen bounds and usable bounds are not necessarily the same thing. The former describes the configured screen area; the latter accounts for screen Insets reported by the platform.
When working with multiple displays, don't assume that every monitor starts at coordinate (0, 0). A secondary monitor positioned to the left of the primary display may have negative X coordinates. Different monitors may also use different resolutions or scaling settings.
If the problem occurs only on one monitor, log the bounds and usable bounds for that specific display before changing the window dimensions.
5. Avoid Double-Counting Window Borders
One of the most common mistakes in custom window-sizing code is counting the same dimensions twice.
Consider a window that needs to fit within a specific usable area. If the application already calculates the outer frame dimensions but then adds the title bar and border sizes again, the final window can exceed the intended width or height.
The reverse can also happen: code that assumes the requested size describes the outer frame when it actually describes a content area can result in a window that's too small.
To troubleshoot this, inspect every place where your code:
-
Calls
setSize(),setBounds(), orsetLocation(). -
Adds
Insetsvalues to width or height calculations. -
Uses
GraphicsConfiguration.getBounds(). - Calculates a window position from the primary monitor's dimensions.
-
Changes the frame state before or after calling
setVisible().
Then test the frame without unnecessary manual geometry adjustments.
For a standard maximized JFrame, the operating system's maximization behavior should usually be your starting point. Use manual screen calculations only when the application has a specific requirement that can't be handled by normal maximization.
If the window still exceeds the expected bounds, compare the reported geometry, Insets, and selected graphics configuration. This provides more useful evidence than repeatedly changing arbitrary width and height values.
How to Identify the Source of the Problem
If you're unsure which setting to check first, use the symptoms below to narrow down the likely cause.
| Symptom | What to Check First |
|---|---|
| Black border around the entire desktop | Display resolution and GPU scaling |
| TV picture has unused space around the edges | TV picture size, underscan, and output scaling |
| TV desktop edges are cut off | Overscan and picture-size settings |
| Black bars appear only in a movie | Video aspect ratio and player settings |
| Black borders appear in one game | Game resolution, aspect ratio, and display mode |
| Only one application has black borders | Application-specific display settings |
| Black borders appear after connecting a new monitor | Output resolution, monitor scaling, and connection path |
| Display options are missing after connecting through a dock | Cable, adapter, dock, and supported display modes |
Java JFrame extends beyond the visible desktop
|
Insets, usable screen bounds, and manual size calculations |
| Problem appears only on a secondary monitor | The selected display configuration and multi-monitor coordinates |
The goal isn't to change every setting listed in the table. Start with the item most closely related to your symptom, make one change, and check the result.
If the problem began after a specific event, such as a driver update, cable change, or new monitor installation, use that information to guide the next test.
Frequently Asked Questions
Why is there a black border around my screen?
A black border around your screen can be caused by an incorrect display resolution, GPU scaling, monitor picture-size settings, TV overscan or underscan, or a difference between the screen's aspect ratio and the displayed content.
If the border surrounds the entire desktop, start by checking the recommended resolution and the display's scaling configuration. If it appears only in a video or game, check the application's aspect ratio and display mode first.
How do I remove black borders from my monitor?
To remove black borders from your monitor, first select the recommended display resolution in your operating system. Then check your graphics driver's scaling mode and the monitor's aspect ratio settings.
If you're using a TV, look for overscan, underscan, or picture-size options. If the border appears only in a specific application, adjust that application's display settings rather than changing the entire system.
Keep in mind that some black bars are intentional. Forcing every image to fill the screen can stretch or crop content.
Why does my TV have black borders when connected to a PC?
A TV may display black borders when connected to a PC because of underscan, an incorrect picture-size setting, a resolution mismatch, or incompatible scaling behavior between the TV and computer.
Check the TV's picture-size menu first, then confirm that the PC is outputting a supported resolution. If the TV's edges are cropped instead of surrounded by black space, investigate overscan.
Is a black border around a screen always a problem?
No. Black borders can be a normal part of displaying content with a different aspect ratio from the screen.
For example, a cinematic movie may have horizontal black bars on a 16:9 monitor, while older 4:3 content may have vertical black bars. These bars help preserve the original image without stretching it.
If the desktop itself doesn't fill the panel, however, it's worth checking the resolution and scaling settings.
Why do JFrame borders go slightly off screen when maximized?
A Java Swing JFrame may extend beyond the expected screen area because of manual window-size calculations, incorrect handling of window Insets, an unsuitable GraphicsConfiguration, or assumptions about the usable screen area.
Start by using the standard JFrame.MAXIMIZED_BOTH maximization behavior and removing unnecessary manual sizing. If the issue persists, inspect the frame's Insets and the bounds of the specific display where the window appears.
Should I change my monitor's resolution or scaling settings?
It depends on the symptom.
If the desktop doesn't fill the screen, check the output resolution and GPU scaling first. If the desktop fills the panel but text and icons look too large or too small, review the operating system's display scaling options.
If only a video or game has black bars, check its aspect ratio and application settings before changing the system-wide display configuration.
Can a bad HDMI or USB-C cable cause black borders?
A cable doesn't automatically cause black borders, but the connection path can affect which resolutions and refresh rates are available. This is especially relevant when using adapters, docks, or USB-C connections with different video capabilities.
If the problem started after changing cables or ports, test a compatible alternative and verify that the computer and display are using the intended output mode.
Why does my external monitor have black borders when connected to a laptop?
An external monitor may show black borders because the laptop is outputting a different resolution, the monitor is using a non-full-screen scaling mode, or an adapter or dock is affecting the available display modes.
Check the external display's resolution independently of the laptop's built-in screen. Then review the monitor's OSD settings and test the connection directly if possible.
Final Thoughts
A black border around screen content can look like a hardware problem, but the cause is often much simpler. The key is to identify whether the border affects the entire desktop, a connected TV, a video, a game, or a particular application.
For most Windows and Mac users, the best starting points are the recommended display resolution, GPU scaling, and the monitor's own aspect ratio settings. TV users should also check overscan and picture-size controls. If the problem appears only in one application, troubleshoot that application before changing the whole display configuration.
For developers dealing with JFrame windows that extend beyond the visible desktop, focus on window geometry, Insets, and the correct screen configuration instead of monitor scaling.
Once you understand where the black border originates, you can make a targeted adjustment, preserve the correct image proportions, and avoid changing settings that aren't related to the problem.