Hi Bill, yes, this question is more related to Swing/awt. You will have better luck here: http://forums.java.net/jive/forum.jspa?forumID=74&start=0
Thanks, Dmitri Bill Dodson wrote:
I am not sure this is the place for this question, but I couldn't seem to find a swing list. In 1.6, when you pass null as the parent component to JOptionPane.showMessageDialog, the focus after clicking the Ok button goes to the top level window. In 1.4 and 1.5, the focus went to the last component to have focus before the message dialog was opened. Here is a small example program. import java.awt.*; import javax.swing.*; import java.awt.event.*; public class JFrameFocusTest extends JFrame { JLabel jLabelWindowName = new JLabel(); JButton jButtonOpenDialog = new JButton(); public JFrameFocusTest() { try { vpGen(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] arg) { JFrameFocusTest jFrameFocusTest1 = new JFrameFocusTest(); jFrameFocusTest1.setLocation(200,200); jFrameFocusTest1.show(); JFrameFocusTest jFrameFocusTest2 = new JFrameFocusTest(); jFrameFocusTest2.jLabelWindowName.setText("Top"); jFrameFocusTest1.setLocation(250,250); jFrameFocusTest2.show(); } private void vpGen() throws Exception { this.setBounds(new Rectangle(10, 10, 389, 354)); jLabelWindowName.setText("Bottom"); jLabelWindowName.setHorizontalAlignment(SwingConstants.CENTER); jLabelWindowName.setHorizontalTextPosition(SwingConstants.CENTER); jButtonOpenDialog.setText("Open Dialog"); this.getContentPane().add(jLabelWindowName, BorderLayout.CENTER); this.getContentPane().add(jButtonOpenDialog, BorderLayout.SOUTH); jButtonOpenDialog.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { jButtonOpenDialog_actionPerformed(e); } }); } void jButtonOpenDialog_actionPerformed(java.awt.event.ActionEvent e) { //the problem can be fixed in this example by changing //the 'null' in the next line to 'this' JOptionPane.showMessageDialog(null, "Whatever", "Error Message", JOptionPane.ERROR_MESSAGE); } } In the above case I know how to make it work like I expected, but in my real code I sometimes have message dialogs called without a reference to the specific window that called them. Does anyone know why this functionality was change for 1.6? BTW, I am running windows xp. Thanks bill =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".