JDK-6467248 : Textfield works with AWT_TOOLKIT=MToolkit, otherwise field is mostly missing.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2006-09-05
  • Updated: 2011-02-16
  • Resolved: 2008-04-09
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
[gat@MyLaptop ~]$ AWT_TOOLKIT=MToolkit JAVA/JDK16/jdk1.6.0_Beta2/jre1.6.0/bin/java  -version
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode , sharing)
[gat@MyLaptop ~]$


ADDITIONAL OS VERSION INFORMATION :
[gat@MyLaptop tmp]$ uname -a
Linux MyLaptop.gatworks.com 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux
[gat@MyLaptop tmp]$


A DESCRIPTION OF THE PROBLEM :
If you run the sample program, the textfields should have a visible field of "wayPoint p2", and the next field should have "wayPoint p2" . The size of the textfield when pack()'d appears to be too calculated too small.

If I use AWT_TOOLKIT=MToolkit, the textfields are large enough for the text strings.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) JAVA/JDK16/jdk1.6.0_Beta2/jre1.6.0/bin/java  menuFindRoute

2) AWT_TOOLKIT=MToolkit JAVA/JDK16/jdk1.6.0_Beta2/jre1.6.0/bin/java  menuFindRoute

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the AWT to work the same with or without the MToolkit set
ACTUAL -
I expected to see the string in the textfield.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import  java.util.TreeSet;
import  java.util.Comparator;
import  java.lang.Comparable;
import  java.util.Iterator;
import  java.util.TreeMap;
import  java.awt.Point;
import  java.util.ArrayList;
import  java.util.HashSet;

public class menuFindRoute extends java.awt.Frame {

    public menuFindRoute() {
        initComponents();
        start.setText( "wayPoint p1" );
        end.setText( "wayPoint p2" );
        setVisible(true);
    }

    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        label2 = new java.awt.Label();
        panel1 = new java.awt.Panel();
        label1 = new java.awt.Label();
        start = new java.awt.TextField();
        label3 = new java.awt.Label();
        end = new java.awt.TextField();
        find = new java.awt.Button();
        stop = new java.awt.Button();
        panel2 = new java.awt.Panel();
        ok = new java.awt.Button();
        quit = new java.awt.Button();

        label2.setText("label2");

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        panel1.setLayout(new java.awt.GridBagLayout());

        label1.setText("Start");
        panel1.add(label1, new java.awt.GridBagConstraints());

        start.setText("textField1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        panel1.add(start, gridBagConstraints);

        label3.setText("End  ");
        panel1.add(label3, new java.awt.GridBagConstraints());

        end.setText("textField2");
        end.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        panel1.add(end, gridBagConstraints);

        find.setLabel("Find");
        find.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                findMouseClicked(evt);
            }
        });

        panel1.add(find, new java.awt.GridBagConstraints());

        stop.setLabel("Stop");
        stop.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                stopMouseClicked(evt);
            }
        });

        panel1.add(stop, new java.awt.GridBagConstraints());

        add(panel1, java.awt.BorderLayout.CENTER);

        ok.setLabel("Ok\n");
        ok.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                okMouseClicked(evt);
            }
        });

        panel2.add(ok);

        quit.setLabel("Quit\n");
        quit.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                quitMouseClicked(evt);
            }
        });

        panel2.add(quit);

        add(panel2, java.awt.BorderLayout.SOUTH);

        pack();
    }
    public void addNotify() {
        super.addNotify();

    }
    private void quitMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quitMouseClicked
    }
    private void okMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_okMouseClicked
    }
    private void endActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_endActionPerformed
    }
    private void stopMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_stopMouseClicked
    }
    private void findMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_findMouseClicked
    }

    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        if ( false )
            System.exit(0);
        this.setVisible( false );
        return;
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new menuFindRoute().setVisible(true);
            }
        });
    }

    private java.awt.TextField end;
    private java.awt.Button find;
    private java.awt.Label label1;
    private java.awt.Label label2;
    private java.awt.Label label3;
    private java.awt.Button ok;
    private java.awt.Panel panel1;
    private java.awt.Panel panel2;
    private java.awt.Button quit;
    private java.awt.TextField start;
    private java.awt.Button stop;
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Dont bother using the default X window tookkit.

Comments
WORK AROUND Setting text field's minimum size to the proper value solves the problem.
06-09-2006

EVALUATION The same behaviour is described in 4238932 and is a known issue of GridBagLayout. The problem here that GBL uses component's minimum size if it doesn't fit into a grid cell and at the same time text field component's minimum size is (0, 0). When using MToolkit minimum size is set to not-null value.
06-09-2006