This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 112462 - Text field size not displays correctly
Summary: Text field size not displays correctly
Status: VERIFIED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Peter Zavadsky
URL: http://www.nabble.com/Text-field-size...
Keywords:
: 116079 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-08-09 15:00 UTC by lujop
Modified: 2007-09-20 18:20 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lujop 2007-08-09 15:00:05 UTC
Using VWP with Netbeans 5.5 or Netbeans 6 M10 I can't correctly
arrange the text field components. Because the size of the text field
that I view in Netbeans it's very different of the size of the
component when it's rendered to the browser. 

For complete info look at
http://www.nabble.com/Text-field-size-rendering-not-displays-correctly-in-browser-using-VWP-tf4230458.html#a12035314
Comment 1 Peter Zavadsky 2007-08-09 18:53:01 UTC
Yes it seems there size based on specified columns doesn't seem to be correct. 
You can try to see that (by default column size is 20), and if you put 20 chars into the text field (e.g.
"12345678901234567890", you can see that the size shown is actually some columns bigger.
Investigating.
Comment 2 Peter Zavadsky 2007-08-09 19:09:54 UTC
It seems the problem is with the swing component (text field in this case), which computes the width, that it adds some
gap after the specified number comlumns, so the actual width is larger than the number of specified columns.
Comment 3 Peter Zavadsky 2007-08-09 19:18:41 UTC
So I found the issue, the width in swing is computed based on the number of columns, and it is interpreted the way that
one column width is equal the width of 'm' character of used font.
I.e. when in swing you have textfield which you specify 20 columns. The width will be the same like with of this text: 
"mmmmmmmmmmmmmmmmmmmm"
the problem is when used different characters there appears the gap, e.g.:
"12345678901234567890"
Note: you can see the difference when non-monospaced font is used.

When comparing the browser, it seems that it calculates the width of textfield based on the columns, using different
character than 'm' (you can try to put that above text, and you'll it won't be fully visible in firefox with textfield
with 20 columns.

We needs to compute the width of textfield similar way the browser does. First we need to find out (hopefully not
guess?) how browser does that.
Comment 4 Peter Zavadsky 2007-08-09 22:47:47 UTC
I didn't find any algorithm. It seems it is not specified by W3C, and each browser implements it on its own. Because of
this I'll try to adjust it a bit, so the difference is not that big.
Comment 5 Peter Zavadsky 2007-08-09 23:13:46 UTC
Fixed. Now it will be closer to the column widths used by the browsers (compared to Firefox).

Note: Each browser has each own algorithm, so all of them (at least) slightly differ as well.

Checking in visualweb/designer/src/org/netbeans/modules/visualweb/css2/FormComponentBox.java;
/cvs/visualweb/designer/src/org/netbeans/modules/visualweb/css2/FormComponentBox.java,v  <--  FormComponentBox.java
new revision: 1.10; previous revision: 1.9
done
Checking in visualweb/designer/src/org/netbeans/modules/visualweb/designer/FormComponentEditor.java;
/cvs/visualweb/designer/src/org/netbeans/modules/visualweb/designer/FormComponentEditor.java,v  <-- 
FormComponentEditor.java
new revision: 1.21; previous revision: 1.20
done
Comment 6 lujop 2007-08-10 09:01:14 UTC
My little testings showed that the two major browsers Firefox 2.0 and IE7 display practically equal (look at the images
of  nabble link).
I think that what more significantly change the size of a field is increasing the text size in the browser.
I haven't been able to test your patch although I think that it will be perfect for me. But possibly wouldn't be a bad
idea to leave a parameter in advanced config named VWP_column_size_factor. That way people people with target their
applications to other browsers or to other text sizes won't have any problems.
Comment 7 _ krystyna 2007-08-17 03:36:40 UTC
Marking this as verified in: NetBeans IDE Dev (Build 200708161200) Java: 1.5.0_12; Java HotSpot(TM) Client VM 1.5.0_12-
b04 System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)

Lujop,

You can download a daily build (Java EE package) to also verify:
http://bits.netbeans.org/download/6.0/nightly/200708161200/
Comment 8 Peter Zavadsky 2007-09-18 01:19:05 UTC
Fixed also password field.

Checking in visualweb/designer/src/org/netbeans/modules/visualweb/css2/FormComponentBox.java;
/cvs/visualweb/designer/src/org/netbeans/modules/visualweb/css2/FormComponentBox.java,v  <--  FormComponentBox.java
new revision: 1.13; previous revision: 1.12
done
Comment 9 Lark Fitzgerald 2007-09-20 18:20:53 UTC
*** Issue 116079 has been marked as a duplicate of this issue. ***