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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:53:27+00:00 2026-06-17T23:53:27+00:00

I have a swing program which creates a fullscreen borderless window — I am

  • 0

I have a swing program which creates a fullscreen borderless window — I am running on Windows 7. I need the program to be able to focus and bring itself to the front. However, when I attempt to use the method found here, How to bring a window to the front?, instead of bringing the window to the front the window just flashes in the taskbar and does not accept input. Below I wrote a small program that demonstrates the issue:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;


public class WindowTest extends JFrame{

WindowTest(){
    setTitle("Window Test");
    setSize(600, 600);
    setLocationRelativeTo(null);
    setUndecorated(true);
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
}

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            final WindowTest wt = new WindowTest();
            wt.setVisible(true);

            Timer t = new Timer(3000,new ActionListener(){
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    java.awt.EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            wt.toFront();
                            wt.repaint();
                        }
                    });             
                }   
            });

            t.setRepeats(false);
            t.start();

            wt.addKeyListener(new KeyListener(){
                @Override
                public void keyPressed(KeyEvent arg0) {
                    if(arg0.getKeyCode() == KeyEvent.VK_ESCAPE){
                        wt.dispose();
                        System.exit(0);
                        return;
                    }
                }

                @Override
                public void keyReleased(KeyEvent arg0) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void keyTyped(KeyEvent arg0) {
                    // TODO Auto-generated method stub

                }   
            });
        }
    });

}

 }

This will create a borderless, maximized window, and then three seconds later will attempt to bring it to the front. If you change to another window before that, the taskbar button will flash but the window will not be brought to the front.

  • 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-17T23:53:28+00:00Added an answer on June 17, 2026 at 11:53 pm
    • toFront(quite common issue) doesn’t works for JFrame, this is basic property for JDialog

    • basically is possible to move toFront() only one JFrame, have to use setExtendedState, but with side effects flickering and jumping on the scren, use JDialog instead

    • don’t use KeyListener, because JFrame isn’t focusable for KeyEvent, have to use KeyBindings

    for example

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.Timer;
    
    public class WindowTest extends JFrame {
    
        private static final long serialVersionUID = 1L;
        private JFrame frame = new JFrame();
    
        public WindowTest() {
            frame.setTitle("Window Test");
            frame.setSize(600, 600);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
            frame.setVisible(true);
            frame.setExtendedState(JFrame.ICONIFIED);
            Timer t = new Timer(3000, new ActionListener() {
    
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    java.awt.EventQueue.invokeLater(new Runnable() {
    
                        @Override
                        public void run() {
                            frame.setExtendedState(JFrame.NORMAL);
                        }
                    });
                }
            });
            t.setRepeats(false);
            t.start();
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
    
                public void run() {
                    final WindowTest wt = new WindowTest();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main program, in which GUI is based on swing and depending
I have a program which consists of two simple Java Swing files. How do
I have a swing application when i run it on windows i have no
I have a Swing runnable app which updates messages, then I have a Java
I have developed a Java Swing application, which uses the SwingWorker class to perform
I had just coded a Swing program that starts up a SwingWorker (which runs
There is an open source desktop program which is written in Java (Swing) and
This is my code I have developed. This is the main program which holds
I have a program with a GUI that needs to open a separate window
I have a SWING UI that contains a button that creates a new SwingWorker

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.