JDialog to appear in Windows Taskbar

Discussion in 'Java' started by RVince, Aug 21, 2007.

  1. RVince

    RVince Guest

    I have an application whose only gui is to invoke a JDialog and
    display it. On Windows machines, I need to have an the usual taskbar
    button, typically at the bottom of the screen on Windows systems,
    appear. It seems that simply invoking a modal JDialog wont put
    anything into the Windows taskbar, and thus if a user puts another
    Window in front of this JDialog -- they can even forget it's there!.

    Does anyone know of a workaround to this? Thanks, R.Vince
    RVince, Aug 21, 2007
    #1
    1. Advertising

  2. RVince wrote:
    > I have an application whose only gui is to invoke a JDialog and
    > display it. On Windows machines, I need to have an the usual taskbar
    > button, typically at the bottom of the screen on Windows systems,
    > appear. It seems that simply invoking a modal JDialog wont put
    > anything into the Windows taskbar, and thus if a user puts another
    > Window in front of this JDialog -- they can even forget it's there!.
    >
    > Does anyone know of a workaround to this? Thanks, R.Vince
    >


    As of 1.6 that is easy to do. Create a JDialog with the
    DialogModalityType of TOOLKIT_MODAL.

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    public class test8 {
    public static void main(String[] args) {
    Runnable r = new Runnable() {
    public void run() {
    JDialog d = new JDialog(
    (Frame)null,Dialog.ModalityType.TOOLKIT_MODAL);
    d.setTitle("title");
    d.setSize(300,200);
    d.setVisible(true);
    System.exit(0);
    }
    };
    EventQueue.invokeLater(r);
    }
    }

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Aug 21, 2007
    #2
    1. Advertising

  3. RVince

    RVince Guest

    Thanks Knute,

    Unfortunately I have to be 1.4.2 compatible here. -R. Vince
    RVince, Aug 21, 2007
    #3
  4. RVince wrote:
    > Thanks Knute,
    >
    > Unfortunately I have to be 1.4.2 compatible here. -R. Vince
    >


    Why would you want to use a compiler that in a very few months will be
    obsolete?

    Use a Frame/JFrame instead of a dialog.

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Aug 21, 2007
    #4
  5. RVince

    vishnudhoodhan

    Joined:
    May 3, 2012
    Messages:
    3
    showing taskbar button while JDialog opened

    hi, i am new to this forum. so hope you all will forgive my mistakes if any....
    Thank you in advance.

    This is a answer for Rvince's question.
    it is simple process though.

    Just now before posting this reply I found the way. I was too searching internet for this answer. after all i found it my self.

    i am doing an application for my personal use. it came up with the same issue when opening a dialog box, it hided the jframe. so i did a little bit of change to the code. and found workin better enough

    this is the code which found erronic.
    ------------------------------------------------------

    Code:
    this.setVisible(false);
            
    frmcompiler = new frmCompiler(this,true);
    frmcompiler.setLocationByPlatform(true);
    frmcompiler.setLocationRelativeTo(this);
    frmcompiler.setVisible(true);
    
    this.setVisible(true);
    the statement
    Code:
    this.setVisible(true/false);
    made it worst
    it hided the jframe and the taskbar button vanished. so i made a little bit of change like the following
    Code:
    //this.setVisible(false);    
        
    frmcompiler = new frmCompiler(this,true);
    frmcompiler.setLocationByPlatform(true);
    frmcompiler.setLocationRelativeTo(this);
    
    this.setState(javax.swing.JFrame.ICONIFIED);
    
    frmcompiler.setVisible(true);
    
    //this.setVisible(true);
    this.setState(javax.swing.JFrame.NORMAL);
    see the difference? i just commented the visiblity statement and
    used the setState function to the parent form. so i can iconify the parent form, and the taskbar button stayed alive...


    hope this will help you....
    :)

    oops forget to type.
    frmCompiler is the JDialog window. and "this" denotes the parent form.
    Last edited: May 3, 2012
    vishnudhoodhan, May 3, 2012
    #5
  6. RVince

    vishnudhoodhan

    Joined:
    May 3, 2012
    Messages:
    3
    Mr. Rvince,

    one more thing is i used Netbeans 7.1 and jdk 1.7. so i am not sure about how much it could work for you with java 1.4

    Thank you
    vishnudhoodhan, May 3, 2012
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elrond Bishop

    Create taskbar for windows

    Elrond Bishop, Sep 30, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,762
    Elrond Bishop
    Sep 30, 2004
  2. Alexandr Molochnikov

    Re: JDialog in taskbar under Linux

    Alexandr Molochnikov, Jul 31, 2003, in forum: Java
    Replies:
    0
    Views:
    1,812
    Alexandr Molochnikov
    Jul 31, 2003
  3. Kyzer
    Replies:
    1
    Views:
    379
    Karthik Kumar
    Nov 15, 2004
  4. Dom
    Replies:
    2
    Views:
    734
  5. Pavel Koryakin

    list of all windows from taskbar

    Pavel Koryakin, Jun 23, 2005, in forum: C++
    Replies:
    2
    Views:
    271
    Pavel Koryakin
    Jun 24, 2005
Loading...

Share This Page