Creating/printing dynamically-sized, detail report ....


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Creating/printing dynamically-sized, detail report ....

  1. #1
    George Guest

    Creating/printing dynamically-sized, detail report ....


    This is such a basic business question that I'm surprised I haven't seen it
    as an example in one of the texts..
    I need to create and print a report. The report will have a header and subheader/column
    titles for the columns of detail-line data.

    The number of detail lines will vary, so a jTable on a JScrollPane will dynamically
    grow/shrink as the number of detail lines change. Problem is, I don't know
    how to resize the columns; one column is the date (MM/DD/YY - 8 char.), the
    next column is name (39 char.), my tables always have the same size columns
    - Not good. I've tried using a JList, but it looks somewhat clumsy and there
    must be a better/standard way.

    Additionally, I will be printing the above report on a Canon BJC-80 and BJC-85
    printer. I am only familiar with printing a string of ASCII char. and the
    width of the report is 200 char. Problem is, the printers only prints portrait
    (only 80 char. width), not landscape.
    Is there an escape sequence for either:
    1)changing the font of the printed char (if small enough, I can fit all

    200 char. on one line, even if it is portrait orientation).
    2)changing the orientation from portrait to landscape.

    Any thoughts would be appreciated,

    George

  2. #2
    Paul Clapham Guest

    Re: Creating/printing dynamically-sized, detail report ....

    You could go through half a dozen Java texts without encountering the word
    "business". However, here's a piece of code from a class I wrote (that
    extends JTable), for changing column widths:

    TableColumn col = null;
    for (int i = 0; i < 3; i++) {
    col = getColumnModel().getColumn(i);
    col.setPreferredWidth((i<2 ? 30 : 250));
    }

    Of course you could set your preferred widths to whatever you liked for each
    column. But I found this doesn't actually set the widths to what the
    program says. Apparently JTable does some kind of scaling or something that
    makes the columns fit the width of whatever container it's in, so the result
    isn't exact.

    Can't advise you on printing, I've never done any from Java.

    PC2

    "George" <gkozel@allstate.com> wrote in message
    news:3ad4a9a8$1@news.devx.com...
    >
    > This is such a basic business question that I'm surprised I haven't seen

    it
    > as an example in one of the texts..
    > I need to create and print a report. The report will have a header and

    subheader/column
    > titles for the columns of detail-line data.
    >
    > The number of detail lines will vary, so a jTable on a JScrollPane will

    dynamically
    > grow/shrink as the number of detail lines change. Problem is, I don't

    know
    > how to resize the columns; one column is the date (MM/DD/YY - 8 char.),

    the
    > next column is name (39 char.), my tables always have the same size

    columns
    > - Not good. I've tried using a JList, but it looks somewhat clumsy and

    there
    > must be a better/standard way.
    >
    > Additionally, I will be printing the above report on a Canon BJC-80 and

    BJC-85
    > printer. I am only familiar with printing a string of ASCII char. and the
    > width of the report is 200 char. Problem is, the printers only prints

    portrait
    > (only 80 char. width), not landscape.
    > Is there an escape sequence for either:
    > 1)changing the font of the printed char (if small enough, I can fit all
    >
    > 200 char. on one line, even if it is portrait orientation).
    > 2)changing the orientation from portrait to landscape.
    >
    > Any thoughts would be appreciated,
    >
    > George




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center