Duplicate :
|
Name: rk38400 Date: 05/19/98 Calling JOptionPane.showMessageDialog(Component parentComponent, Object message, String title, int messageType) doesn't set the title of the message box correctly. For example if I call showMessageDialog and set the title to be "Title1" and then call showMessageDialog with a different title the title remains "Title1". My development environment is VisualCafe 2.5 using Swing 1.02. The following code demonstrates the problem. If you click on Button1 it pops up a message dialog with the title "Original Title". If you click on Button2 it also pops up a message dialog with the same title even though the title should be set to "A Different Title". Additional info: In reference to the bug I already submitted about this when I tested this on Solaris 2.51 it worked correctly. (The original bug was submitted in reference to WindowsNT) import com.sun.java.swing.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.FlowLayout; public class TestMessageDialog { public TestMessageDialog() { JFrame frame = new JFrame("test"); frame.getContentPane().setLayout(new FlowLayout()); JButton button = new JButton("Button 1"); JButton button1 = new JButton("Button 2"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null,"A Message","Original Title",JOptionPane.INFORMATION_MESSAGE); }}); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null,"Another Message","A Different Title",JOptionPane.INFORMATION_MESSAGE); }}); frame.getContentPane().add(button); frame.getContentPane().add(button1); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);}}); frame.pack(); frame.show(); frame.setLocation(200,200); } public static void main(String[] args){ new TestMessageDialog(); } } (Review ID: 30697) ======================================================================