473,895 Members | 3,051 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 1997
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
2042
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
11191
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
7980
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
3699
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
1629
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
3821
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
4105
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
1983
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
3327
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
9833
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
10841
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
10931
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
10469
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
9648
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
8025
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
6066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4282
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3293
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.