Can someone try this on RedHat Linux/jre1.5 or redhat linux/jdk1.6?

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();
}
}
 
T

Thomas Hawtin

U. George said:
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.

By default in 1.5.0_04 and 1.6.0-ea-b64 I get the typed letter followed
by the Z. i.e. consuming the KEY_PRESSED event does not suppress the key
typed.

Using the old Motif toolkit (which is what 1.4 has), with export
AWT_TOOLKIT=MToolkit, on the other hand just displays Z. i.e. consuming
the KEY_PRESSED event does suppress the key typed.

I'm not surprised by either behaviour.

Tom Hawtin
 
U

U. George

So I just tried it. one way, then the other. The default, and setting
export AWT_TOOLKIT=XToolkit does the double char business.

setting the export AWT_TOOLKIT=MToolkit
does what it used to - WORK!

thanks again, guess i'll update the sun bug report, and see if i can
resubmit.
It also seems that the folks at sun dont bother to use the *default
XToolkit* in their debugging sessions. Otherwise the bug report
evaluator would have noticed the error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top