473,670 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TextArea expands on own?

Hey im kinda a newbie to java so i dont know much any help would be
appreciated. Thanx in advance to anyone who does help or takes the time
to read this.
Hey i have placed a text area in a panel which uses a borderlayout.
the code goes relatively like this

// Create a new JPanel to sit in the top right corner
this.topRight = new JPanel();
this.topRight.s etLayout(new BorderLayout()) ;

String plantInfo = plantGetInforma tion();
plantInformatio n.setMaximumSiz e(new Dimension(100, 300));
plantInformatio n.setText(plant Info);

private String plantGetInforma tion()
{
String allInfo = "";
allInfo = allInfo + "Descriptio n: " + dataPlant.getDe scription() +
"\n";
allInfo = allInfo + "Other Notes: " + dataPlant.getOt herNotes() + "\n";
return allInfo;
}

Anyway my problem is that when I add this information to the text field
the text field expands opff the screen to fit in the text.. The get
description returns a rather long string. Is there anyway i can have
stay at a set size and drop down automatically without using \n?

Thanx

Jul 17 '05 #1
2 2356
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Merlin_1102 wrote:
Hey im kinda a newbie to java so i dont know much any help would be
appreciated. Thanx in advance to anyone who does help or takes the
time to read this.
Hey i have placed a text area in a panel which uses a borderlayout.
the code goes relatively like this

// Create a new JPanel to sit in the top right corner
this.topRight = new JPanel();
this.topRight.s etLayout(new BorderLayout()) ;

String plantInfo = plantGetInforma tion();
plantInformatio n.setMaximumSiz e(new Dimension(100, 300));
plantInformatio n.setText(plant Info);

private String plantGetInforma tion()
{
String allInfo = "";
allInfo = allInfo + "Descriptio n: " +
dataPlant.getDe scription() +
"\n";
allInfo = allInfo + "Other Notes: " + dataPlant.getOt herNotes()
+ "\n";
return allInfo;
}

Anyway my problem is that when I add this information to the text
field the text field expands opff the screen to fit in the text..
The get description returns a rather long string. Is there anyway i
can have stay at a set size and drop down automatically without
using \n?

Thanx


Hi,
As far as I can tell, your "plantInformati on" is a JTextArea. If this
is so, it will indeed get as large as necessary to hold all the text.
If you want a "classic"-style text area, you need a JScrollPane. You
should be able to do the following, wherever it is you have
<something>.add (plantInformati on):

JScrollPane sp = new JScrollPane(pla ntInformation);
<something>.add (sp);

The default configuration is for the JScrollPane to take up the amount
of space it's "supposed" to (i.e. the layout manager, or you, tell it
to - you'll need to call setMaximumSize( ) on the JScrollPane instead
of the JTextArea), and display scrollbars if the content gets too
big. You can use the 3-parameter constructor or the
set{Vertical|Ho rizontal}Scroll barPolicy() methods if you need the
scrollbars to be permanent or nonexistent.

- --
Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/ymUMwxczzJRavJY RAlTRAKCdj876PU gr6PeX8Ai+Z8JiI okKjACgiaNg
9rWShSX782wgUvj 9bidLEEg=
=s3tp
-----END PGP SIGNATURE-----
Jul 17 '05 #2
>
JScrollPane sp = new JScrollPane(pla ntInformation);
<something>.add (sp);


Additionally if you want to keep the info on screen...

plantInformatio n.setLineWrap( true );

// and optionally to keep from wrapping in the middle of a word.

plantInformatio n.setWrapStyleW ord( true );
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10200
by: David | last post by:
It's sad to say, but when using the AOL web site, like to send an email, they have a nifty capability such that when a window is resized, the textarea where the message is input expands not only horizontally, but also vertically, to fill the space. I took a look at their javascripts, but they are quite complex and convoluted since they make use of many of their own functions designed to work with their web site. Does anybody have a...
11
5232
by: bill | last post by:
I want to have a form with a text input, a textarea and a button. - - - - - - - - - - - - - - - - - - - - - - - - sample form <div style="color=blue; border: dashed blue"> <div id="subject">For a Bulk Email:<br />Subject: <input type="text" name="bulk_subject" size="60" /> </div> <div id="paper"> <textarea rows="25" cols="65" name="bulk_letter"> </textarea>
4
16688
by: Csaba Gabor | last post by:
What I'd like to do is to be able to set the font of a textarea element to the same font that another element is using (say, for example, an <INPUT type=text ...> element, but if that's a no go, then a generic element's font will do OK, too. What's the correct way to do this, please (so that it will also work for IE 6)? The motivation for this is that I have some text on the screen and I want to insert a textarea element between the...
6
9266
by: Thirteenva | last post by:
I've encountered a bug in IE that I can not find a fix to. Maybe someone can help me out here. I have a 3 column css layout. The middle column is fluid and expands as the browser is resized. I have a textarea who's width is 100%. This text box resides in the middle column. When the page renders in IE the textarea is sized to 100% of the middle div, the way it should be. However, when i start typing in this box it immediately expands...
1
3555
by: Volt | last post by:
is there any way to select and mark part of text in textarea by regular expression? i need to select the first string in textarea whitch is like xxxxx,xxx where x is any character
4
4242
by: TJS | last post by:
can the rows and columns of a textarea element with an id be changed on the fly ? if so is there an example ?
1
1382
by: libsfan01 | last post by:
hi all i have a text area on a webpage that expands/contracts (height in px) based on the number of characters inside it, which may or not be relevent. the problem is most of the time someone is clicking on it and typing in stuff the cursor line (looks like that -| ) which shows u where u are on the line dissappears. has anyone else encountered this, know whats causing it or how to fix it?
3
5634
by: FunkHouse9 | last post by:
I'm working on a form to collect data in a textarea which and am trying to keep returns and spaces. I have a couple of functions that I Frankensteined together to replace returns with <br> and to replace spaces with &nbsp;. The <br> part works well enough, but I keep getting "%20" instead of "&nbsp;" for the spaces. I understand that escape() changes " " to "%20", but I would think the ConvertSpaces function below would change the %20 to...
2
3558
by: ivowel | last post by:
dear experts: is it possible to define in plain html (perhaps with css) a textarea in a form that expands over the entire width of a browser window? sincerely, /iaw
0
8468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7415
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4209
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2799
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 we have to send another system
2
2041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1792
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.