-
Bug
-
Resolution: Fixed
-
P3
-
solaris_9, 1.4.0
-
beta2
-
x86, sparc
-
solaris_9, windows_2000
Name: yyT116575 Date: 06/12/2001
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
Create an app that contains a simple input type JOptionPane. I used
JOptionPane.showInputDialog(parentComponent, "Enter name", "Add Name",
JOptionPane.QUESTION_MESSAGE);
After entering a name and I press the Enter key I expect the dialog to close
and return the string I entered. The default button is the OK button in this
case so I expect that pressing Enter is like clicking the OK button. This is
normal Windows behavior. This can be reproduced in Solaris platform as well.
/**
* @version 1.20 21 Jun 1998
* @author Cay Horstmann
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class CenteredFrame extends JFrame {
public CenteredFrame() {
try {
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
} catch( Exception e ) {
}
setTitle("CenteredFrame");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
int screenHeight = d.height;
int screenWidth = d.width;
setSize(screenWidth / 2, screenHeight / 2);
setLocation(screenWidth / 4, screenHeight / 4);
Image img = tk.getImage("icon.gif");
setIconImage(img);
Frame[] frames = Frame.getFrames();
String retValue = JOptionPane.showInputDialog( frames[0],
"Enter name of new group: ", "Add New Group", JOptionPane.QUESTION_MESSAGE );
if ( retValue != null ) {
// Add new group name to dropdown
JOptionPane.showMessageDialog( frames[0], retValue );
}
}
public static void main(String[] args) {
JFrame frame = new CenteredFrame();
frame.show();
}
}
(Review ID: 126370)
======================================================================