JDK-4120856 : win32: setTitle on modal dialogs will fail to change the title
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.0.2,1.1,1.1.5,1.1.6,1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10,windows_95,windows_nt
  • CPU: generic,x86
  • Submitted: 1998-03-18
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2fcsFixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Description
On win32, changing the title of a modal dialog doesn't appear to work.

The included program demonstrates this problem.
Bring up the program
Click on "Show Modal Dialog"
(note the dialog title: "New Title: 1")
Click on "Close Modal Dialog"

Click on "Show Modal Dialog" again
(note the dialog title is STILL "New Title: 1", should be "New Title: 2")

The problem only occurs with modal dialogs (setTitle on non-modal Dialogs
and Frames works fine), and it only occurs on win32.

Also, strangely enough, if you call setTitle *while* the modal dialog
is showing, it works!

Unfortunately, though, this bug affects Swing because for our Option dialogs,
we re-use dialog instances (to get around a bug in Solaris where disposing
dialogs causes a SEGV), and this bug causes titles to be incorrect.


/*-----------------------------------------------------------------------*/
import java.awt.*;
import java.awt.event.*;


public class WinTitleTest extends Frame {
    Dialog dialog, modalDialog;
    Frame frame;

    public WinTitleTest() {
        super("Window Title Test");

        add("North", new Label("Window titles should change each time shown..."));
        
        Panel p = new Panel();
        p.setLayout(new FlowLayout());
        add("Center", p);

        modalDialog = new Dialog(this, "Initial Title", true);
        Button b = new Button("   Close Modal Dialog...   ");
        b.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                modalDialog.setVisible(false);
            }
        });    
        modalDialog.add("North", b);
        modalDialog.pack();
        b = new Button("Show Modal Dialog");
        b.addActionListener(new TitleChanger(modalDialog));
        p.add(b);

        dialog = new Dialog(this, "Initial Title", false);
        b = new Button("   Close Dialog...   ");
        b.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
            }
        });    
        dialog.add("North", b);
        dialog.pack();
        b = new Button("Show Dialog");
        b.addActionListener(new TitleChanger(dialog));
        p.add(b);

        frame = new Frame("Initial Title");
        b = new Button("    Close Frame....    ");
        b.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                frame.setVisible(false);
            }
        });
        frame.add("North", b);
        frame.pack();

        b = new Button("Show Frame");
        b.addActionListener(new TitleChanger(frame));
        p.add(b);

        pack();
    }
    public static void main(String[] args) {
        WinTitleTest test = new WinTitleTest();
        test.show();
    }
}

class TitleChanger implements ActionListener {
    Window win;
    int counter = 0;

    public TitleChanger(Window win) {
        this.win = win;
    }

    public void actionPerformed(ActionEvent e) {
        if (win instanceof Frame) {
            ((Frame)win).setTitle("New Title: "+(++counter));
        } else if (win instanceof Dialog) {
            // BUG:  This seems to fail for modal dialogs!!!!
            ((Dialog)win).setTitle("New Title: "+(++counter));
        }
        win.setVisible(true);
    }
}



erik.larsen@Eng 1998-05-21
web bug Incident: (###@###.###)
import java.awt.*;
import java.awt.event.*;

public class DialogTest extends java.awt.Frame {
	public static void main( String[] args ) {
		final Frame dt = new DialogTest();
		dt.setVisible( true );
		
		final Dialog d = new Dialog( dt, "", true );
		WindowListener l = new WindowAdapter() {
								public void windowClosing(WindowEvent e){
									((Window)e.getSource()).setVisible(false);
									if ( e.getSource() == dt ) System.exit(0);
								}
							};
		System.out.println( "setting title to \"TITLE 1\"" );
		d.setTitle( "TITLE 1" );
		dt.addWindowListener( l );
		d.addWindowListener( l );
		d.setBounds( 5,5,200,50 );
		d.setVisible( true );
		System.out.println( "setting title to \"TITLE 2\"" );
		//*

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2fcs INTEGRATED IN: 1.2fcs
14-06-2004

PUBLIC COMMENTS win32: setTitle on modal dialogs will fail to change the title.
10-06-2004

EVALUATION This is Fixed and Integrated in 1.2fcs. lara.bunni@Eng 1998-09-02
02-09-1998