How to display multiple paragraphs

Hi, I cannot find any tutorials about displaying multiple paragraphs in a Canvas. All the tutorials only print a certain paragraph. When I added a "\n" in the text, it also does not print on the next line. This is the code I used:
String sentence = "The quick brown fox \n\n\njumps over the lazy dog.";
Graphics2D g = (Graphics2D) graphics;
          LineBreakMeasurer linebreaker = new LineBreakMeasurer(new AttributedString(sentence)
          .getIterator(), g.getFontRenderContext());
          int y = 5;
          while (linebreaker.getPosition() < sentence.length()) {
               TextLayout textLayout = linebreaker.nextLayout(300);
               y += textLayout.getAscent() + 5;
               textLayout.draw(g, 5, y);
               y += textLayout.getDescent() + textLayout.getLeading();
          }This prints
The quick brown fox jumps over the lazy dog.but what I expect is
The quick brown fox
jumps over the lazy dog.Can someone help me please. Thanks!

Hi,
I went through the API documentation for the java.awt.font.LineBreakMeasurer and I have found two examples at the class API level; Please do read the api again with the example which gives a good details of the class and especially with displaying a paragraph inside a component.
LineBreakMeasure
Regards,
Alan Mehio
London, UK

Similar Messages

  • How to Display multiple records in Table in VC without using BAPI.

    Hi All,
    I am working on Visual composer (NW2004s SP10). I am trying to display Poitems from BAPI_PO_GETDETAIL. I am creating my front end using VC. I have created one form and one Table where I want to display POItems. I am writing my logic of retrieving data from BAPI in CAF.I am connecting them in Guided procedures.When I run my process in Guided Procedures I am getting single row displayed in table. Can Anyone help me how to display multiple rows in table.
    Regards,
    Sheetal

    Hi Sheetal,
    if the BAPI returns a table, then you get multiple rows. From which system is the BAPI, so that I can check the BAPI to give you further information.
    Best Regards,
    marcel

  • How to display multiple attachments in UWL item in portal?

    HI,
    How to display multiple attachments in UWL item in portal?
    I want to display more than one attachment in UWL body,present its dispalying one attachment.
    Pls help on this
    Thanks,
    Bheem
    Edited by: v bheem on Aug 4, 2009 3:10 PM

    Hi,
    Are you able to manage this! Pls do let us know if you have done any configuration changes!

  • How to display multiple thumbnail images in jframe

    hi
    please help me about how to display multiple thumbnail images in jframe

    Multi post:
    http://forum.java.sun.com/thread.jspa?threadID=627253&messageID=3588990

  • How to display multiple tables from database using netbeans swing gui

    plz reply asap on how to display multiple tables from database using netbeans swing gui into the same project

    Layered Pane with JTables or you can easily to it with a little scripting and HTML.
    plzzzzzzzzzzzzzzzzz, do not use SMS speak when posting.

  • How to display multiple reports at the same time

    Hi,
    I'm trying to display multiple reports at the same time, each one in separates tabs or windows using Forms 11g 11.1.1.6
    I have a button which has a call to a procedure which makes use of rp2rro library to show the specific reports, for example:
    call_report('report1');
    call_report('report2');
    call_report('report3');
    call_report('report4');
    The main problem is that, just the last report is been displayed.
    Is there some way to display report1, report2 etc in separate tabs or windows ??
    Regards
    Carlos

    You shouldn't have a problem calling different reports at once. As long as you're using Forms 11g they show up in different windows.
    The question is how you are calling the report.
    Here is how I manipulate it.
    After I pass parameters with the ADD_PARAMETER built-in I set some key values (destype, desformat, desname) with the RP2RRO's procedures.
    Finally calling RP2RRO.RP2RRO_RUN_PRODUCT and then WEB.SHOW_DOCUMENT passing the correct procedure parameters the report comes up in a window. If you repeat the above changing the appropriate variables (the report_name in the RP2RRO_RUN_PRODUCT and so on) you can get multiple reports in different windows.

  • How to display multiple categories of webapp items in list view? Changing listbox list to checkbox list to select category in submission process?

    Hello!
    1.
    I am trying to get my page to list webapp items that are part of a few categories. I understand that if i want to view only one category, I just need to do the normal process of choosing that category and placing it out. So my question is: How do I display multiple categories of items in a webapp in a single page. I've tried this
    {module_webapps,WEBAPP_ID,c,CATEGORY_ID1,,,,10,,1} {module_webapps,WEBAPP_ID,c,CATEGORY_ID2,,,,10,,1}
    This only displays the everything from the first category, then everything from the next, which will not make it in order of date.
    I've also tried this for fun:
    {module_webapps,WEBAPP_ID,c,CATEGORY_ID1&CATEGORY_ID2,,,,10,,1}
    How can I go about doing it?
    2.
    I am looking to allow users to input a webapp item and allow them to select a category to tie to that item.
    <label for="CAT_Category">Category (You may select more than 1)<span class="req">*</span></label>
        <select name="CAT_Category" id="CAT_Category" class="cat_listbox" rows="4" multiple="multiple" style="height: 60px;">
        <option value="CATEGORY_ID1">--- Option 1</option>
        <option value="CATEGORY_ID2">--- Option 2</option>
        </select>
    Is it possible for me to change the listbox style into a checkbox style such that the user doesn't have to control+click multiple options?

    No answer to No.1 but I really want to find it out too.
    No.2 
    If you already know list of the categories & ID you can manually create a list of checkboxes
    <input type="checkbox" name="CAT_Category" value="89081" />
    <input type="checkbox" name="CAT_Category" value="89082" />
    <input type="checkbox" name="CAT_Category" value="89083" />
    something like that should work

  • How to display multiple selected rows in a table inside a popup?

    Hi,
    I have a table on which multiple selection is enabled. I am able to get hold of multiple selected rows i.e. i am able to iterate over the selected row keys and print their values. Now, my problem is how to display the contents of all the selected rows in a popup? I get the details of only one row when I launch the popup.
    Thanks
    Karan

    Hi,
    Not confident if this works or not but just try it...
    1. create a ViewLink between the same view Object.
    The source and destination wil be the same Vo and the source and destination attribute will be the pk of both Vos.
    2. Update the changes in Appln Module.
    Open the AM and in DataModel tab .
    select the Same VO from which you created table in the DataModel Listbox and select the VL in the "Avaible View Objects" List Box. Add under it(selected vo in datamodel listbox).
    3. Refresh DataControl accordion.
    4. in your jsff page drag and drop the child vo as a table..
    See if it works
    Regards,
    Santosh.

  • How to display multiple page images in forms ?

    Hi,
    What is the best method to display multiple pages image(100 pages) in forms 10g?
    Thanks

    Hello,
    <p>this is a link to a tutorial that contains several sample forms.<br> One of them (ALBUM.FMB) demonstrates how to display hundred of images.<br><br>The tutorial is in French, but you can simply download the samples on the introduction chapter</p>Francois

  • How to display multiple clocks in menu bar?

    Is there an app that can display multiple clocks in different time zones, side by side, like the regular system clock?
    http://d.pr/i/P6Zr

    Does this come close enough?
    https://itunes.apple.com/gb/app/clocks/id414554506?mt=12
    Found at…
    http://www.cultofmac.com/165298/set-up-multiple-world-clocks-in-menu-bar-os-x-ti ps/
    Don't forget you can add multiple clock widgets to Dashboard, and the info icon will allow you to set the location/ timezone.
    This will give you a dashboard overview…
    http://mac.appstorm.net/how-to/using-dashboard-in-2013/

  • HT201300 how activation display multiples in macbook pro 13

    how activation arrange multiple display

    Hi pattyufita,
    Depending on what model of MacBook Pro you have, you will need the correct adapter for its video out port. Also, the other end of the adapter would need to fit whatever video in port your TV has. So for example the most recent MacBook Pro has Thunderbolt for video out and your TV might use HDMI video. See the specifications on this page for the MacBook Pro -
    Apple - MacBook Pro with Retina display - Technical Specifications
    http://www.apple.com/macbook-pro/specs-retina/
    Of course you will need to find the specifications for your own model of MacBook Pro. You can find out which model you have by going to the Apple menu and selecting About this Mac and clicking the More Info button.
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • Hi , How to display multiple images

    hi,
    please help me out!
    I need to display multiple images on the jframe or on a jpanel . From the database where the path of the images are stored how to do it any one please
    give the code

    import java.awt.*;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class ShowingImages extends JPanel
        final int
            WIDTH  = 75,
            HEIGHT = 125;
        public ShowingImages()
            String[] filePaths = getPaths();
            BufferedImage[] images = getImages(filePaths);
            setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(5,5,5,5);
            gbc.weighty = 1.0;
            gbc.weightx = 1.0;
            loadImages(images, gbc);
        private void loadImages(BufferedImage[] images, GridBagConstraints gbc)
            for(int j = 0; j < images.length; j++)
                BufferedImage scaled = scale(images[j], WIDTH, HEIGHT);
                ImageIcon icon = new ImageIcon(scaled);
                if(j % 2 == 0)
                    gbc.gridwidth = GridBagConstraints.RELATIVE;
                else
                    gbc.gridwidth = GridBagConstraints.REMAINDER;
                add(new JLabel(icon), gbc);
        private String[] getPaths()
            String[] fileNames = {
                "images/redfox.jpg", "images/greathornedowl.jpg",
                "images/bclynx.jpg", "images/mtngoat.jpg"
            return fileNames;
        private BufferedImage[] getImages(String[] fileNames)
            BufferedImage[] images = new BufferedImage[fileNames.length];
            for(int j = 0; j < fileNames.length; j++)
                images[j] = loadImage(fileNames[j]);
            return images;
        private BufferedImage loadImage(String fileName)
            BufferedImage image = null;
            try
                URL url = new URL("file:" + fileName);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.err.println("malformed url for image: " + mue.getMessage());
            catch(IOException ioe)
                System.err.println("unable to read image file: " + ioe.getMessage());
            return image;
        private BufferedImage scale(BufferedImage source, int w, int h)
            BufferedImage scaled = new BufferedImage(w, h, source.getType());
            Graphics2D g2 = scaled.createGraphics();
            g2.setPaint(getBackground());          // background for
            g2.fillRect(0,0,w,h);                  //   scale to fit
            double width = source.getWidth();
            double height = source.getHeight();
            double xScale = w / width;
            double yScale = h / height;
            double scale = Math.min(xScale, yScale);      // scale to fit
            //double scale = Math.max(xScale, yScale);    // scale to fill
            double x = (w - scale*width)/2;
            double y = (h - scale*height)/2;
            AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
            g2.translate(x, y);
            g2.drawRenderedImage(source, at);
            g2.dispose();
            return scaled;
        public static void main(String[] args)
            // create and configure your JFrame here...
            f.getContentPane().add(new JScrollPane(new ShowingImages()));
    }

  • Crystal report -How to display multiple lines in line chart?

    Hi,
    M struggling to display multiple lines in line chart. All the values m fetching it from database into data table in below format & data type
    Category(String).....year(Int).....graph_values(Int).....table_value(String)
    Test.........................2006.......... -100............................(100)
    Avg..........................2006..........20................................20
    Median......................2006...........5................................5
    Test..........................2007...........500.............................500
    Avg...........................2007............90..............................90
    Median.......................2007............45..............................45
    M using cross tab to display data and chart to plot line. Following fields I used in Cross tab Expert & Chart expert
    Cross tab expert-
    Rows u2013 category
    Columns u2013 year
    Summarized fields u2013 Min of table_value
    In Chart Expert u2013
    On Change of - Year
    Show values - graph values
    In cross tab m able to see the data properly but not in graph.I have three categories. Hence it should plot three lines in line chart but m able to see only one line for test category.
    FYI u2013 using VS 2008 and crystal report assembly version 10.5
    Urgent. Please reply soon.
    Thanks
    ThakurS

    I got the solution.
    In Chart Expert - I should use
    On Change of -- Year, Category
    Show values -- graph values
    Thanks,
    ThakurS

  • How to display multiple lines in a text box defined in  steploop.

    Hi,
    I have a requirement to display data ( which is dynamic in nature. I determine data type,length etc dynamically) in a table format. I am using step loop for the same. I am facing a problem. Some field can be as long as 256 char long. Is there  any way to display multiple lines in text box defined in a step loop so that I can display the complete string as one entity.
    I can't use custom control as custom control can't be defined in a step loop or table controlI would really appreciate your help on this.
    Regards,
    Sanjeev

    Hello Sanjeev
    Perhaps it is possible to use a <b>mixed strategy</b> consisting of a classical table control (or, even better, an ALV grid list) where you display the first 250 character of the data and next to the table control you place a simple textedit control. When the user selects one of the text fragments in the table control the entire text will be displayed in the textedit control.
    Regards
      Uwe

  • How to display multiple records in smart forms in new page for each record

    Hi,
              How to display the data from a internal table in a smart form.
    I want each record to be displayed in seperate page.
    please tell me with example.
    thank u,
    Sarath

    Do this ,
       in the main window - open a loop on your internal table ,
    within the loop open the text and give the output fields,
    after this text  use the Command node and in this set the next page as page1,
    so when the loop gets executed its first record will be on the first page and the second record will be on the next page and so on ..
    Reward to usefull answers.

Maybe you are looking for