Scrollable JTextArea problem. Tried the techniques of previous posts.

Hi guys,
I know this is a very common post on this forum. I have tried the solutions mentioned in previos posts, but somehow I am unable to make a JTextArea Scrollable.
I have written the following code :
          TAlab1 = new JTextArea(temp);
          TAlab1.setBounds(50, 130, 530, 50);
          TAlab1.setBorder(BorderFactory.createEtchedBorder() );
          TAlab1.setLineWrap(true);
          TAlab1.setEditable(false);
          jsp = new JScrollPane(TAlab1);
          p.add(jsp); // where p is JPanelHere, if I add jsp, then the JTextArea is not visible. If I add TAlab1, then I get a JTextArea, but which is not scrollable.
I would appreciate any of your assistance.
Regards
kbhatia

Calling setBounds can get you in trouble. Hardcoding values is almost always a bad idea. Here's a short demo of adding a JTextArea to a JScrollPane;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ScrollTest extends JFrame{
    private String longString = "This is just a long string to be added over and over again to textarea\n";
    int times = 0;
    private JTextArea textArea;
    public ScrollTest() {
        buildGUI();
    private void buildGUI(){
        JPanel mainPanel = (JPanel) getContentPane();
        mainPanel.setLayout(new BorderLayout());
        JPanel centerPanel = buildCenterPanel();
        mainPanel.add(centerPanel, BorderLayout.CENTER);
        JPanel buttonPanel = buildButtonPanel();
        mainPanel.add(buttonPanel, BorderLayout.SOUTH);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        pack();
        setLocationRelativeTo(null);
        setVisible(true);
    private JPanel buildButtonPanel() {
        JPanel retPanel = new JPanel();
        JButton addButton  = new JButton("Add Text");
        addButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                addText();
        retPanel.add(addButton);
        return retPanel;
    private void addText() {
        textArea.append(times+ " "+longString);
        times +=1;
    private JPanel buildCenterPanel() {
        JPanel retPanel = new JPanel(new GridLayout(1,0, 5,5));
        textArea = new JTextArea(5,10);
        textArea.setWrapStyleWord(true);
        textArea.setLineWrap(true);
        textArea.setEditable(false);
        textArea.setEnabled(false);
        JScrollPane jsp = new JScrollPane(textArea);
        retPanel.add(jsp);
        return retPanel;
    public static void main(String[] args) {
        new ScrollTest();
}Cheers
DB

Similar Messages

  • Have the same problem tried the signing in and out, rebooting, uninstalling and back again nothing is working, on 4th download of creative cloud still coming up with lightroom 5 after signing in anf out, also signing out dowloading and signing in, spent 2

    have the same problem tried the signing in and out, rebooting, uninstalling and back again nothing is working, on 4th download of creative cloud still coming up with lightroom 5 after signing in anf out, also signing out dowloading and signing in, spent 2 days on this, just cannot spend days on trying tricks and hacks

    I  am getting so mad because I cant even sign out OR quit! They are both grayed out. I have the spinning blue wheel in my apps and am trying to fix that but none of the solutions are working.

  • Pls.help my iphone stuck in recovery mode and itunes wont recognize it..i tried the other options that posted here,,,pls tell me what to do..

    pls. help my iPhone stuck in recovery mode and iTunes wont recognize it..i tried the other options that posted here,,,pls tell me what to do..before it was just stuck in an apple logo but when i tried recovery mode to itunes then it stuck..

    Hi awison,
    If your iPhone is not recognized by iTunes on your Windows computer you may want to use the steps in this article to troubleshoot -
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    This may also resolve your recovery mode issue. If it does not, use the steps in this article to resolve it -
    Use iTunes to restore your iOS device to factory settings
    http://support.apple.com/kb/HT1414
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • Problem with the text from previous year in current year appraisal (PPR)

    Hi Gurus,
    I have some problem with the text from the PPR of the previous year in the PPR current year.
    The text from the previous year have not the same displaying in the tab "previous year" of  the current year PPR.
    EXAMPLE :
    this is write in the PPR of year 2009 in Individual Targets without Incentives (tab My S-imple) :
    -Aufrechterhaltung der MA motivation, in dieser Zeit der Neuorientierung.
    -G1 Unterstüzung
    -Fachübergreifende Teamarbeit ausbauen
    Gefährdungsbeurteilung weiter führen
    -tragen von PSA einfordern
    -VI Opt.(Intervalle)
    -Azubi und Praktikanten AUsbildung unterstüzen
    and this is what I have in the PPR of 2010 in Individual Targets without Incentives (tab Previous Year's Targets):
    -Aufrechterhaltung der MA motivation, in dieser Zeit der-Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    there is the error, all the end of the text isn't displayed and the begin of the text is repeated.
    I think that this issue is created at the creation of the PPR.
    If someone have a idea he is welcom.
    thanks and regards

    Hi,
    Please follow the note:425601,
    Go to Tcode: OBA5 change the error messge into warning message. carry out the settlement and roll abck the warning message into the error message after sucessfull settlement.
    Reward points if found useful.
    Thanks!

  • I've tried all the suggestions from previous posts about error 2002f and none work for me. I am selling my macbook air so erased the drive. When I select my wireless connection the globe turns then gives me the mentioned error. Nothing seems to work. Help

    Tried changing wpa options and having no security but that doesn't work. I have talk talk fibre so connection speed no issues.  I have an external HD with back up on but I don't think that has anything on to help me here.

    Tried changing wpa options and having no security but that doesn't work. I have talk talk fibre so connection speed no issues.  I have an external HD with back up on but I don't think that has anything on to help me here.

  • Labview 7.1 crashes windows XP when using VI's saved with the 'Save for Previous Version' option available in Labview 8

    I am trying to work with a series of vi's developed in Labview 8 in Labview 7.1.  The code was saved with the 'Save for Previous Version' option available in Labview 8.  When trying to use the code in LV7.1 my entire Windows XP system locks up (cursor freezes).  Are there any ideas what's going on and how to fix this?
    Thanks for your help!
    Mike

    I have seen some problems with the save for previous option in the past. Instead of saving the entire hierarchy, try seperating the code into several different pieces and saving each piece individually. Then, see if you can open the different pieces in 7.1.
    If that doesn't help, you should post some more details, like when exactly does it lock up, does it have things like DLL calls, and maybe attach the code.
    Try to take over the world!

  • I just bought a used iMac and I'm having problems updating my apps from the app store! it shows that i am signed in, but when trying to update, the email of previous owner shows and i cannot change it! how can i fix this?

    how can i change the email from previous owner of the computer to mine?

    The first thing to do with a second-hand computer is to erase the internal drive and install a clean copy of OS X. You — not the previous owner — must do that. How you do it depends on the model, and on whether you already own another Mac. If you're not sure of the model, enter the serial number on this page. Then find the model on this page to see what OS version was originally installed.
    1a. If you don't own another Mac
    If the machine shipped with OS X 10.4 or 10.5, you need a boxed and shrink-wrapped retail Snow Leopard (OS X 10.6) installation disc from the Apple Store or a reputable reseller — not from eBay or anything of the kind. If the machine has less than 1 GB of memory, you'll need to add more in order to install 10.6. Preferably, install as much memory as it can take, according to the technical specifications.
    If the machine shipped with OS X 10.6, you need the installation media that came with it: gray installation discs, or a USB flash drive for some MacBook Air models. For early MBA models, you may need a USB optical drive or Remote Disc. You should have received the media from the previous owner, but if you didn't, order replacements from Apple. A retail disc, or the gray discs from another model, will not work.
    To boot from an optical disc or a flash drive, insert it, then reboot and hold down the C key at the startup chime. Release the key when you see the gray Apple logo on the screen.
    If the machine shipped with OS X 10.7 or later, you don't need media. It should boot into Internet Recovery mode when you hold down the key combination option-command-R at the startup chime. Release the keys when you see a spinning globe.
    1b. If you do own another Mac
    If you already own another Mac that was upgraded in the App Store to the version of OS X that you want to install, and if the new Mac is compatible with it, then you can install it. Use Recovery Disk Assistant to create a bootable USB device and boot the new Mac from it by holding down the C key at the startup chime. Alternatively, if you have a Time Machine backup of OS X 10.7.3 or later on an external hard drive (not a Time Capsule or other network device), you can boot from that by holding down the option key and selecting it from the row of icons that appears. Note that if your other Mac was never upgraded in the App Store, you can't use this method.
    2. Partition and install OS X
    If you see a lock screen when trying to boot from installation media or in Recovery mode, then a firmware password was set by the previous owner, or the machine was remotely locked via iCloud. You'll either have to contact the owner or take the machine to an Apple Store or another authorized service provider to be unlocked. You may be asked for proof of ownership.
    Launch Disk Utility and select the icon of the internal drive — not any of the volume icons nested beneath it. In thePartition tab, select the default options: a GUID partition table with one data volume in Mac OS Extended (Journaled) format. This operation will permanently remove all existing data on the drive.
    After partitioning, quit Disk Utility and run the OS X Installer. If you're installing a version of OS X acquired from the App Store, you will need the Apple ID and password that you used. When the installation is done, the system will automatically reboot into the Setup Assistant, which will prompt you to transfer the data from another Mac, its backups, or from a Windows computer. If you have any data to transfer, this is usually the best time to do it.
    Then run Software Update and install all available system updates from Apple. To upgrade to a major version of OS X newer than 10.6, get it from the Mac App Store. Note that you can't keep an upgraded version that was installed by the previous owner. He or she can't legally transfer it to you, and without the Apple ID you won't be able to update it in Software Update or reinstall, if that becomes necessary. The same goes for any App Store products that the previous owner installed — you have to repurchase them.
    3. Other issues
    If the previous owner "accepted" the bundled iLife applications (iPhoto, iMovie, and Garage Band) in the App Store so that he or she could update them, then they're irrevocably linked to that Apple ID and you won't be able to download them without buying them. Reportedly, Mac App Store Customer Service has sometimes issued redemption codes for these apps to second owners who asked.
    If the previous owner didn't deauthorize the computer in the iTunes Store under his Apple ID, you wont be able to  authorize it immediately under your ID. In that case, you'll either have to wait up to 90 days or contact iTunes Support.
    When trying to create a new iCloud account, you might get a failure message: "Account limit reached." Apple imposes a lifetime limit of three iCloud account setups per device. Erasing the device does not reset the limit. You can still use an account that was created on another device, but you won't be able to create a new one. Contact iCloud Support for more information.

  • Internet Problem - One site will load, another won't. Then mintues later, the site that previously would load won't and the one that wouldn't will. I'm also pulling up a lot of pages in all text. Pics won't load or only one will load and the rest won't...

    Several weeks ago, I began to have some very strange internet connection issues. All the lights on my modem stay on and my computer shows full wi-fi signal, but I suddenly I won't be able to load any pages. Other times, I'll be able to load pages from one site, but not another. It's not the same sites all the time though.... sometimes I'll be able to load pages from one site and not another, and then 5 minutes later it'll switch and I'll be able to load pages from the site I previously couldn't and I won't be able to load pages from the site I previously could. A lot of pages are coming up just text with no pics... and then 5 mintues later that site will load normally and another site will come up just text. It does the same thing whether I'm connecting wirelessly or via an ethernet cable. It also doesn't matter which browser I use (I've tried Safari, Chrome, and Firefox). Although, once in a while when using chrome, I get a DNS error page instead of the usual 'cannot find server'. I contacted my service provider and I'm not losing speed or dropping packets. According to them, the problem I'm having is very strange since diagnostic tests show no problems at all. Perhaps someone has run into this before and has a suggestion?

    Then if you have tried all the browsers try connecting the system to yoour router with an Ethernet cable and turn WiFi off. If you have the same problem then it more then likely after your computer, Router or modem or connection from your ISP.
    If you get good browsing with the Ethernet cable then it is either the WiFi card in your Mac or the WiFi system in your router.

  • I am have problems with firefox 5& 6. It does not display correctly. I have tried the no squint and the internal zoom. Some pages load ok, others like yahoomail, load tiny unless I zoom and then other pages have problems. Why? What else can I be doing?

    I am frustrated. With the no squint, which has a mind of its own, then some pages are fine, in others the type is too big or too small for the frames. If I use the default Firefox zoom that is no better. I have to set things for like 130 percent and am constantly having to click on the zoom and change things. I never had that with previous versions? Why can't Firefox just go back to displaying text in the correct frames at a decent size?

    I have played with all the options in no squint and the default zoom thing. My email list in yahoo remains tiny tiny, other things do not. If I enlarge that, then other things are too big. I never had this problem with older versions of firefox. I never had used any zoom features, it all sized itself correctly.
    To troubleshoot, I tried to open the same things with chrome, and it had much less of a problem sizing the type etc.
    I am kind of at my wits end here.

  • Hi im having huge problems trying to install flash for my mac 10.5 imac, iv gone through the internet and tried all of the solutions, everytime i try to install flash it says cant read the download file, or it just wont install, anybody plz help!

    hi im having huge problems trying to install flash for my mac 10.5 imac, iv gone through the internet and tried all of the solutions, everytime i try to install flash it says cant read the download file, or it just wont install, anybody plz help!
    iv unistalled flash, iv checked plug ins it just wont work,

    It would have been a great help to know precisely what Mac you have, so some of the following may not apply:
    You can check here:  http://www.adobe.com/products/flash/about/  to see which version you should install for your Mac and OS. Note that version 10,1,102,64 is the last version available to PPC Mac users*. The latest version,10.3.183.23 or later, is for Intel Macs only running Tiger or Leopard, as Adobe no longer support the PPC platform. Version 11.4.402.265 or later is for Snow Leopard onwards.
    (If you are running Mavericks: After years of fighting malware and exploits facilitated through Adobe's Flash Player, the company is taking advantage of Apple's new App Sandbox feature to restrict malicious code from running outside of Safari in OS X Mavericks.)
    * Unhelpfully, if you want the last version for PPC (G4 or G5) Macs, you need to go here:  http://kb2.adobe.com/cps/142/tn_14266.html  and scroll down to 'Archived Versions/Older Archives'. Flash Player 10.1.102.64 is the one you download. More information here:  http://kb2.adobe.com/cps/838/cpsid_83808.html
    You should first uninstall any previous version of Flash Player, using the uninstaller from here (make sure you use the correct one!):
    http://kb2.adobe.com/cps/909/cpsid_90906.html
    and also that you follow the instructions closely, such as closing ALL applications (including Safari) first before installing. You must also carry out a permission repair after installing anything from Adobe.
    After installing, reboot your Mac and relaunch Safari, then in Safari Preferences/Security enable ‘Allow Plugins’. If you are running 10.6.8 or later:
    When you have installed the latest version of Flash, relaunch Safari and test.
    If you're getting a "blocked plug-in" error, then in System Preferences… ▹ Flash Player ▹ Advanced
    click Check Now. Quit and relaunch your browser.
    You can also try these illustrated instructions from C F McBlob to perform a full "clean install", which will resolve the "Blocked Plug-in" message when trying to update via the GUI updater from Adobe.
    Use the FULL installer for 12.0.0.44:  Flash Player 12 (Mac OS X)
    And the instructons are here: Snow Leopard Clean Install.pdf
    (If you are running a PPC Mac with Flash Player 10.1.102.64 and are having problems with watching videos on FaceBook or other sites, try the following solution which fools the site into thinking that you are running the version 11.5.502.55:)
    Download this http://scriptogr.am/nordkril/post/adobe-flash-11.5-for-powerpc to your desktop, unzip it, and replace the current Flash Player plug-in which is in your main/Library/Internet Plug-Ins folder, (not the user Library). Save the old one just in case this one doesn't work.

  • I keep geting this message when trying to udate to Itunes 10.5.1 "There is a problem with the Windows Installer package. A program run as part odf the setup did not finish as expected . Contact your support prersonel or package vender"

    I keep getting this message when trying to upgrade to Itunes 10.5.1
    Driving me nuts trying to upgrade. What can I do to correct this?
    "There is a problem with the Windows Installer package.
    A program run as part odf the setup did not finish as expected .
    Contact your support prersonel or package vender"

    Yes, I had found a similar solution also.  I'm running XP Pro, SP3.  I went Control Panels/ Add-Remove programmes/apple software update/ change/ repair.  Then run the 10.5 exe.
    While the programme updated from version 8 of iTunes, my new iTunes is now a mess.  Not all of my music was in the same folder previously but it all showed up on iTunes.  Now many albums have been left out, some have only a few tracks and some have two copies of some tracks as well as having other tracks missing.  I haven't begun to work on that.

  • Problem with the Arabic vowelization in V 4.0 although we didn't face this problem with the previous versions ,so please fix it up quickly

    There is a problem with the arabic vowelization in the browser version 4.0 although we didn't face this problem with the previous versions ,so please fix it up quickly because it affects on our work

    Do you have an Arabic version of Firefox installed which isn't displaying the vowelization correctly, or are you trying to read it using an English language version?
    There are a few add-ons for Arabic which might possibly help here: [https://addons.mozilla.org/en-US/firefox/search/?q=arabic&cat=all&x=0&y=0 Arabic add-ons]

  • Select problem in the JTextArea

    Hi
    I have a problem on the select(), I am trying to select multiple lines of text in the JTextArea, but select(int start, int end) can only select single line, int end will be cut to the length of the line instead of going to the next line. Can anyone give me any advice?
    Thanks in advance

    DefaultHighlighter highlighter = (DefaultHighlighter)textArea.getHighlighter();
    highlighter.setDrawsLayeredHighlights(false);

  • I Cannot get my organizer to work for Elements 13. "A problem caused the program to stop working correctly. Windows will close the program......" is the error I get. I've uninstalled and reinstalled the program and tried various other things based on the

    I Cannot get my organizer to work for Elements 13. "A problem caused the program to stop working correctly. Windows will close the program......" is the error I get. I've uninstalled and reinstalled the program and tried various other things based on the MANY other complaints with this same issue and nothing is working. How can this problem be corrected?

    Hi,
    Which operating system are you running on?
    Are you upgrading from a previous version of Photoshop elements or is this your first?
    Are you trying to load the organizer or the editor or do both fail?
    Brian

  • I tried to reload a previously downloaded CS3 program on to my new hard drive and this is the message when I click on the english link for Mac products: HTTP ERROR: 404 /support/downloads/dlm/main.jsp RequestURI=/support/downloads/dlm/main.jsp

    I tried to reload a previously downloaded CS3 program on to my new hard drive and this is the message when I click on the english link for Mac products: HTTP ERROR: 404 /support/downloads/dlm/main.jsp RequestURI=/support/downloads/dlm/main.jsp

    Make sure you have cookies enabled for your browser.  Try using a different browser if the problem continues.

Maybe you are looking for

  • Exports from Keynote to Flash doesn't work

    I am trying to create an automatic slide show and export it as an .swf (or anything) to run on a web site and it doesn't work. For documentation of my tests go to: http://www.equalivote.com/abKeynoteExportTESTS.pdf

  • Nokia X3 02 Changing Unlock style

    I have Nokia X3 02 and it unlocks with that sliding unlock.but now i want 2 change it with a unlock that looks like a button on touch screen.i have seen that in one Nokia X3 02 mobile and i am not getting how to change unlock style.guyz help

  • 10.2 Breaks FCPX

    Beware of 10.2.  I installed it and now the Inspector is broken. No parameters show up. And Importing doesn't work.  On both my Macs.   I spent two hours on the phone with a senior Apple FCPX tech and he couldn't help.  We did everything.  Including

  • Realm of my application for identity and access

    I plan to replace Azure cloud services' provided subdomain (myapp.cloudapp.net) with our own domain, customDomain.com. I eventually find out that I cannot do that. I have to configure a custom domain name to route traffic to myapp.cloudapp.net. Why d

  • Language Not reflecting in portal sub areas

    Hi all, We have installed languages in back end ECC6.0 (SP14,Enhancement Package2). In UME we have assigned the default language to. But still its not reflecting fully in portal page. It means for example I have assigned a french language to the part