Other |
---|
1.2.0 1.2fcsFixed |
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
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\"" ); //*
|