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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:07:49+00:00 2026-06-15T05:07:49+00:00

I have Jpanel which is maximized on a button click. I do it by

  • 0

I have Jpanel which is maximized on a button click. I do it by setting the dimensions to the screensize and then calling setLocationRelativeTo(null). This works fine if i have the panel in primary monitor, but when the panel is on other monitor the button click always makes the panel to move to primary monitor. Is there a way to get the currently used monitor of the panel and use the same for new location. Thanks in advance.

  • 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-15T05:07:50+00:00Added an answer on June 15, 2026 at 5:07 am

    I have only one screen at home and will be back to my job monday, but the following code set the title of the JFrame to “\Display0” under Windows Seven 64 bits. I suppose this string is the ID of the Screen and the second Screen is named “\Display1”.

    • Component.getGraphicsConfiguration()
    • GraphicsConfiguration.getDevice()
    • GraphicsDevice.getIDstring()

    I suggest to run this application on multi-screen PC to evaluate it.

    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    
    public class Frm
       extends
          JFrame
       implements
          ActionListener
    {
       Frm()
       {
          setDefaultCloseOperation( EXIT_ON_CLOSE );
          setPreferredSize( new Dimension( 640, 480 ));
          setLayout( new BorderLayout());
          JButton getScreenBtn = new JButton( "Get Screen ID" );
          add( getScreenBtn, BorderLayout.CENTER );
          getScreenBtn.addActionListener( this );
          pack();
          setLocationRelativeTo( null );
          setVisible( true );
       }
    
       @Override
       public void actionPerformed( ActionEvent e ) {
          setTitle( getGraphicsConfiguration().getDevice().getIDstring());
       }
    
       public static void main( String[] args ) {
          SwingUtilities.invokeLater( new Runnable() {
             @Override public void run() { new Frm(); }});
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JPanel to which when a button is pressed I want to
Hi Experts: I have a class which extends JPanel now ShapePanel (Sp) this gets
I have a program which creates JButtons which are then added to a JPanel
I have a JPanel which has a line, circle, etc. Now when I click
I have a JPanel which has a background image. To this panel, I add
I have Form on which i am drawing oval on mouseClick Event. This works
I have a JPanel which uses a BoxLayout in the X_AXIS direction. The problem
I have a JPanel which contains some fields. The height of the JPanel is
I have a JPanel (A) which contains another JPanel (B). Each panel implements a
I have below snippet of code in which TestClass is extending jPanel which is

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.