<Swing Dev> Question about bug 4512626
Sean Chou
zhouyx at linux.vnet.ibm.com
Wed Dec 7 08:21:30 UTC 2011
Hi all,
I'm just working on a similar bug like 4512626, so I wrote a simple
testcase for 4512626.
However, I think 4512626 is not in the state as described in its comment.
The comment says:
"
MS Windows indicates the focus of uneditable text component by
displaying a flashing caret. We could make the same thing with
JTextField, JPasswordField, JFormattedTextField and JTextArea.
For Windows LAF we could make this without API changes just by
overriding createCaret() in corresponding UI classes.
"
I tested these 4 components in windows LAF and found they are not
displaying the caret at all.
Is that because it was thought "won't fix" ?
The link is : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4512626
The testcase is :
import java.awt.EventQueue;
import javax.swing.BoxLayout;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
public class NonEditableFocusTest extends JFrame {
private JPanel contentPane;
private JTextField txtJtextfield;
private JPasswordField passwordField;
private JButton btnWinLf;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
NonEditableFocusTest frame = new NonEditableFocusTest();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public NonEditableFocusTest() {
String LAF = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(LAF);
} catch (ClassNotFoundException | InstantiationException
| IllegalAccessException | UnsupportedLookAndFeelException
e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
passwordField = new JPasswordField();
passwordField.setEditable(false);
passwordField.setText("passwod");
passwordField.setToolTipText("JPasswordField");
contentPane.add(passwordField);
JFormattedTextField frmtdtxtfldJformattedtextfield = new
JFormattedTextField();
frmtdtxtfldJformattedtextfield.setText("JFormattedTextField");
frmtdtxtfldJformattedtextfield.setEditable(false);
frmtdtxtfldJformattedtextfield.setToolTipText("JFormattedTextField");
contentPane.add(frmtdtxtfldJformattedtextfield);
JTextArea txtrJtextarea = new JTextArea();
txtrJtextarea.setText("JTextArea");
txtrJtextarea.setEditable(false);
txtrJtextarea.setToolTipText("JTextArea");
contentPane.add(txtrJtextarea);
txtJtextfield = new JTextField();
txtJtextfield.setText("JTextField");
txtJtextfield.setEditable(false);
txtJtextfield.setToolTipText("JTextField");
contentPane.add(txtJtextfield);
txtJtextfield.setColumns(10);
btnWinLf = new JButton(LAF);
contentPane.add(btnWinLf);
}
}
--
Best Regards,
Sean Chou
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20111207/6f43ffee/attachment.html>
More information about the swing-dev
mailing list