-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.1.7
-
sparc
-
solaris_2.6
In the test case below, give focus to the second JTextfield and press
enter. Dismiss dialog 1.
On Solaris, textfield 2 is highlighted when the first dialog comes up, as well
as the default button ("Don't Press"). When the second dialog is dismissed,
textfield 2 remains highlighted, but not fully repainted, while the caret is active in textfield 1.
This has been tested with 1.1.6, 1.1.7L and Swing 1.0.2, 1.0.3, and 1.1beta3 with identical results.
The same code compiled and run with 1.1.7 on Windows demonstrates a different
bug (see #4173790).
_______________________________ DoubleFocus.java -------------------------------
import com.sun.java.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DoubleFocus extends JInternalFrame {
public DoubleFocus() {
setSize(400, 300);
getContentPane().setLayout(new FlowLayout());
tf1.setColumns(10);
tf2.setColumns(16);
getContentPane().add(tf1);
getContentPane().add(tf2);
getContentPane().add(targetButton);
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
tf2.getKeymap().removeKeyStrokeBinding(enter);
getRootPane().setDefaultButton(targetButton);
targetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
tf1.setText("");
tf2.setText("");
doDlgSequence();
}
});
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Could not set L&F: " + e);
e.printStackTrace();
}
frame = new JFrame();
frame.setSize(800, 600);
JDesktopPane dt = new JDesktopPane();
frame.getContentPane().add(dt);
frame.setVisible(true);
DoubleFocus bt = new DoubleFocus();
dt.add(bt);
dlg = new Dlg1(frame);
}
public void doDlgSequence() {
showDlg1();
showDlg2();
}
public void showDlg1() {
dlg.setVisible(true);
}
public void showDlg2() {
JOptionPane.showMessageDialog(frame, "This is dlg 2", "2",
JOptionPane.ERROR_MESSAGE);
tf1.requestFocus();
}
JButton targetButton = new JButton("Don't Press");
static Dlg1 dlg ;
static JFrame frame;
JTextField tf1 = new JTextField("Tab to next");
JTextField tf2 = new JTextField("Press enter here");
}
class Dlg1 extends JDialog {
public Dlg1(Frame frame) {
super(frame);
setSize(200, 200);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(label);
getContentPane().add(button);
setModal(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
setVisible(false);
}
});
}
JButton button = new JButton("OK");
JLabel label = new JLabel("This is dialog 1");
}
--------------------
This bug does in fact occur on both Solaris and Windows if the plaf
is set to Motif and run against both platforms. Therefore, I will
be closing the Shadow bug in the java_solaris category as this appears
to be a Swing related bug.
james.melvin@East 1998-11-12
--------------------------------------------------------------------------------
I have tested this bug with Swing 1.1.1 beta 2 and have found that it no longer
occurs.
nick.rodin@eng 1999-04-07
enter. Dismiss dialog 1.
On Solaris, textfield 2 is highlighted when the first dialog comes up, as well
as the default button ("Don't Press"). When the second dialog is dismissed,
textfield 2 remains highlighted, but not fully repainted, while the caret is active in textfield 1.
This has been tested with 1.1.6, 1.1.7L and Swing 1.0.2, 1.0.3, and 1.1beta3 with identical results.
The same code compiled and run with 1.1.7 on Windows demonstrates a different
bug (see #4173790).
_______________________________ DoubleFocus.java -------------------------------
import com.sun.java.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DoubleFocus extends JInternalFrame {
public DoubleFocus() {
setSize(400, 300);
getContentPane().setLayout(new FlowLayout());
tf1.setColumns(10);
tf2.setColumns(16);
getContentPane().add(tf1);
getContentPane().add(tf2);
getContentPane().add(targetButton);
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
tf2.getKeymap().removeKeyStrokeBinding(enter);
getRootPane().setDefaultButton(targetButton);
targetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
tf1.setText("");
tf2.setText("");
doDlgSequence();
}
});
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Could not set L&F: " + e);
e.printStackTrace();
}
frame = new JFrame();
frame.setSize(800, 600);
JDesktopPane dt = new JDesktopPane();
frame.getContentPane().add(dt);
frame.setVisible(true);
DoubleFocus bt = new DoubleFocus();
dt.add(bt);
dlg = new Dlg1(frame);
}
public void doDlgSequence() {
showDlg1();
showDlg2();
}
public void showDlg1() {
dlg.setVisible(true);
}
public void showDlg2() {
JOptionPane.showMessageDialog(frame, "This is dlg 2", "2",
JOptionPane.ERROR_MESSAGE);
tf1.requestFocus();
}
JButton targetButton = new JButton("Don't Press");
static Dlg1 dlg ;
static JFrame frame;
JTextField tf1 = new JTextField("Tab to next");
JTextField tf2 = new JTextField("Press enter here");
}
class Dlg1 extends JDialog {
public Dlg1(Frame frame) {
super(frame);
setSize(200, 200);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(label);
getContentPane().add(button);
setModal(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
setVisible(false);
}
});
}
JButton button = new JButton("OK");
JLabel label = new JLabel("This is dialog 1");
}
--------------------
This bug does in fact occur on both Solaris and Windows if the plaf
is set to Motif and run against both platforms. Therefore, I will
be closing the Shadow bug in the java_solaris category as this appears
to be a Swing related bug.
james.melvin@East 1998-11-12
--------------------------------------------------------------------------------
I have tested this bug with Swing 1.1.1 beta 2 and have found that it no longer
occurs.
nick.rodin@eng 1999-04-07
- relates to
-
JDK-4173790 1.1.7: Focus Problems with Consecutive Modal JDialogs on win32
- Closed