Other |
---|
5.0 b28Fixed |
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: rk38400 Date: 05/18/98 Using the code given below, bring up the internal message dialog. Click on the JTextField & focus is moved there. Worse if you bring up the JOptionPane.showMessageDialog() before dismissing the internal dialog you are totally locked up. import java.awt.*; import java.awt.event.*; import com.sun.java.swing.*; class TestFrame extends JFrame { TestFrame() { getContentPane().setLayout(new FlowLayout()); JButton dlgErrBtn = new JButton("Dialog error msg"); dlgErrBtn.addActionListener(new DlgErrBtnController()); getContentPane().add(dlgErrBtn); getContentPane().add(new JTextField("hello world")); JButton dlgInErrBtn = new JButton("Internal Dialog error msg"); dlgInErrBtn.addActionListener(new DlgInErrBtnController()); getContentPane().add(dlgInErrBtn); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Msg.setParent(this); } class DlgErrBtnController extends AbstractAction { public void actionPerformed(ActionEvent evt) { Msg.err("Hello World\nWe have bugs\n"); } } class DlgInErrBtnController extends AbstractAction { public void actionPerformed(ActionEvent evt) { Msg.errIn("Hello World\nWe have bugs\n"); } } } class Msg { public static void err(String s) { if (frame == null) System.out.println(s); else JOptionPane.showMessageDialog(frame.getContentPane(),s,"Standard Dialog",JOptionPane.INFORMATION_MESSAGE); } public static void errIn(String s) { if (frame == null) System.out.println(s); else JOptionPane.showInternalMessageDialog(frame.getContentPane(),s,"Internal Message Dialog",JOptionPane.INFORMATION_MESSAGE); } public static void setParent(JFrame f) { frame = f; } private static JFrame frame; } public class TestApp { TestApp() throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); frame = new TestFrame(); frame.setSize(400,300); frame.setVisible(true); } public static void main(String[] argv) { try { new TestApp(); } catch(Exception e) { System.out.println(e); e.printStackTrace(); } } TestFrame frame; } (Review ID: 30613) ======================================================================
|