473,473 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to change the length of a JTextField? (Java/Swing)

37 New Member
Hello,

I am trying to shorten the length of a JTextField with the following code :

// up to this point, getColumns() returns a value of 35.
//
jTextField1.setColumns(20);
(jTextField1.getParent()).invalidate();
(jTextField1.getParent()).validate();

When I ran this code, it did not change the length of the text field at all.

I wonder if I am writing my code correctly or is there a better/more correct
way to do this?

Thank you for your help.

Akino.
Aug 7 '08 #1
2 8262
Dököll
2,364 Recognized Expert Top Contributor
Hey there!

Here are a bunch of ideas:

http://forums.sun.com/thread.jspa?th...ssageID=637676

Not sure of the legality of them but, seem to head somewhere.

Let us know!
Aug 8 '08 #2
JosAH
11,448 Recognized Expert MVP
Hello,

I am trying to shorten the length of a JTextField with the following code :

// up to this point, getColumns() returns a value of 35.
//
jTextField1.setColumns(20);
(jTextField1.getParent()).invalidate();
(jTextField1.getParent()).validate();

When I ran this code, it did not change the length of the text field at all.

I wonder if I am writing my code correctly or is there a better/more correct
way to do this?

Thank you for your help.

Akino.
The columns property of a JTextField is a rough estimation used for the calculation
of the preferred size of the component. The preferred width is columns times the
width of the letter 'm' displayed in a certain font. Once a LayoutManager has got
his hands on the JTextField that column property doesn't mean much anymore.
It most certainly doesn't determine the maximum number of characters that can
be entered in the field.

The columns property is a 'bound property' so it can be changed.

kind regards,

Jos
Aug 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Scott Khan | last post by:
We have a Java Swing position. Need consultants ASAP. Position : Java Swing XML / SOAP - FX / Brokerage Requirements : Swing - JTrees / Jtables. other swing classes. etc. Java/ J2EE. JDK...
5
by: haran | last post by:
Hi, I have developed a project by using java Swings. Now i want to deploy that project into web. If its applet means we can deploy that by using browser. so plz help me to deploy the java swing...
3
by: itsmichelle | last post by:
This is a very primative code of a java swing calculator. I have assigned all the number buttons and the operator buttons and I can add, subtract, multiply, and divide two numbers together. However,...
3
by: bytespaulraj | last post by:
We have RHEL5 server. We could able to run Java programs through telnet But When we run Java Swing (GUI) we are getting GTK error Please help us to eliminate this error.
10
by: yeshello54 | last post by:
Hey guys i am pretty new to java swing and need some help. I am developing a simple color chooser program in swing. I have a color panel that is connected to three sliders. red green and blue. but...
2
by: Selva123 | last post by:
Hi All, Greetings. I want to test JAVA SWING application with PERL, do we have any module to do so (like win32::GUI for windows)?. or some third party free tools integrated with PERL? I am...
3
by: Akino877 | last post by:
Hello, I have a Java Swing application that I would like to be able to forward to or to run it - sorry, I am not sure if I am using the right term - from a JSP page. And I would like for my Java...
1
by: JanineXD | last post by:
Hey, I seem to have a problem on a Java Swing Program with ActionListener. I've tried to use getSource in our class but seem don't have an idea why it won't work when I tried to program at...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.