473,796 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scroll bar attached to text area

60 New Member
I'm trying to set u a scroll bar to be attached to the text area with a border around it. The problem is my text area appears as a small screen above the bordered/scrolled text area.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1. notesText = new JTextArea();
  2. notesText.setLineWrap(true);
  3. notesText.setWrapStyleWord(true);
  4.  
  5. JScrollPane scroll = new JScrollPane(notesText);
  6. scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  7. scroll.setPreferredSize(new Dimension(400, 300));
  8. scroll.setBorder(BorderFactory.createCompoundBorder (BorderFactory.createCompoundBorder (BorderFactory.createTitledBorder("Enter extracts from book"), BorderFactory.createEmptyBorder (5, 5, 5, 5)), scroll.getBorder()));
Your help is very much appreciated.

Petra
Jul 19 '07 #1
2 1987
nickyeng
254 Contributor
scroll.setBorde r(BorderFactory .createCompound Borde r (BorderFactory. createCompoundB order (BorderFactory. createTitledBor der("Enter extracts from book"), BorderFactory.c reateEmptyBorde r (5, 5, 5, 5)), scroll.getBorde r()));

your above line is causing the problem i think...why not make it easier by seperate it ?

too long in a line for setBorder...
Jul 20 '07 #2
JosAH
11,448 Recognized Expert MVP
I'm trying to set u a scroll bar to be attached to the text area with a border around it. The problem is my text area appears as a small screen above the bordered/scrolled text area.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1. notesText = new JTextArea();
  2. notesText.setLineWrap(true);
  3. notesText.setWrapStyleWord(true);
  4.  
  5. JScrollPane scroll = new JScrollPane(notesText);
  6. scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  7. scroll.setPreferredSize(new Dimension(400, 300));
  8. scroll.setBorder(BorderFactory.createCompoundBorder (BorderFactory.createCompoundBorder (BorderFactory.createTitledBorder("Enter extracts from book"), BorderFactory.createEmptyBorder (5, 5, 5, 5)), scroll.getBorder()));
Your help is very much appreciated.

Petra
What happens when you get rid of that complicated border and the preferred
size for that scroll pane? (set the number of rows and columns in the JTextArea
instead).

kind regards,

Jos
Jul 20 '07 #3

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

Similar topics

0
2040
by: syed_saqib_ali | last post by:
Please take a look at and run the code snippet shown below. It creates a canvas with vertical & Horizontal scroll-bars. If you shrink the window to smaller than the area of the canvas, the scroll-bars work as advertised. That's great. However, if you click the Left Mouse button, it calls code which expands the width of the canvas by 100 pixels. The area being viewed expands correspondingly..... BUT I DON'T WANT IT TO!!
3
11180
by: Rithish Saralaya | last post by:
Is there a way to scroll a selected OPTION into view? I have a combination of text box and SELECT list. A user can key in text in the text box, and depending on the entry made, the respective option in the list is to be highlighted. Somewhat like an autocolmplete... I have been able to achieve this, however, if the position/index of the selected option is beyond the SIZE of the SELECT list, then the OPTION positions itself at the bottom...
3
7905
by: cmay | last post by:
I am trying to use scrollIntoView to programatically scroll an area on one of my pages. It wors just like you would expect it to when the page itself doesn't have any scrolling (the page is smaller than the browser window). However, as soon as you introduce the same code on a page that has a vertical scrollbar, the scrollIntoView causes not only the scroll area to move, but also the entire form.
5
3689
by: Aidan | last post by:
Greetings all, I'm trying to build a div based layout for a mambo template (work in progress), and I'm having a strange problem, 2 acctually, with scroll bars in IE. I've tried everything I can think of, but just can't get it to display quite right. It's worth noting that the page displays exactly as intended in Firefox. First Problem:
2
1625
by: Workgroups | last post by:
I need to scroll a virtual grid that is 1.2M pixels x 1.28M pixels in size. I think this is too large of a size for a control or a form, so I think I need to "fake it" with a custom drawn control. I do not need to maintain a bitmap or make the control surface physically larger than the screen, becuase I can create the grid dynamically based upon any virtual X, Y upper-left coordinate of the currently viewed area. E.g., if I am scrolled...
1
3819
by: Raffi | last post by:
Hi, I have an application screen with a CSS scroll area. Users click links in the scroll area which open small popup windows to enter data. When the data is submitted, the popup reloads the opener to update the page and closes itself. However when the parent page is updated, the div scrolls back to the top. Is there a way to have CSS remember the vertical scroll position and go back to it when the page is reloaded? Similar to...
14
4098
by: mbatestblrock | last post by:
Okay, So trust me I have googled, and searched this board before posting.. Maybe I dont know the correct searching phrase. I want to be able to recreate a text area for news on my site, and I want it to have a scroll area that is sharp looking. I know very little javascript, and understand that I probably should, But I dont think this should be TOO difficult. Anyways I have provided a site with an example of how I want it to work ...
3
1981
by: Italio Novuas | last post by:
Hi all, let me begin by saying that I *ALMOST* have this complete! What I'm trying to do is make it so my text area shows the innerHTML of any select item with the same value. For example, if I have a select list with 5 options: <select name="select" onChange="changeValues();"> <option value="1">Option 1</option> <option value="1">More stuff on option 1</option> <option value="1">EVEN more option one stuff!!</option> <option...
1
3323
by: spalanivel | last post by:
Hi, I need to plot the wave format on the usercontrol screen with the use of text file(having input values). Horizontal Scrollbar is placed on the panel . Read the values from 2 text files and plot the wave format like attached. 1) TDI TMS --------------- 0 1 1 0 0 1 and so on..
0
9683
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
10457
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
10231
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6792
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5443
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...
0
5576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2927
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.