-1

I am working with Java Swing Application. I have used JFrame for Notification window. When my application is running at random interval some notification will be display on right top of screen but when notification window displayed at that time I am seeing that notification detail with title named on my task bar. I want to prevent to display this information on task bar. Any one help me. I have also tried with JWindow but same issue present. I don't want to use as System Try on task bar

enter image description here

Piyush Chaudhari
  • 962
  • 3
  • 19
  • 41

2 Answers2

3

Try setType(Type.UTILITY);

The drawback is for decorated JFrames it only gives close button. Works better for undecorated JFrames

Rahul
  • 289
  • 2
  • 7
  • This works better than using a JDialog for undecorated frames - the frames are hidden from the alt-tab view, don't cause problems with context menus of system tray icons (yes, dialogs do that), and don't try to get to the front (even with `setAutoRequestFocus(false)` set on the dialogs). – Njol Oct 28 '17 at 09:13
1

You should use JDialog instead of JFrame or JWindow. May the following example help you:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
import javax.swing.Timer;

public class Main {
    public static void main(String[] args) {
        final JDialog dlg = new JDialog();
        dlg.setBounds(100, 100, 200, 100);
        dlg.setUndecorated(true);
        dlg.setVisible(!dlg.isVisible());

        Timer showTimer = new Timer(3000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                dlg.setVisible(!dlg.isVisible());
            }
        });
        showTimer.start();
    }
}

[UPDATE] Actually JDialog is for providing a frame as a child for another JFrame or JWindow, so it should not creating any info in taskbar or system tray by default.

The above code provides the below output on screen and there is no iconified info on taskbar or any think in system tray as you can see:

enter image description here

Good Luck.

STaefi
  • 4,297
  • 1
  • 25
  • 43
  • Thanks for good option but still this dialog is visible on task bar when JDialog is visible. Is it possible that JDialog display on screen but no information of that JDialog visible on taskbar? – Piyush Chaudhari Aug 06 '15 at 07:55
  • @Piyush: yes it is possible. It works on my system. Do you use any custom L&F for your application? I would provide a screenshot shows the dialog would not show any information on taskbar. Did you run my code or you just changed your JFrame or JWindow to JDialog? – STaefi Aug 06 '15 at 08:37
  • I have executed your code then after I reply you. I am not using custom L&F. I am run your code on Linux Mint OS. If you don't mind then will you share your screenshot? – Piyush Chaudhari Aug 06 '15 at 08:41
  • Actually I'm running win7 on my machine, but there should not be a difference. It is wired by the way. Painting Graphical windows or frames highly depends on the OS. Maybe Mint OS is not following the same way to showing frames, maybe for security purposes. – STaefi Aug 06 '15 at 08:54