|
| ||||||||||
| Tags: awt, graphical user interface, jtextarea, scrollbar, swing |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Add scrollbar to JTextArea
I made a GUI application with a JTextArea, when i append some text to it, it begin change its height, now I want to add scrollbar to the Jtextarea, but I do not know how to do that. If you have any idea please let me know. Thanks in advance. |
|
#2
| |||
| |||
| Re: Add scrollbar to JTextArea
Hello, "now I want to add scrollbar to the Jtextarea, but I do not know how to do that. If you have any idea please let me know." The solution for your problem is to add a JScrollPane to your JTextArea. I think this is quite simple solution and you should not have any problems to do it. Still if you have queries regarding this topic then you can post and we will try to solve it. |
|
#3
| |||
| |||
| Re: Add scrollbar to JTextArea
Hello, Even I want to add a scrollbar to the Jtextarea, but I do not know how to code that. I have tried you solution but it does not work for me. I think if you post a sample source code it would be great and it can help me a lot than just a explanation. Also, if you have any other alternative then please let me know I am the interested here. Thanks in advance. |
|
#4
| |||
| |||
| Re: Add scrollbar to JTextArea
Hello, This is my updated code have a look at it and if you find any more problems then please guide me with the correct. Code: JScrollPane scpn = new JScrollPane (informationRunwayEnglishTextField); contentPane.setPreferredSize (new Dimension (450, 110)); contentPane.add (scpn, BorderLayout.CENTER); sp = new JScrollPane JScrollPane (informationRunwayEnglishTextField); spane.getVerticalScrollBar (). addAdjustmentListener (new myAction () ( public void adjustmentValueChanged (AdjustmentEvent ae) ( int val = ae.getValue (); String str = Integer.toString (val); field.setText (str); } }); panelRunwayStatus.add (sp); |
|
#5
| |||
| |||
| Re: Add scrollbar to JTextArea
Hello, You can take help of the following example, this is not the complete code, but will surely help you Code: TextArea txar = new JTextArea(5, 30); JScrollPane scpn = new JScrollPane(txar); ... contentPane.setPreferredSize(...); ... contentPane.add(scpn, BorderLayout.CENTER); |
|
#6
| |||
| |||
| Re: Add scrollbar to JTextArea
Hello, If you need to add a scrollbar to the Jtextarea, then here is the code to do it. This is how you can add scrollbar to it Here is the code for the same Code: JScrollPane scpn = new JScrollPane(mainConsole); scpn.setBounds(10,50,760,520); scpn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Add scrollbar to JTextArea" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scrollbar Settings | Bear 55 | Customize Desktop | 3 | 18-11-2010 04:05 AM |
| JTextArea for input text from the user | liatB | Software Development | 1 | 17-03-2010 08:37 PM |
| JTextArea class of java | Ram Bharose | Software Development | 5 | 13-02-2010 10:06 AM |
| Bolding text in a JTextArea | Kieran Blenkarne | Software Development | 3 | 09-11-2009 12:10 PM |
| How to hide the Scrollbar in Frame | Aamin | Software Development | 3 | 09-02-2009 05:46 PM |