473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Remove vertical scroll of jTextArea

126 64KB
How do we remove vertical scroll bar of a jTextArea?
Apr 19 '13 #1
5 11635
r035198x
13,262 8TB
You can pass it to a scroll pane that has the required scrolling options set


Expand|Select|Wrap|Line Numbers
  1.     JTextArea yourTextArea = ...;
  2.  
  3.         JScrollPane pane =  new JScrollPane(yourTextArea,JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
Apr 19 '13 #2
PreethiGowri
126 64KB
Its not showing any text inside it now
Apr 19 '13 #3
r035198x
13,262 8TB
Create a short example that demonstrates the problem and post it.
Apr 19 '13 #4
PreethiGowri
126 64KB
Expand|Select|Wrap|Line Numbers
  1.  jTextArea2.setText("House No = "+house+","+add); //which almost comes upto 3 lines
  2.         jTextArea2.setLineWrap(true);
  3.         jTextArea2.setWrapStyleWord(true);
  4.         JScrollPane pane =  new JScrollPane(jTextArea2,
  5. JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
When i do so i scrollpane is removed but text inside textarea is not displayed
Apr 19 '13 #5
r035198x
13,262 8TB
Must be something wrong with some code that you haven't posted because this doesn't show scroll bars

Expand|Select|Wrap|Line Numbers
  1. import javax.swing.JFrame;
  2. import javax.swing.JScrollPane;
  3. import javax.swing.JTextArea;
  4. import javax.swing.SwingUtilities;
  5. import javax.swing.UIManager;
  6.  
  7. public class Test extends JFrame {
  8.  
  9.     private JScrollPane jScrollPane;
  10.     private JTextArea textArea;
  11.  
  12.     public Test() {
  13.         initComponents();
  14.     }
  15.  
  16.     private void initComponents() {
  17.         setSize(500, 500);
  18.  
  19.  
  20.         StringBuilder text = new StringBuilder();
  21.         for (int i = 0; i < 100; i++) {
  22.             text.append("Line number " + (i + 1)).append("\n");
  23.         }
  24.         textArea = new JTextArea(text.toString());
  25.  
  26.         jScrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  27.         getContentPane().add(jScrollPane);
  28.  
  29.     }
  30.  
  31.     public static void main(String args[]) {
  32.         SwingUtilities.invokeLater(new Runnable() {
  33.             @Override
  34.             public void run() {
  35.                 // Turn off metal's use of bold fonts
  36.                 UIManager.put("swing.boldMetal", Boolean.FALSE);
  37.                 new Test().setVisible(true);
  38.             }
  39.         });
  40.     }
  41.  
  42. }
Apr 19 '13 #6

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

Similar topics

0
by: David Pratt | last post by:
Hi. I am putting together a database application on Zope. I have built a pager for my records (20 per page) but do not want the browser scroll bars to reset to the top of the browser each time the...
2
by: Nathan Wallace | last post by:
When in quirks mode, IE seems to be able to display pages without any vertical scrollbar: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <style> body {...
1
by: Ted | last post by:
I am trying to return the vertical scroll position of a rich textbox control using Access 2000. It seems to work for the horizontal scroll bar, but not the vertical. Code follows: Option...
0
by: Sachin | last post by:
How to match the look and feel of vertical scroll bar with the inbuilt vertical scroll bars of some controls like PrintPreviewControl, Rich Text box , etc. Their scroll bars look blue where the...
7
by: bienwell | last post by:
Hi, I'm using the CheckBoxList control in ASP.NET for Web development. This checkboxlist is bound by the database. If we have more items for this checkbox list, it takes space on the page. I...
0
by: Greg | last post by:
I've made a datagrid multiline (for anyone interested, I used an adaptation of the code at http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp). This has introduced a very serious issue: the vertical...
2
by: akm | last post by:
I am facing an issue with the vertical scroll bar. Actually i am using data grid to display the data in my tables, and also i am using the same view form to diplay the data for different tables....
2
by: Sean Liming \(MVP\) | last post by:
I have a communication program using the SerialPort control. The application performs the serial read in sPort_DataReceived thread and data is displayed in a RichTextBox using the callback/invoke...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client...
4
by: Matthew Cox | last post by:
Hi, I've been searching the net all day today trying to figure out how one would accomplish what I originally thought would be a fairly straight forward and simple thing. The problem I'm trying...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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...
0
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...

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.