Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6906661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:20:18+00:00 2026-05-27T08:20:18+00:00

I have ran into 2 situations already that feel like they could be solved

  • 0

I have ran into 2 situations already that feel like they could be solved if JasperReports had some kind of JRDesignElementGroup. I’ve checked the net.sf.jasperreports.engine.design. package high and low but can’t find anything like it, although I was able to find a JRDesignGroup which looks like it sort of accomplishes what I’m looking for, but I’m not very sure of that.

Here are the siutations where my issue is cropping up:

(1) Grouping multiple text fields together:
I’d like to have a report where I can print out the names and values of a bunch of metrics; something that looks like:

Name: John Smith
Email: john.smith@example.com

I was hoping to accomplish this by creating 1 JRDesignElement subclass instance, and adding it to a band in my JasperDesign object. However, after thinking it over, that setup requires 3 separate JRDesignElements: 2 JRDesignTextFields (for the metric name and value) and 1 JRDesignStaticText for the colon (“:”) and space between them.

Is there a way to append these 3 items to a group and then just add the group to a band?

(2) Group an image and its title/caption
I also would like to do the same as above, except using JRDesignImage and JRDesignStaticText elements, where the image is an image to be displayed on my report, and the static text will be a title or caption to be placed above the image.

Is there any way to append these 2 items to a group and then just add the group to a band?

If so, can anyone provide JRXML, or even more preferably, some Java examples for how to do this appending? And if not, what’s the solution/work-around?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:20:19+00:00Added an answer on May 27, 2026 at 8:20 am

    (1) Grouping multiple text fields together:

    • The first solution – using single JRDesignTextField element
        //Detail
        band = new JRDesignBand();
        band.setHeight(40);
    
        textField = new JRDesignTextField();
        textField.setX(0);
        textField.setY(0);
        textField.setWidth(200);
        textField.setHeight(40);
        textField.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
        textField.setStyle(normalStyle);
        textField.setMarkup(JRCommonText.MARKUP_HTML);
        expression = new JRDesignExpression();
        expression.setText("\"<b>Name:   </b>\" + $F{Name} + \"<br/><b>Email: </b>\" + $F{Email}");
        textField.setExpression(expression);
        textField.getLineBox().getLeftPen().setLineWidth(1);
        textField.getLineBox().getTopPen().setLineWidth(1);
        textField.getLineBox().getRightPen().setLineWidth(1);
        textField.getLineBox().setLeftPadding(10);
        band.addElement(textField);
    
        ((JRDesignSection) jasperDesign.getDetailSection()).addBand(band);
    
    • The second solution – using two JRDesignStaticText and two JRDesignTextField elements together
        //Detail
        band = new JRDesignBand();
        band.setHeight(40);
    
        JRDesignStaticText staticText = new JRDesignStaticText();
        staticText.setX(0);
        staticText.setY(0);
        staticText.setWidth(60);
        staticText.setHeight(20);
        staticText.setMode(ModeEnum.OPAQUE);
        staticText.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
        staticText.setStyle(boldStyle);
        staticText.setText("Name: ");
        staticText.getLineBox().getLeftPen().setLineWidth(1);
        staticText.getLineBox().getTopPen().setLineWidth(1);
        staticText.getLineBox().setLeftPadding(10);
        band.addElement(staticText);
    
        textField = new JRDesignTextField();
        textField.setX(60);
        textField.setY(0);
        textField.setWidth(200);
        textField.setHeight(20);
        textField.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
        textField.setStyle(normalStyle);
        expression = new JRDesignExpression();
        expression.setText("$F{Name}");
        textField.setExpression(expression);
        textField.getLineBox().getTopPen().setLineWidth(1);
        textField.getLineBox().getRightPen().setLineWidth(1);
        textField.getLineBox().setLeftPadding(10);
        band.addElement(textField);
    
        staticText = new JRDesignStaticText();
        staticText.setX(0);
        staticText.setY(20);
        staticText.setWidth(60);
        staticText.setHeight(20);
        staticText.setMode(ModeEnum.OPAQUE);
        staticText.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
        staticText.setStyle(boldStyle);
        staticText.setText("Email: ");
        staticText.getLineBox().getLeftPen().setLineWidth(1);
        staticText.getLineBox().getBottomPen().setLineWidth(1);
        staticText.getLineBox().setLeftPadding(10);
        band.addElement(staticText);
    
        textField = new JRDesignTextField();
        textField.setStretchWithOverflow(true);
        textField.setX(60);
        textField.setY(20);
        textField.setWidth(200);
        textField.setHeight(20);
        textField.setPositionType(PositionTypeEnum.FLOAT);
        textField.setStyle(normalStyle);
        expression = new JRDesignExpression();
        expression.setText("$F{Email}");
        textField.setExpression(expression);
        textField.getLineBox().getRightPen().setLineWidth(1);
        textField.getLineBox().getBottomPen().setLineWidth(1);
        textField.getLineBox().setLeftPadding(10);
        band.addElement(textField);
    
        ((JRDesignSection) jasperDesign.getDetailSection()).addBand(band);
    

    (2) Group an image and its title/caption

    Using three JRDesignImage and single JRDesignStaticText elements

        band = new JRDesignBand();
        band.setHeight(110);
    
        String imgPath1 = "\"jasperreports.png\"";
        String imgPath2 = "\"js_logo.png\"";
        int img1Width = 105;
        int img2Width = 200;
        int distance = 20;
    
        expression = new JRDesignExpression();
        expression.setText(imgPath1);
    
        JRDesignImage image = new JRDesignImage(jasperDesign);
        image.setX(0);
        image.setY(0);
        image.setWidth(img1Width);
        image.setHeight(26);
        image.setScaleImage(ScaleImageEnum.FILL_FRAME);
        image.setExpression(expression);
    
        band.addElement(image);
    
        expression = new JRDesignExpression();
        expression.setText(imgPath2);
    
        image = new JRDesignImage(jasperDesign);
        image.setX(distance + img1Width);
        image.setY(0);
        image.setWidth(img2Width);
        image.setHeight(87);
        image.setScaleImage(ScaleImageEnum.FILL_FRAME);
        image.setExpression(expression);
    
        band.addElement(image);
    
        expression = new JRDesignExpression();
        expression.setText(imgPath1);
    
        image = new JRDesignImage(jasperDesign);
        image.setX(2*distance + img1Width + img2Width);
        image.setY(0);
        image.setWidth(img1Width);
        image.setHeight(26);
        image.setScaleImage(ScaleImageEnum.FILL_FRAME);
        image.setExpression(expression);
    
        band.addElement(image);
    
        JRDesignStaticText staticText = new JRDesignStaticText();
        staticText.setX(200);
        staticText.setY(90);
        staticText.setWidth(60);
        staticText.setHeight(20);
        staticText.setMode(ModeEnum.OPAQUE);
        staticText.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
        staticText.setStyle(boldStyle);
        staticText.setText("The title above images");
    
        band.addElement(staticText);
    
        ((JRDesignSection) jasperDesign.getDetailSection()).addBand(band);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ran into an issue with a class; I have a class that looks like:
I've been working on optimizing a query and have ran into a situation that's
I ran into an interesting dilemma today. I have a function that handles information
Today I ran into the following problem with NUnit. I have a class, that
I have ran into a problem that i suspect has to do painting/drawing elements
I would like to use the universal code and have ran into difficulties getting
I have several times ran into the same problem, and I would like to
I ran into this situation today. I have an object which I'm testing for
I have ran into an interesting issue while trying to create a more usable
Currently developing a PHP framework and have ran into my first problem. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.