JTextArea Formatting Questions

How can I add a Scroll Bar to the JTextArea in the following code, I have tried adding it, as one can see below, however no matter what I seem to change, the scroll bar does not appear. If anyone could help me I'd grealtly appreciate it.
public class CardLayoutDemo extends JTextArea implements ItemListener {
JPanel cards; //a panel that uses CardLayout
final static String BUTTONPANEL = "JPanel with JButtons";
final static String TEXTPANEL = "JPanel with JTextField";
public void addComponentToPane(Container pane) {
//Put the JComboBox in a JPanel to get a nicer look.
JPanel comboBoxPane = new JPanel(); //use FlowLayout
String comboBoxItems[] = { BUTTONPANEL, TEXTPANEL };
JComboBox cb = new JComboBox(comboBoxItems);
//Create the "cards".
JPanel card1 = new JPanel();
card1.add(new JButton("Button 1"));
card1.add(new JButton("Button 2"));
card1.add(new JButton("Button 3"));
JPanel card2 = new JPanel();
String text = "This is just jibberish to see whether the scroll function will work, \n"+
     "This is just jibberish to see whether the scroll function will work, \n"+
     "This is just jibberish to see whether the scroll function will work, \n"+
"This is just jibberish to see whether the scroll function will work, \n"+
     "This is just jibberish to see whether the scroll function will work, \n"+
     "This is just jibberish to see whether the scroll function will work, \n";
JTextArea textArea = new JTextArea (text);
JScrollPane scrollPane = new JScrollPane(textArea);
//Create the panel that contains the "cards".
cards = new JPanel(new CardLayout());
cards.add(card1, BUTTONPANEL);
cards.add(card2, TEXTPANEL);
pane.add(comboBoxPane, BorderLayout.PAGE_START);
pane.add(cards, BorderLayout.CENTER);
public void itemStateChanged(ItemEvent evt) {
CardLayout cl = (CardLayout)(cards.getLayout());
cl.show(cards, (String)evt.getItem());
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
//Create and set up the window.
JFrame frame = new JFrame("CardLayoutDemo");
//Create and set up the content pane.
CardLayoutDemo demo = new CardLayoutDemo();
//Display the window.
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {

JScrollPane scrollPane = new JScrollPane(textArea);
card2.add(textArea);This is messed up. I think you wanted to add the text-area-in-a-scroll-pane to card2 and not to "this". Try doing that instead:JScrollPane scrollPane = new JScrollPane(textArea);

Similar Messages

  • Landscape formatting question

    Can anyone help me with a formatting question? I have a number of PDFs that are landscape format. Every time I open them they default to portrait, even when I change orientation in page set-up and re-save...

    You are only changing the view, not the pdf. Use the Rotate command in the Document menu, not the view menu.

  • Locale Formatting question

    Locale Formatting question
    In the preceding code the number 50 represent currency.
    The output of NumberFormat is 50 with the local symbol
    The output of DecimalFormat is 50.00 without the local symbol
    The question is how to show 50.00 with the local symbol ???
    import java.text.*;
    import java.math.BigDecimal;
    public class LocalFormating {
    public static void main(String[] args) {
    NumberFormat nf = NumberFormat.getCurrencyInstance();
    DecimalFormat decfs = new DecimalFormat("#,##0.00");
    BigDecimal anumb = new BigDecimal(50);
    String temp = nf.format(anumb);
    System.out.println("local anumb = " +temp);
    String temp2 = decfs.format(anumb);
    System.out.println("Decimal format anumb = " +temp2);

    Locale Formatting question
    In the preceding code the number 50 represent currency.
    The output of NumberFormat is 50 with the local symbol
    The output of DecimalFormat is 50.00 without the local symbol
    The question is how to show 50.00 with the local symbol ???
    import java.text.*;
    import java.math.BigDecimal;
    public class LocalFormating {
    public static void main(String[] args) {
    NumberFormat nf = NumberFormat.getCurrencyInstance();
    DecimalFormat decfs = new DecimalFormat("#,##0.00");
    BigDecimal anumb = new BigDecimal(50);
    String temp = nf.format(anumb);
    System.out.println("local anumb = " +temp);
    String temp2 = decfs.format(anumb);
    System.out.println("Decimal format anumb = " +temp2);

  • Cascading lookup format questions

    Hi everyone,
       I have a couple of questions regarding formatting the cascading look up fields.  I have a list that filters classes and mnemonics by educator which works fine however on the entry form, when the "Educators" drop down menu is changed,
    a secondary description box appears. The question is, how do I get rid of that secondary description box?
    The second formatting question is that when I have filled out the form, on the edit entry form, there is a hyperlink to the list that the cascading lookup is using as a reference. How do I get rid of that link? See image 002 below

    It's not easy to understand the question, please attach the image here.
    if you mean to achieve a cascade lookup in SharePoint new/edit form, after selecting one column, the cascaded column below will show with filtered value, otherwise, the column is hidden, you may consider to use JavaScript/JQuery to show/hide the second column,
    following is an article about how to use cascaded lookup in SharePoint:
    Qiao Wei <br/> My blog:http://blog.goobol.com

  • Adding loops and loops format question

    Hi, i've been facing difficulties adding loops into my GB. My problem is: "Loops do not appear in my loop browser nor the loop list from the silver loop bar above the browser".
    Yes, forgive me for asking this repeated question but after checking the help tutorial, my personal GB guide books, and even HangTime's FAQ, sadly, i still dont find any answers.
    Generally, the procedure is pretty simple from all the sources i've read. Simply drag the folder or loops into the browser and thats DONE right? I did exactly what it said but sigh...maybe there's something wrong with my Macbook?
    For your information, all the loops that i've been adding are loops from CDs coupled with FutureMusic and ComputerMusic magazines, so i believe the sources are pretty reliable i hope.
    As i was struggling to add the loops, this msg popped up for the first time; "Loops that are not in Apple format will not be added into GB"
    So, is the loop format the main cause of my problem?
    if yes, is there any way to convert the format? what is the procedure?
    ps: My current status is, some loops i added are in my browser while some dont although they exist in User/Library/Audio/AppleLoops/UserLoops.
    Thank you in advance.

    So, is the loop format the main cause of my problem?
    if yes, is there any way to convert the format? what is the procedure?
    apple's loop utility:
    also note:

  • Converting from PDF directly to Java Objects/XML (and PDF format questions)

    I posted this originally in the Acrobat Windows forums but was told I might have more luck here, so here goes:
    I am desperately trying to find a tool (preferably open source but commercial is fine also) that will sit on top of a PDF and allow me to query it's text for content and formatting (I don't care about images). I have found some tools that get me part of the way there, but nothing that seems to provide an end-to-end solution but is quite lightweight. My main question is WHY are there so many tools that go from PDF to RTF, and many tools that go from RTF to XML, but NONE that I can find that go PDF to XML.
    To clarify, by formatting I simply mean whether a line/block of text is bold/italic, and its font size. I am not concerned with exact position on the page. The background is that I will be searching PDFs and assigning importance to whether text is a heading/bodytext etc. We already have a search tool in place so implementing a pure PDF search engine is not an option. I need a lightweight tool that simply allows me to either make calls directly to the PDF OR converts to XML which I can parse.
    Some tools I have tried:
    1) PDFBox (Java Library) - Allows the extraction of text content easily, but doesn't seem to have good support for formatting.
    2) JPedal (Java Library) - Allows extraction of text content easily, and supports formatting IF XML structured data is in the PDF (not the case for my data).
    3)  Nitro PDF (Tool) + RTF to XML (script) - This works quite nicely and shows that PDF to XML is possible, but why do I have to use 2 tools? Also, these are not libraries I can integrate into my app.
    4) iText (Java Library) - Seems great at creating PDFs but poor at extracting content.
    I don't really expect someone to give me a perfect solution (although that would be nice!).
    Instead, what I'd like to know is WHY tools support PDF to RTF/Word/whatever retaining formatting, and other tools support RTF to XML with the formatting information retained. What is it about PDF and RTF/Word that makes it feasible to convert that way, but not to XML. Also, as I found in 3) above, it is perfectly feasible to end up as XML from PDF, so why do no tools support this reliably!
    Many thanks for any advice from PDF gurus.

    XML doesn't mean anything - it's just a generic concept for structuring
    information.  You need a specific GRAMMAR of XML to mean anything.  So what
    grammar would you use?  Something standard?  Make up your own?
    However, there are a number of commercial and open source products that can
    convert PDF to various XML grammars - SVG, ABW, and various custom grammars.
    But the other thing you need to understand is that most PDF files do not
    have any structure associated with them (as you saw when using JPEDAL).  As
    such, any concepts of paragraphs/sections/tables/etc. Are WILD GUESSES by
    the software in question.

  • And a partition in a pear tree...format question

    Well, I've spent almost an hour of my life I won't get back. Trying to archive an iDVD project (33gb) from internal hard drive to new Lacie 160g external. Keep getting "Error in archiving project" message. Even though I was able to copy some large folders onto the drive, with no problem, iDVD doesn't like that the drive is apparently formatted to FAT. I assume. Whatever. Okay, I'll play: I'm ready to reformat the drive. Understand HOW....but that's not the question....
    "You can choose up to eight partitions." Okay, Eight. How about seven? Why not 1,000? How do I, as the APPLE tech support docs says, "choose the number of partitions I want" if I don't have a clue as to why I am choosing them. I figured two would be good enough. So, any help would be appreciated (I've copied the files back over to what's left of the hard drive so I can format now with impunity. I hope this solves the "you can't get there from here after spending more time and money" message. All I want to do is archive the files so I can get 155gb of the 160gb hard drive back. And understand "choose the number of partitions you want" and run the disk utility instruction.

    Hi TuckerdogAVL
    What you need to do is partition the drive in Mac OS extended for it to work with iDVD6.
    Go to applications>Utilities>Apple's DU
    The procedure might look something like this:
    Click Here
    Hope this is Helpful.
    P.S. I like the title to your Post! (Merry X-mas).

  • Photo format question

    Newbie question: when designing an ID document (let's say ID CS4, since that's what I'm using), is there any difference in placing a Photshop image (.ps) versus a .TIF file? I've done both. And is there any harm in using high-res .JPG's? I have a friend who works in Quark and he always changes every photo to .TIF before placing. Thanks.

    Resizing is a different issue altogether from format.
    It's safe to scale the image in ID regardless of the format. If you look in the info panel with the image selected you'll see two resolution numbers listed, actual and effective. Actual is just the resolution at the dimensions the image was saved and is essentially irrelevant. Effective resolution is what you have at the dimensions you are currently using, and that's the number that counts. If that number is in the range that is acceptable for the type of output you are using, there is no need to resize the image in Photoshop at all.
    If you MUST resize the image, then yes, convert to something besides jpeg if that's what it is to start. And keep in mind that up-sampling won't improve image quality in general, and downsampling more than 20% or so can cause you to lose fine details (but so will scaling down).

  • Apple mail formatting Question

    I just bought a MBAir and in using Apple mail I cannot seem to format email replies to contain an extra two lines of blank space above the original email.  Is there a way to format email replies to do this automatically?

    What is the question? The reference to the system administrator, is more in reference to how the IMAP server is configured. Does this IMAP work, as expected?

  • Script format question: Title over

    Question: In the script format when using a "TITLE OVER" is it a General, Shot or an Action format. Appreciate any input here, thanks.

    It a good question, as it is worth thinking how the elements in our screenplays will be used down the line. So for example, although the formatting of making it a Shot certainly would put TITLE OVER in caps, and making it Action would allow the paragraph it is in to be lower and upper case, it better to think how the elements may be used as metadata when you move on from writing, rather than how they look on the page. The tags and elements will be used by others in many different ways as the script moves through the planning and shooting steps.
    Shot elements will be processed by an application like Adobe OnLocation which will create a placeholder shot for it for the shoot. That could be theoretically correct in this case as the title will need to be shot. However to answer your question I think General is the appropriate element, just as the Title and Author are General on the titlle page.
    Are there other elements of the screenplay that will need to be tagged in special ways so they are available as the right kind of metadata later in the production process?

  • JFileChooser and date format questions

    I have a JFileChooser that currently works - I set the default directory and allow the user to select a file or enter a file name.
    I have been asked to modify this to prepopulate the file name field on the JFileChooser.
    How do I do that? It is not obvious which method to call to set the filename field.
    Also, the file name needs to be a timestamp "*yyyyMMddHHmmss*.dat"
    I tried creating the timestamp part with the following code, but it does not format as expected.
            String s = "";
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddddHHmmss");
                java.util.Date now = new java.util.Date();
                java.util.Date dat = dateFormat.parse( now.toString() );
                s = dat.toString();
            }What is wrong with this?

    I don't do Swing and this is also not the subforum for Swing questions. It has its own subforum.

  • PDA Formatting questions ...

    APEX 2.2 - I know, I know, we're working on the upgrade, they say 'soon'.
    Oracle 10gR2 on the database side
    I'm trying to format an APEX application to fit on a PDA screen even though the PDA hasn't been selected yet, I'm using a Symbol scanner running Windows CE as a test bed.
    The application runs OK but there are still some blank lines that I can't seem to get rid of.
    Here are a couple of questions:
    1- Can I change the height of the text and item fields on the screen?
    2- How can I get rid of the Region/Page name and reclaim that space?
    3- I have 2 buttons at the bottom that appear side-by-side on my PC but are on top of each other on the PDA, can't find out why?
    4- Is there a way to put a 2nd label (or free text area) for an item to the right of it?
    I'm pretty newbie-ish at this so please be gentle with your suggestions! ;-)>
    Thanks very much! APEX rocks!

    Dimitri, et al
    I've done as much as I can with the version of APEX I'm currently using, thanks for the suggestions.
    I now need to know how to initiate the scanning function on the scanner. I'm using a Symbol NC9060 to test but it looks like we'll be using NC9090 for Production. I believe the NC9060 is running Windows CE and the NC9090 is running Windows Mobile 6.
    Is there a function code I need to send to the scanner before we start the application? If so, is that done through APEX or some program outside?
    We'd obviously like to use the scanning function to gather barcode information as input.
    Thanks in advance for any assistance.

  • CFMAIL formatting question

    I'm sending out a email using CFMAIL, but have noticed that
    the formatting
    gets all screwed up in places like Hotmail.
    What is the best type of formatting options to pick? I have
    the options set
    as shown below:
    <cfmail from="[email protected]"
    bcc="[email protected]"
    subject="Requested fencing information"
    failto="[email protected]"
    replyto="[email protected]">
    And the the actual mail is being sent as:
    Dear #user1#,<br>
    <p>Thanks for requesting fencing
    <p>Your requested information has been attached to
    this email in the
    form of a ZIP file. You will need a program such as PKZIP or
    WinZIP to
    decompress the attachment. The programs listed above can be
    obtained from
    <a href="
    or from <a href="
    if not already
    installed on your computer.</p>
    <p>You have requested the following
    <cfloop list="#form.Events#" index="i">
    <cfset file1=findnocase("/",#i#,4)>
    <cfset dl_file=right(#i#, file1+2)>
    <p>We hope this information answers your questions,
    and we hope to see
    you at a fencing class soon.</p>
    Is there a better way? The message is getting all jammed
    together, no
    spacing for paragraphs, etc......

    What a pain that is!! :)
    "jdeline" <[email protected]> wrote in message
    news:f59jt7$pbu$[email protected]..
    > I've noticed the same thing at some (not all) Web mail
    sites. On one
    > application, I had to resort to sending text, not
    TYPE="html" That
    > required a
    > string to be constructed as the body of the e-mail:
    > <CFSET myBody = "Dear " & user &
    "#Chr(10)##Chr(10)#" & "Thanks for
    > requesting
    > fencing information." &Chr(10)##Chr(10)#" ... >
    > Your e-mail then looks like this:
    > <CFMAIL ... >
    > #myBody#
    > </CFMAIL>

  • Format Question - Biz Objects

    I created a report with 8 data fields; I added a 9th column and included a formula that provides a 'status' for a given line item based on the data pulled within the report.  There are three seperate statuses; I then inserted a break which now seperates my three statuses into groups by that status, which is exactly what I want.  I can't figure out out to get a 'heading' above the three groups though.  Since I created a formula for the column of 'status', it won't let me drag that column heading to 'drop here to create a section' when I am in view structure mode .  I would simply like to be able to have a static heading above each section and have scoured the options/formatting/etc.  Is that possible to do?

    New to business objects; valid question you ask.  In my 'research', it is only a dimension value that allows for the section headers, which is why I havne't been able to figure this out.  That said, I guess I am not clear on exactly what a dimension variable is or how to do that.
    To drive my status, I created the following formula in that column:
    =(If Not(IsNull([Income])) And (([Address]) <> "To Be Determined") Then "***Needs Action***" ElseIf((([Address]) = "To Be Determined")) Then "No Action - Property TBD" ElseIf(IsNull([Income])) Then "No Action - Incomplete")
    Thanks for the reply.

  • Format & Questions type - Oracle  R12: E-Business Essentials(1Z0-204)?

    Hi Guyz
    Well i am currently preparing for the exam Oracle R12: E-Business Essentials(1Z0-204), so any of u guyz have any idea of paper format & what type of questions are asked? kindly share your personal experiences of exam. Moreover the preparation strategy and which stuff or books/material u guyz used for preparation.

    Oracle E-Business Suite R12: E-Business Essentials Exam Topics are listed in the following link (I guess you already have the link):
    Oracle E-Business Suite R12: E-Business Essentials
    Recommended Training and Preparation:
    R12 Oracle E-Business Suite Essentials for Implementers
    Check the following links for practice tests:
    Oracle E-Business Suite OCP & OCE Certification
    Oracle Certification Program - Practice Test Page

Maybe you are looking for

  • Why can't I add my Yahoo mail account to my iPhone 5S?

    I cannot add my Yahoo email account to my iPhone 5S. I have searched this forum and watched videos, but to no avail. I tried the 'other' tab, using smtp, imap, etc. But I either get the 'Server Unavailable' message or 'Username and/or password is inc

  • Vista 32 Install Fails - Error 0xE0000100

    MacPro 2.66 w/ 3GB of RAM, Leopard fully updated Three internal HDD Bay 1 - 250GB Mac OSX Bay 2 - 400GB HFS+, contents deleted, designated as Vista drive Bay 3 - 500GB new, empty Vista 32 System Builder disk Upgraded to Leopard just the day before, n

  • Reader XI / AcroQTP / Win7 / QTP11 - objects not recognised

    Hi Our toolset is Reader XI / AcroQTP / Win7 / QTP11. I have selected the AcroQTP add-in in QTP and can see that it is associated with my test.  However, when I open a PDF and use the object spy I still see WinObjects. I have run the registration scr

  • Korean data is not displaying in BI system

    Hello BI Experts, Do you have any idea or some settings in BI system as korean data is not displaying in BI ODS, while source system  in correct data. Korean data is displaying # value in PSA and ODS. Thanks, Sapna

  • Goods delivery error for transfer posting

    I have created a P.O for transfer posting for a material from Plant 2000 to plant 3000.where in my account assignment I have mentioed the WBS element. created the delivery document---VL10B and outbound delivery VL01N. during PGI, system gives error t