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 7779615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:41:00+00:00 2026-06-01T18:41:00+00:00

I would like to get the effective screen size. That is: the size of

  • 0

I would like to get the effective screen size. That is: the size of the screen without the taskbar (or the equivalent on Linux/Mac).

I am currently using…

component.getGraphicsConfiguration().getBounds()

…and subtracting the default taskbar size depending on the OS, but I would like a way that works even if the user has resized/moved the taskbar.

  • 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-01T18:41:03+00:00Added an answer on June 1, 2026 at 6:41 pm

    This could determine the screen size in pixels without the taskbar

    //size of the screen
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    
    //height of the task bar
    Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
    int taskBarSize = scnMax.bottom;
    
    //available size of the screen 
    setLocation(screenSize.width - getWidth(), screenSize.height - taskBarSize - getHeight());
    

    EDIT

    Can someone please run this code on Xx_nix and Mac OSX and check if JDialog is really placed in the bottom right corner?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.UIManager.LookAndFeelInfo;
    
    public class NotificationPopup {
    
        private static final long serialVersionUID = 1L;
        private LinearGradientPaint lpg;
        private JDialog dialog = new JDialog();
        private BackgroundPanel panel = new BackgroundPanel();
    
        public NotificationPopup() {
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Insets scnMax = Toolkit.getDefaultToolkit().
                    getScreenInsets(dialog.getGraphicsConfiguration());
            int taskBarSize = scnMax.bottom;
            panel.setLayout(new GridBagLayout());
            GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 0;
            constraints.weightx = 1.0f;
            constraints.weighty = 1.0f;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.BOTH;
            JLabel l = new JLabel("You have got 2 new Messages.");
            panel.add(l, constraints);
            constraints.gridx++;
            constraints.weightx = 0f;
            constraints.weighty = 0f;
            constraints.fill = GridBagConstraints.NONE;
            constraints.anchor = GridBagConstraints.NORTH;
            JButton b = new JButton(new AbstractAction("x") {
    
                private static final long serialVersionUID = 1L;
    
                @Override
                public void actionPerformed(final ActionEvent e) {
                    dialog.dispose();
                }
            });
            b.setOpaque(false);
            b.setMargin(new Insets(1, 4, 1, 4));
            b.setFocusable(false);
            panel.add(b, constraints);
            dialog.setUndecorated(true);
            dialog.setSize(300, 100);
            dialog.setLocation(screenSize.width - dialog.getWidth(),
                    screenSize.height - taskBarSize - dialog.getHeight());
            lpg = new LinearGradientPaint(0, 0, 0, dialog.getHeight() / 2,
                    new float[]{0f, 0.3f, 1f}, new Color[]{new Color(0.8f, 0.8f, 1f),
                        new Color(0.7f, 0.7f, 1f), new Color(0.6f, 0.6f, 1f)});
            dialog.setContentPane(panel);
            dialog.setVisible(true);
        }
    
        private class BackgroundPanel extends JPanel {
    
            private static final long serialVersionUID = 1L;
    
            BackgroundPanel() {
                setOpaque(true);
            }
    
            @Override
            protected void paintComponent(final Graphics g) {
                final Graphics2D g2d = (Graphics2D) g;
                g2d.setPaint(lpg);
                g2d.fillRect(1, 1, getWidth() - 2, getHeight() - 2);
                g2d.setColor(Color.BLACK);
                g2d.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
            }
        }
    
        public static void main(final String[] args) {
            try {
                for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                    System.out.println(info.getName());
                    if ("Nimbus".equals(info.getName())) {
                        UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (UnsupportedLookAndFeelException e) {
            } catch (ClassNotFoundException e) {
            } catch (InstantiationException e) {
            } catch (IllegalAccessException e) {
            }
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
    
                    NotificationPopup notificationPopup = new NotificationPopup();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get some information on list of points that needs to
I would like to get the dimensions (coordinates) for all the HTML elements of
I would like to get the most out of working in cch or tcsh
I would like to get a reference to all objects in the Java heap,
I would like to get contents of some stream or project I can find
I would like to get the AssemblyCompany attribute from a WinForm project inside of
I would like to get the final SQL query, with parameter values bound (replaced)
I would like to get the XAML source of a WPF Window (MainWindow). Clicking
I would like to get the first item from a list matching a condition.
I would like to get some feedback on what is one of my first

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.