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

Discussion in 'Java' started by U. George, Aug 11, 2005.

  1. U. George

    U. George Guest

    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:

    > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6303620



    ------------------------------------------------------------
    *
    * 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();
    }
    }
     
    U. George, Aug 11, 2005
    #1
    1. Advertising

  2. U. George wrote:
    > 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
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
     
    Thomas Hawtin, Aug 11, 2005
    #2
    1. Advertising

  3. U. George

    U. George Guest

    is this doc'd somewhere?

    > AWT_TOOLKIT=MToolkit




    Thomas Hawtin wrote:
    > U. George wrote:
    >
    >
    > 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.
     
    U. George, Aug 11, 2005
    #3
  4. U. George wrote:
    > is this doc'd somewhere?
    >
    >> AWT_TOOLKIT=MToolkit


    Yeah, it's in the JDK docs. Have a search.

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
     
    Thomas Hawtin, Aug 11, 2005
    #4
  5. U. George

    U. George Guest

    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.

    Thomas Hawtin wrote:
    > U. George wrote:
    >
    >> is this doc'd somewhere?
    >>
    >>> AWT_TOOLKIT=MToolkit

    >>

    >
    > Yeah, it's in the JDK docs. Have a search.
    >
    > Tom Hawtin
     
    U. George, Aug 11, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qazmlp
    Replies:
    4
    Views:
    687
    John C. Bollinger
    Jul 15, 2004
  2. Michal M
    Replies:
    7
    Views:
    806
    Andrew Thompson
    Aug 2, 2005
  3. Guapo
    Replies:
    7
    Views:
    2,171
    Jon Martin Solaas
    Mar 13, 2006
  4. Replies:
    3
    Views:
    5,198
    Bjorn Abelli
    Mar 30, 2006
  5. sujit
    Replies:
    1
    Views:
    937
    Arne Vajhøj
    Jan 5, 2011
Loading...

Share This Page