-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.1.4, 1.1.5, 1.1.8_003, 1.3.0
-
x86, sparc
-
solaris_7, windows_nt
Name: diC59631 Date: 11/11/97
create a simple modal dialog box with a textfield contained within it.
create a menuitem along with a shortcut that will spawn this modal dialog.
try to type in the dialog's textfield.
here is some sample code:
//*********************************
import java.awt.*;
import java.awt.event.*;
public class testModal extends Frame implements ActionListener
{
private MenuItem makeDialog;
private IndentDialog indent;
public static void main(String[] args)
{
testModal thisapp = new testModal();
}
public testModal()
{
super("test modality");
MenuBar mb = new MenuBar();
Menu test = new Menu("test");
test.add(makeDialog = new MenuItem("makeDialog", new MenuShortcut('m')));
mb.add(test);
setMenuBar(mb);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
makeDialog.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
indent = new IndentDialog(this, "", true);
}
});
setBounds(100, 100, 200, 100);
setVisible(true);
}
}
//****************************************
public class IndentDialog extends Dialog implements ActionListener
{
TextField indentSize;
Label pixels;
Button ok, cancel;
int size;
public IndentDialog(Frame f, String title, boolean modal)
{
super(f,title,modal);
setLayout(new BorderLayout());
setResizable(false);
setSize(200,100);
setLocation(300,300);
Panel buttons = new Panel();
buttons.setLayout(new FlowLayout(FlowLayout.CENTER));
buttons.add(ok= new Button("OK"));
buttons.add(cancel = new Button("Cancel"));
Panel topPanel = new Panel();
topPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
topPanel.add(pixels = new Label("Pixels:", Label.CENTER));
topPanel.add(indentSize= new TextField(10));
add("Center", topPanel);
add("South", buttons);
size = 0;
this.addWindowListener(new WinAdapter(false, false));
ok.addActionListener(this);
cancel.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand() == "OK")
{
if(indentSize.getText().length() <= 0) return;
try
{
size = (new Integer(indentSize.getText())).intValue();
}
catch(NumberFormatException ex)
{
indentSize.setText("integral values only");
return;
}
indentSize.setText("");
setVisible(false);
dispose();
}
if(e.getActionCommand() == "Cancel")
{
size = -1;
indentSize.setText("");
setVisible(false);
dispose();
}
}
public int getIndentSize() {return size;}
}
(Review ID: 19774)
======================================================================
Another report: (see ATTACHMENTS for code example)
I have modal dialog containing "OK"/"Cancel" buttons
together with TextField. This dialog is connected
with menu item. When I choose this menu item with mouse or keyboard,
dialog works, bu if I use shortcut, input to TextField locks, and
beeps are sent to speaker. When I recompiled
my classes with jdk1.1.3/1.1.2/1.1.1 everithing works
perfectly.
2nd: I cannot use comma,+,- (i.e. not-letter symbols)
for menu shortcuts.
brian.klock@eng 1997-11-17
======================================================================
- relates to
-
JDK-4128514 JTextField looks like it has keyboard focus but doesn't
-
- Closed
-
-
JDK-4192877 Solaris JDialog initial FOCUS prob...(was "setDefaultButton() won't work")
-
- Closed
-