U
U. George
Can someone try this program on a Redhat linux system with either
jdk1.5, or jdk1.6.
When I do a TextField.setText(), is does not erase the text field with
what I want to have displayed. The typed/keyboard-in text is still
displayed in the TextField.
This works in jre1.4
I submitted this as a bug to sun/javasoft:
------------------------------------------------------------
*
* TF2Chars.java
*
* Created on July 28, 2005, 5:46 AM
*/
/**
*
* @author gat
*/
import java.awt.Frame;
public class TF2Chars extends java.awt.Panel {
private Frame f;
/** Creates new form menuLocation2 */
public TF2Chars() {
System.out.println("TF2Chars started");
initComponents();
initListener();
f = new Frame("City Location Finder");
f.add(this);
}
public void
reStart() {
System.out.println("TF2Chars restarted");
if( f.isVisible() ) {
f.toFront();
return;
}
f.pack();
f.setVisible( true );
addListener( true );
}
static
public void main( String[] args ) {
TF2Chars m = new TF2Chars();
m.reStart();
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
West = new java.awt.Panel();
tLocations = new java.awt.TextField();
panel1 = new java.awt.Panel();
setLayout(new java.awt.BorderLayout());
West.setLayout(new java.awt.GridBagLayout());
tLocations.setColumns(35);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth =
java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
West.add(tLocations, gridBagConstraints);
panel1.setLayout(new java.awt.BorderLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth =
java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
West.add(panel1, gridBagConstraints);
add(West, java.awt.BorderLayout.CENTER);
}
private void tLocationsKeyPressed(java.awt.event.KeyEvent evt) {
System.out.println("menuLocation2.tLocationKeyPressed()");
String s = "Z"; //tEdit.composeNewEditString( evt );
evt.consume(); // dont let it filter to
rest of Event system
//if ( s == null ) return;
//System.out.println("menuCities.tLocationsKeyPressed(); s = "+s);
tLocations.setText( s );
//tLocations.setCaretPosition(tEdit.getCaretPosition());
//tLocations.setCaretPosition(1);
//System.out.println("String to set = "+s+", got back
="+tLocations.getText() );
}
private java.awt.Panel West;
private java.awt.Panel panel1;
private java.awt.TextField tLocations;
java.awt.event.KeyAdapter keyadapter;
java.awt.event.WindowAdapter winAdapter;
void
initListener() {
keyadapter = new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
tLocationsKeyPressed(evt); }
};
winAdapter = new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt); }
};
}
void
addListener( boolean b ) {
if( b ) {
tLocations.addKeyListener( keyadapter );
f.addWindowListener( winAdapter );
return;
}
tLocations.removeKeyListener( keyadapter );
f.removeWindowListener( winAdapter );
}
private void
closeDialog(java.awt.event.WindowEvent evt) {
f.setVisible(false);
addListener( false );
f.dispose();
}
}
jdk1.5, or jdk1.6.
When I do a TextField.setText(), is does not erase the text field with
what I want to have displayed. The typed/keyboard-in text is still
displayed in the TextField.
This works in jre1.4
I submitted this as a bug to sun/javasoft:
------------------------------------------------------------
*
* TF2Chars.java
*
* Created on July 28, 2005, 5:46 AM
*/
/**
*
* @author gat
*/
import java.awt.Frame;
public class TF2Chars extends java.awt.Panel {
private Frame f;
/** Creates new form menuLocation2 */
public TF2Chars() {
System.out.println("TF2Chars started");
initComponents();
initListener();
f = new Frame("City Location Finder");
f.add(this);
}
public void
reStart() {
System.out.println("TF2Chars restarted");
if( f.isVisible() ) {
f.toFront();
return;
}
f.pack();
f.setVisible( true );
addListener( true );
}
static
public void main( String[] args ) {
TF2Chars m = new TF2Chars();
m.reStart();
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
West = new java.awt.Panel();
tLocations = new java.awt.TextField();
panel1 = new java.awt.Panel();
setLayout(new java.awt.BorderLayout());
West.setLayout(new java.awt.GridBagLayout());
tLocations.setColumns(35);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth =
java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
West.add(tLocations, gridBagConstraints);
panel1.setLayout(new java.awt.BorderLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth =
java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
West.add(panel1, gridBagConstraints);
add(West, java.awt.BorderLayout.CENTER);
}
private void tLocationsKeyPressed(java.awt.event.KeyEvent evt) {
System.out.println("menuLocation2.tLocationKeyPressed()");
String s = "Z"; //tEdit.composeNewEditString( evt );
evt.consume(); // dont let it filter to
rest of Event system
//if ( s == null ) return;
//System.out.println("menuCities.tLocationsKeyPressed(); s = "+s);
tLocations.setText( s );
//tLocations.setCaretPosition(tEdit.getCaretPosition());
//tLocations.setCaretPosition(1);
//System.out.println("String to set = "+s+", got back
="+tLocations.getText() );
}
private java.awt.Panel West;
private java.awt.Panel panel1;
private java.awt.TextField tLocations;
java.awt.event.KeyAdapter keyadapter;
java.awt.event.WindowAdapter winAdapter;
void
initListener() {
keyadapter = new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
tLocationsKeyPressed(evt); }
};
winAdapter = new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt); }
};
}
void
addListener( boolean b ) {
if( b ) {
tLocations.addKeyListener( keyadapter );
f.addWindowListener( winAdapter );
return;
}
tLocations.removeKeyListener( keyadapter );
f.removeWindowListener( winAdapter );
}
private void
closeDialog(java.awt.event.WindowEvent evt) {
f.setVisible(false);
addListener( false );
f.dispose();
}
}