Stopping a header reloading with each page

I've had loads of conflicting advice on this one. Someone
must know surely. How do I stop a flash movie from reloading each
time a link button is clicked. In other words I just want the movie
to load once on the home page and the integrated buttons to work as
links to other html pages without the movie reloading on each
page.

well, lets start with the top one, since its an interesting
way to do things anyway.
when you look at your html file, (or asp or php) you'll be
able to see the .swf file embedded in there. If you attach
variables to the back of that using a script...
"yourflashfile.swf?VARIABLEA=yesssss"
that will pass a variable to your _root timeline called
VARIABLEA with the value of "yesssss". You can use that directly in
your html, but if you want the variable to change, you'll have to
use a script. I like to use php because its free and open source,
and very easy to find online help.
http://www.13studios.com/whatever.php?VARIABLEA=no
------ doesn't work, dont click.
Would pass your php file VARIABLEA with a value of no. So you
see we can now connect the two by using a php echo command...
<?php echo "$VARIABLEA" ?> or <?=$foo?>
can you put that jumbled mess of answer together
successfully? :D Lemme know!

Similar Messages

  • Header displaying in each page

    Hi,
    I need  header details to be displayed in each page. These header details with line items are  placed in a table  in  main window. So when line items exceed to second page and so on  then i have to display header details in each page.
    Thanks in advance.
    Regards,
    Neelima.

    Hi Chetan Gala  ,
    Thanx for that its working but now format problem after  that
    I have  to display header details in Bold . I have made a paragraph format as BOLD  but now header line in first page displaying normally and in page 2 bold. How can display In all pages as Bold for header details
    Thank in Advance
    Regards,
    Neelima

  • OCI bowser generates new session with each page load

    Here is a summary of my problem:
    I am trying to implement the SAP Open Catalog Interface (OCI) with our eCommerce software, but I am having issues with the Web browser that OCI uses.
    Our eCommerce software utilizes the browser session id to identify the user. Our issues is that the OCI browser supplies a new session id with each page load.
    The weird part is that if I open a standard instance of IE, access the site, and then access the site though OCI the same session is shared by both the OCI browser and the IE browser. The OCI browser is now able to maintain the session ID as the user browses the site.
    Thanks.

    Thank you for your quick response.
    I understand that session IDs are always unique, and should only last for as long as the instance of the browser is open.
    What I have seen happen is that the session ID will get recreated with each page load with in a single instance of the OCI browser.
    When the site is opened in OCI it logs the user in, and then redirects them to the homepage. The problem is that the load of the login page, and the load of the homepage have different session IDs. If the user then clicks on a link on the homepage that page load will again have a different page load. This causes the eCommerce system to see them as separate users.
    As I described when I open an instance of IE first it seems to work. This leads me to believe that the OCI browser can read the cookie information, but can't write or create. 
    I am trying to figure out why the OCI browser keeps generating new Session IDs.

  • How do I put the page number in my header so the header changes with every page

    I need to write a paper for my english class and I need the header to contain the page number so it changes with each consecutive page.
    I need to know ASAP! Thank you!

    Click in your header > Menu > Insert > Page Number
    Peter

  • How to show header value in each page same as Page field value.

    Hi there
    It would be very helpful if anyone could tell us how to set header value based on the page field.
    To make it more clear.. i have a field in my Rtf (which is basically a group by) so in each page it'll differ.. My Header should reflect the same as field value.
    what my understanding is header wont change for each page. but ,my requirement is something like i have to show the header which is same as one of my filed value..
    for eg:
    HEADER: ABC page-1
    Field - ABC
    HEADER:XYZ page-2
    Field - XYZ
    Regards - Vijay
    Edited by: Vijay Santhanam on 23-Oct-2008 3:51 PM

    Hi Haiye ,
    The Pointer you gave would keep Header ABC through out all the pages in report right, actually i had tried this and got same header for all pages,
    but what i need is my first page Header should be based on one of the field of Page 1, second pge Header again based on the same field, but the value may differ... (coz the page field is group by ).
    Would appreciate your help on this issue!!
    Regards - Vijay

  • Stop PSASE from downloadig with each update

    Almost everytime I start photoshopelements it tells me to update. Then, like clockwork, PSASE downloads AGAIN, after I had just uninstalled it.
    Is there any way to stop this? How can they get away with tuis?
    I assume once you use it there is no other way to get your phots. It's like outlook express.
    Can anybody recommend alternatives for Reader (you get it then too when you update) and Photoshop Elements?

    If you click on Edit, then Photoshop Services, uncheck the box that says
    automatically check for new services and updates.
    This should help.
    Cheers

  • How to stop Firefox demanding authentication for each page of the same website (IE does not do this for the same site))

    I have a website (Still being developed but at the testing stage) which works fine in IE but when viewed in Firefox It insists on authentication at every page, instead of just one login it repeats the login at every page.

    Hi,
    If it's Basic auth, please check if this happens in a [https://support.mozilla.org/en-US/kb/Managing-profiles new profile]. If it's okay, you can later [https://support.mozilla.org/en-US/kb/Recovering%20important%20data%20from%20an%20old%20profile?s=profile&r=1&e=sph&as=s copy the needed personal data] from the old profile. Firefox stores your personal data and settings in another location separate from its [http://kb.mozillazine.org/Installation_directory files/folder]. A new profile would have the default Firefox settings ('''Tools''' ('''Alt''' + '''T''') > [https://support.mozilla.org/en-US/kb/Options%20window '''Options'''], and [http://kb.mozillazine.org/About:config about:config] ), and usually would also be empty of any '''Extensions''' and themes ('''Appearance''') in Tools > Add-ons) and their settings. Also, a new profile would have no previous stored website data/settings etc., ('''Tools''' > [https://support.mozilla.org/en-US/kb/Clear%20Recent%20History '''Clear Recent History''']).
    [https://support.mozilla.org/en-US/kb/Profiles?s=profile&r=2&e=sph&as=s Profiles Howto]
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder & Files]
    [http://kb.mozillazine.org/About:config_entries about:config Entries]
    For NTLM authentication, you can try to automatically trust the domain in the [http://kb.mozillazine.org/Network.automatic-ntlm-auth.trusted-uris network.automatic-ntlm-auth.trusted-uris] list in [http://kb.mozillazine.org/About:config about:config], eg. domain.com
    Not sure, but for Kerberos, I think you would have to use '''network.negotiate-auth.trusted-uris''' instead.

  • How can Preview cut each page of a PDF file in half? I want to obtain a version that is two times more pages, with each page containing half of the original content.

    As title. Thank you guys for answering!

    RickRockUSC wrote:
    As title. Thank you guys for answering!
    Maybe Acrobat Reader is what you need:
    http://get.adobe.com/reader/

  • How can i make my header move with the page so it always shows

    I reseached the muse guides online but i could not find the answer. Maybe I missed it, butim tired of looking for it.

    maybe try pinning it?

  • Dw, css, and a template, what is the best way to create a 20 page website with a different header in each page?

    dw, css, and a template, what is the best way to create a 20
    page website with different header content on each page? i am
    trying to insert a specific image and background color for each
    header on every page. what is the easiest or best way to do this?
    thanks, bryan

    "mediastream13" <[email protected]> wrote in
    message
    news:f47bes$9om$[email protected]..
    > ok, murray, here is the site.
    http://www.helphotline.org
    > in I.E. 6 i can't see the background color behind the
    header images,
    I'm seeing a hot pink background (which is my browser default
    - so that I do
    remember to declare a background color). You need to add:
    body { background-color: white;} to your stylesheet, or into
    the imbedded
    styles on your page.
    In Firefox, the very top black section, #headertop is hidden
    behind the
    header image.
    > background of the date/time isn't stretching the full
    length of the
    > screen, and
    > the margins aren't working in the main content area. how
    can i put a
    > background
    > color behind the header images?
    I can see the header image stretching right across the page..
    so not sure
    what color is missing there.
    > is there anyway to download i.e. six on my computer if i
    already have
    > i.e.7? i
    > just want to be able to preview the site before i upload
    the changes. it
    > seems
    > everything works in i.e. 7.
    Yes, I used this and it works really well.
    http://tredosoft.com/Multiple_IE
    Nadia
    Adobe® Community Expert : Dreamweaver
    CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    ~ Customisation Service Available ~
    http://www.csstemplates.com.au

  • Do paging with header on a JSP page

    Hi:
    We have a data report displayed as a JSP page. The report displays 200 rows of data. We need to print these 200 rows report with a header/title on each page. And our user only wants to hit he Browser print button once. This would have been easy if we don't have to insert the header on each print page. But how can we print this multiple page report with a header? Do we need to use CSS? any help will be appreciated.
    reportPrinter

    Okay bear with me:
    Step 1: determine how many rows in a table with a header will print on a single page
    Step 2: Create a jsp that breaks your data down into tables of the row size determined above.
    For example if the data consists of 1000 rows and 50 rows w/ headers will fit on a page
    then the jsp will create 20 tables of 50 rows w/ headers each.
    Step 3: Use CSS to put page breaks between the tables.
    http://www.htmlgoodies.com/beyond/css_print.html
    Step 4: In the original JSP use the HTML LINK tag to link it to the JSP you just created
    http://www.gself.com/xbas/head/linking.htm
    <link rel="alternative" href="{new JSP url}" type="text/html" media="print" />
    Step 5: On the original JSP provide a button that when clicked on will call the JavaScript print function.
    Now what should happen is that when the button on the original JSP is clicked the JavaScript print function will be called but instead of the page displayed in the browser being printed the alternative page
    in the LINK tag will get printed. This alternative JSP page is formatted to print one table with headers per page.
    The only part of this that I have not used in a production web app iss the CSS page break part. The rest of it I know will work.

  • How to display column headings only once in each page with repeated blocks

    Hi,
    I have a report with 1 block on one column. The block has a table in it and will repeat in one page.
    I need to display the column headers only in the beginning of each page. Can someone share your experience in implementing this ?
    Thanks for your help.

    >
    andyhchsu wrote:
    > Hi,
    > I mean in each block within section, I only need to display the table header once in each page.
    > However if I check table header, it will display repeatedly. Any way to get around this ? Thx.
    The trick I use to do that is turn off all the headers on the block (table and break) and put the header information in its own block above the section and set the new header block to repeat on each page.  You just have to remember to resize the columns in the header block if you make changes to the column sizes in your data block.

  • Header on each page in  a CrossTab Report

    Hi,
    I created a cross tab report. The only place I can place it is the Report header. I have a heading that should be displayed on each page of the report, how can I do this.
    Because the cross tab is in the Report Header I placed my heading in the Report Header only so it appears on the first page only. How can I make it appear on each page.
    Thanks,
    Reena

    Hi Reena,
    Have you tried placing the Crostab in Report Footer? This way you can keep the heading in Page header and the Crosstab in Report footer so that the heading appers on each page. Rest all section which are not required can be suppressed.
    Let us know if this helps.
    Cheers!

  • Created letter head templates with pages-open using in WORD HOW?

    please help.. i created beautiful letter head templates with iwork pages  and i am trying to give to my employee to use it ... and then they can't import or open  use from microsoft Word 2011. they do not have iwork.. possible can share templates both pages and microsoft word?  is there way to do it?  all the letter logo reflextion effect  that i sed from iwork  dont seem work in microsoft word. ;(
    or it is not possible?
    not everyone  in my office has iwork and i want them to use same letter head  i creadted from pages.. so that they can use it from thier PC.
    anyone can help me?

    Do you mean template or document? They're not the same thing.
    The template formats that Microsoft and Apple use are different (just like all their document formats). You can Export a Pages document in a Word format and send this to your employees. An employee can then save this Word document as a Word template and use it.

  • Print - JTable with a TITLE on each page

    Hi! someone know haw can I print a MY TITLE on each page that I print ?
    ----->MY TITLE<----
    | co1 | col2 | col3 | col4 |
    |dtxxz|dtxyz|dtxyz|dtxyz|
    |dtxxz|dtxyz|dtxyz|dtxyz|
    |dtxxz|dtxyz|dtxyz|dtxyz|
    PAGE 1
    I try that :
    g.drawString("MY TITLE", 100,50);
    but the table header hide (writing over) my title
    Here is my call :
    public int print(Graphics g, PageFormat pageFormat, int pageIndex)
    throws PrinterException {
         Graphics2D g2 = (Graphics2D) g;
         g2.setColor(Color.black);
         int fontHeight = g2.getFontMetrics().getHeight();
         int fontDesent = g2.getFontMetrics().getDescent();
         pageFormat.setOrientation(pageFormat.LANDSCAPE);
         //leave room for page number
         double pageHeight = pageFormat.getImageableHeight() - fontHeight;
         double pageWidth = pageFormat.getImageableWidth();
         double tableWidth =
              (double) getCurrentTable().getColumnModel().getTotalColumnWidth();
         double scale = 1;
         if (tableWidth >= pageWidth) {
              scale = pageWidth / tableWidth;
         double headerHeightOnPage =
              getCurrentTable().getTableHeader().getHeight() * scale ;
         double tableWidthOnPage = tableWidth * scale;
         double oneRowHeight =
              (getCurrentTable().getRowHeight() + getCurrentTable().getRowMargin()) * scale;
         int numRowsOnAPage = (int) ((pageHeight - headerHeightOnPage) / oneRowHeight);
         double pageHeightForTable = oneRowHeight * numRowsOnAPage;
         int totalNumPages =
              (int) Math.ceil(((double) getCurrentTable().getRowCount()) / numRowsOnAPage);
         if (pageIndex >= totalNumPages) {
              return NO_SUCH_PAGE;
         g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
         g2.drawString(
              "Page: " + (pageIndex + 1),
              (int) pageWidth / 2 - 35,
              (int) (pageHeight + fontHeight - fontDesent));
         //bottom center
         g2.translate(0f, headerHeightOnPage);
         g2.translate(0f, -pageIndex * pageHeightForTable);
         //TODO this next line treats the last page as a full page
         g2.setClip(
              0,
              (int) (pageHeightForTable * pageIndex),
              (int) Math.ceil(tableWidthOnPage),
              (int) Math.ceil(pageHeightForTable));
         g2.scale(scale, scale);
         getCurrentTable().paint(g2);
         g2.scale(1 / scale, 1 / scale);
         g2.translate(0f, pageIndex * pageHeightForTable);
         g2.translate(0f, -headerHeightOnPage);
         g2.setClip(
              0,
              0,
              (int) Math.ceil(tableWidthOnPage),
              (int) Math.ceil(headerHeightOnPage));
         g2.scale(scale, scale);
         getCurrentTable().getTableHeader().paint(g2); //paint header at top
         return Printable.PAGE_EXISTS;
    Thanks

    //Solution-------------------------------------------------------------------------------------------------------
    // PRINT : CENTER HEADER TITLE ON EACH PAGE
    : PAGE NUMBER ON EACH PAGE
    : USE A PREVIEW WINDOW
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.print.*;
    import java.awt.*;
    import java.awt.event.*;
    * File: PrintTable.java
    * (C) Copyright Corp. 2001 - All Rights Reserved.
    * Print a JTable data
    public class PrintTable implements Printable {
    * Insert the method's description here.
    * Creation date: (03-13-2002 13:50:41)
    * @param g java.awt.Graphics
    * @param pg java.awt.print.PageFormat
    * @param i int
    public int print(Graphics g, PageFormat pageFormat,
         int pageIndex) throws PrinterException {
         try{
              Graphics2D g2 = (Graphics2D) g;
              g2.setColor(Color.black);
              int fontHeight = g2.getFontMetrics().getHeight();
              int fontDesent = g2.getFontMetrics().getDescent();
              // Normalize the header color
              // he title of the report is not printed if the color of the header is different of these colors
              m_table.getTableHeader().setBackground(new java.awt.Color(204,204,204));
              m_table.getTableHeader().setForeground(new java.awt.Color(0,0,0));
              //leave room for page number
              double pageHeight = pageFormat.getImageableHeight() - fontHeight;
              double pageWidth = pageFormat.getImageableWidth();
              double tableWidth = (double) m_table.getColumnModel().getTotalColumnWidth();
              double scale = 1;
              if (tableWidth >= pageWidth) {
                   scale = pageWidth / tableWidth;
              // Get the size of the table header
              double headerHeightOnPage = m_table.getTableHeader().getHeight() * scale;
              // Get the table size on a page
              double tableWidthOnPage = tableWidth * scale;
              // Title Height
              double titleHeightOnPage = 0;
              if( m_title != null ){
                   titleHeightOnPage = ((double)m_title.getFontMetrics(m_title.getFont()).getHeight() + 40) * scale;
              // Get size of a row
              double oneRowHeight =
                   (m_table.getRowHeight() + m_table.getRowMargin()) * scale;
              int numRowsOnAPage = (int) ((pageHeight - headerHeightOnPage - titleHeightOnPage) / oneRowHeight);
              // Get number of row in a page
              double pageHeightForTable = oneRowHeight * numRowsOnAPage;
              // Get the number of page to print
              int totalNumPages =
                   (int) Math.ceil(((double) m_table.getRowCount()) / numRowsOnAPage);
              if (pageIndex >= totalNumPages) {
                   return NO_SUCH_PAGE;
              // Print the page label at bottom center
              g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
              g2.drawString(
                   "Page: " + (pageIndex + 1),
                   (int) pageWidth / 2 - 35,
                   (int) (pageHeight + fontHeight - fontDesent));
              g2.translate(0f, headerHeightOnPage + titleHeightOnPage);
              g2.translate(0f, -pageIndex * pageHeightForTable);
              //If this piece of the table is smaller than the size available,
              //clip to the appropriate bounds.
              if (pageIndex + 1 == totalNumPages) {
                   int lastRowPrinted = numRowsOnAPage * pageIndex;
                   int numRowsLeft = m_table.getRowCount() - lastRowPrinted;
                   g2.setClip(
                        0,
                        (int) (pageHeightForTable * pageIndex),
                        (int) Math.ceil(tableWidthOnPage),
                        (int) Math.ceil(oneRowHeight * numRowsLeft));
              //else clip to the entire area available.
              else {
                   g2.setClip(
                        0,
                        (int) (pageHeightForTable * pageIndex),
                        (int) Math.ceil(tableWidthOnPage),
                        (int) Math.ceil(pageHeightForTable));
              g2.scale(scale, scale);
              m_table.paint(g2);
              g2.scale(1 / scale, 1 / scale);
              g2.translate(0f, pageIndex * pageHeightForTable);
              g2.translate(0f, -headerHeightOnPage );
              g2.setClip(
                   0,
                   0,
                   (int) Math.ceil(tableWidthOnPage),
                   (int) Math.ceil(headerHeightOnPage));
              g2.scale(scale, scale);
              // Paint header at the top of the page
              m_table.getTableHeader().paint(g2);
              g2.scale(1 / scale, 1/ scale);
              g2.translate(0f, -titleHeightOnPage);
              g2.setClip(
                   0,
                   0,
                   (int) Math.ceil(tableWidthOnPage),
                   (int) Math.ceil(titleHeightOnPage));
              // Paint title
              if( m_strTitle != null ){
                   //Center
                   g2.translate((pageFormat.getImageableWidth() / 2) -
                                  (m_title.getFontMetrics(m_title.getFont()).stringWidth(m_title.getText()) / 2 ),
                                  0f );
                   g2.drawString(m_title.getText(), 0, 10);
              }else if ( m_title != null ){
                   //Center
                   g2.translate((pageFormat.getImageableWidth() / 2) -
                                  (m_title.getFontMetrics(m_title.getFont()).stringWidth(m_title.getText()) / 2 ),
                                  0f );
                   m_title.paint(g2);     
         }catch (Exception e){
              e.printStackTrace();
              return Printable.PAGE_EXISTS;
    * Show a print dialog box
    * Call the method to print
    * @param JTable table : table to print
    * @param String title : title of the table
    public static void print(JTable table, String title) {
         try {
              m_table = table;
              m_strTitle = title;
              m_data     = m_table.getModel();
              PrinterJob prnJob = PrinterJob.getPrinterJob();
              prnJob.setPrintable(PrintTable.instance, prnJob.defaultPage());
              // if the print job is cancelled
              if (!prnJob.printDialog())
                   return;
              // print the table
              prnJob.print();
         } catch (PrinterException pe) {
              pe.printStackTrace();
              System.err.println("Printing error: " + pe.toString());
         protected static PrintTable instance     = new PrintTable();
         public static int LANDSCAPE = PageFormat.LANDSCAPE;
         protected static TableModel m_data;
         protected static int m_maxNumPage           = 1;
         protected static String          m_strTitle = null;
         protected static JTable      m_table;
         protected static JLabel      m_title          = null;
         // Paper orientation
         public static int PORTRAIT = PageFormat.PORTRAIT;
         private final static String PREVIEW_LBL = "Aper�u avant impression...";
    * Insert the method's description here.
    * Creation date: (03-13-2002 10:12:41)
    public static void preview(JTable table) {
         m_table = table;
         m_data      = table.getModel();
         PrinterJob prnJob = PrinterJob.getPrinterJob();
         new PrintPreview(PrintTable.instance,
                             PREVIEW_LBL,
                             prnJob.defaultPage());
    * Insert the method's description here.
    * Creation date: (03-13-2002 10:12:41)
    public static void preview(JTable table, PageFormat pf) {
         m_table = table;
         m_data      = table.getModel();
         new PrintPreview(PrintTable.instance,
                             PREVIEW_LBL,
                             pf);
    * Insert the method's description here.
    * Creation date: (03-13-2002 10:12:41)
    public static void preview(JTable table, String title) {
         m_table = table;
         m_data      = table.getModel();
         m_strTitle = title;
         m_title = new JLabel(title);
         PrinterJob prnJob = PrinterJob.getPrinterJob();
         new PrintPreview(PrintTable.instance,
                             PREVIEW_LBL,
                             prnJob.defaultPage());
    * Insert the method's description here.
    * Creation date: (03-13-2002 10:12:41)
    public static void preview(JTable table, String title, PageFormat pf) {
         m_table = table;
         m_data      = table.getModel();
         m_strTitle = title;
         m_title = new JLabel(title);
         new PrintPreview(PrintTable.instance,
                             PREVIEW_LBL,
                             pf);
    * Insert the method's description here.
    * Creation date: (03-13-2002 10:12:41)
    public static void preview(JTable table, JLabel title) {
         m_table = table;
         m_data      = table.getModel();
         m_title = title;
         PrinterJob prnJob = PrinterJob.getPrinterJob();
         new PrintPreview(PrintTable.instance,
                             PREVIEW_LBL,
                             prnJob.defaultPage());
    * Insert the method's description here.
    * Creation date: (03-13-2002 10:12:41)
    public static void preview(JTable table, JLabel title, PageFormat pf) {
         m_table = table;
         m_data      = table.getModel();
         m_title = title;
         new PrintPreview(PrintTable.instance,
                             PREVIEW_LBL,
                             pf);
    * Show a print dialog box
    * Call the method to print
    * @param JTable table : table to print
    * @param String title : title of the table
    public static void print(JTable table, String title, PageFormat pf) {
         try {
              m_table = table;
              m_strTitle = title;
              m_data     = m_table.getModel();
              PrinterJob prnJob = PrinterJob.getPrinterJob();
              prnJob.setPrintable(PrintTable.instance, pf);
              // if the print job is cancelled
              if (!prnJob.printDialog())
                   return;
              // print the table
              prnJob.print();
         } catch (PrinterException pe) {
              pe.printStackTrace();
              System.err.println("Printing error: " + pe.toString());
    * Show a print dialog box
    * Call the method to print
    * @param JTable table : table to print
    * @param String title : title of the table
    public static void print(JTable table, String title, PageFormat pf, int orientation) {
         try {
              m_table = table;
              m_strTitle = title;
              m_data     = m_table.getModel();
              PrinterJob prnJob = PrinterJob.getPrinterJob();
              prnJob.setPrintable(PrintTable.instance, prnJob.defaultPage());
              pf.setOrientation(orientation);
              // if the print job is cancelled
              if (!prnJob.printDialog())
                   return;
              // print the table
              prnJob.print();
         } catch (PrinterException pe) {
              pe.printStackTrace();
              System.err.println("Printing error: " + pe.toString());
    * Show a print dialog box
    * Call the method to print
    * @param JTable table : table to print
    * @param String title : title of the table
    public static void print(JTable table, JLabel title) {
         try {
              m_table = table;
              m_title = title;
              m_data = table.getModel();
              PrinterJob prnJob = PrinterJob.getPrinterJob();
              prnJob.setPrintable(PrintTable.instance, prnJob.defaultPage());
              // if the print job is cancelled
              if (!prnJob.printDialog())
                   return;
              // print the table
              prnJob.print();
         } catch (PrinterException pe) {
              pe.printStackTrace();
              System.err.println("Printing error: " + pe.toString());
    * Show a print dialog box
    * Call the method to print
    * @param JTable table : table to print
    * @param String title : title of the table
    public static void print(JTable table, JLabel title, PageFormat pf) {
         try {
              m_table = table;
              m_title = title;
              m_data      = table.getModel();
              PrinterJob prnJob = PrinterJob.getPrinterJob();
              prnJob.setPrintable(PrintTable.instance, pf);
              // if the print job is cancelled
              if (!prnJob.printDialog())
                   return;
              // print the table
              prnJob.print();
         } catch (PrinterException pe) {
              pe.printStackTrace();
              System.err.println("Printing error: " + pe.toString());
    * Show a print dialog box
    * Call the method to print
    * @param JTable table : table to print
    * @param String title : title of the table
    public static void print(JTable table, JLabel title, PageFormat pf, int orientation) {
         try {
              m_table = table;
              m_title = title;
              m_data      = table.getModel();
              PrinterJob prnJob = PrinterJob.getPrinterJob();
              prnJob.setPrintable(PrintTable.instance, pf);
              // if the print job is cancelled
              if (!prnJob.printDialog())
                   return;
              pf.setOrientation(orientation);
              // print the table
              prnJob.print();
         } catch (PrinterException pe) {
              pe.printStackTrace();
              System.err.println("Printing error: " + pe.toString());
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.util.*;
    import java.awt.print.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    public class PrintPreview extends JFrame
    protected int m_wPage;
    protected int m_hPage;
    protected Printable m_target;
    protected JComboBox m_cbScale;
    protected PreviewContainer m_preview;
    private String lblBtnClose           = "Fermer";
    private String lblBtnPrint           = "Imprimer...";
    protected PageFormat m_pf;
    private String[] scales                = { "10 %", "25 %", "50 %", "100 %" };
    public PrintPreview(Printable target, String title, PageFormat pf) {
         super(title);
         setSize(600, 400);
         m_target = target;
         m_pf = pf;
         JToolBar tb = new JToolBar();
         JButton bt = new JButton(this.lblBtnPrint);
         ActionListener lst = new ActionListener() {
         public void actionPerformed(ActionEvent e) {
              try {
              // Use default printer, no dialog
              PrinterJob prnJob = PrinterJob.getPrinterJob();
              prnJob.setPrintable(m_target, m_pf);
              setCursor( Cursor.getPredefinedCursor(
                   Cursor.WAIT_CURSOR));
              prnJob.print();
              setCursor( Cursor.getPredefinedCursor(
                   Cursor.DEFAULT_CURSOR));
              dispose();
              catch (PrinterException ex) {
              ex.printStackTrace();
              System.err.println("Printing error: "+ex.toString());
         bt.addActionListener(lst);
         bt.setAlignmentY(0.5f);
         bt.setMargin(new Insets(4,6,4,6));
         tb.add(bt);
         bt = new JButton(this.lblBtnClose);
         lst = new ActionListener() {
         public void actionPerformed(ActionEvent e) {
              dispose();
         bt.addActionListener(lst);
         bt.setAlignmentY(0.5f);
         bt.setMargin(new Insets(2,6,2,6));
         tb.add(bt);
         m_cbScale = new JComboBox(scales);
         lst = new ActionListener() {
         public void actionPerformed(ActionEvent e) {
              Thread runner = new Thread() {
              public void run() {
                   String str = m_cbScale.getSelectedItem().
                   toString();
                   if (str.endsWith("%"))
                   str = str.substring(0, str.length()-1);
                   str = str.trim();
                   int scale = 0;
                   try { scale = Integer.parseInt(str); }
                   catch (NumberFormatException ex) { return; }
                   int w = (int)(m_wPage*scale/100);
                   int h = (int)(m_hPage*scale/100);
                   Component[] comps = m_preview.getComponents();
                   for (int k=0; k<comps.length; k++) {
                   if (!(comps[k] instanceof PagePreview))
                        continue;
                   PagePreview pp = (PagePreview)comps[k];
                        pp.setScaledSize(w, h);
                   m_preview.doLayout();
                   m_preview.getParent().getParent().validate();
              runner.start();
         m_cbScale.addActionListener(lst);
         m_cbScale.setMaximumSize(m_cbScale.getPreferredSize());
         m_cbScale.setEditable(true);
         tb.addSeparator();
         tb.add(m_cbScale);
         getContentPane().add(tb, BorderLayout.NORTH);
         m_preview = new PreviewContainer();
         PrinterJob prnJob = PrinterJob.getPrinterJob();
         PageFormat pageFormat = pf;
         if (pageFormat.getHeight()==0 || pageFormat.getWidth()==0) {
         System.err.println("Unable to determine default page size");
              return;
         m_wPage = (int)(pageFormat.getWidth());
         m_hPage = (int)(pageFormat.getHeight());
         int scale = 10;
         int w = (int)(m_wPage*scale/100);
         int h = (int)(m_hPage*scale/100);
         int pageIndex = 0;
         try {
         while (true) {
              BufferedImage img = new BufferedImage(m_wPage,
              m_hPage, BufferedImage.TYPE_INT_RGB);
              Graphics g = img.getGraphics();
              g.setColor(Color.white);
              g.fillRect(0, 0, m_wPage, m_hPage);
              if (target.print(g, pageFormat, pageIndex) !=
              Printable.PAGE_EXISTS)
              break;
              PagePreview pp = new PagePreview(w, h, img);
              m_preview.add(pp);
              pageIndex++;
         catch (PrinterException e) {
         e.printStackTrace();
         System.err.println("Printing error: "+e.toString());
         JScrollPane ps = new JScrollPane(m_preview);
         getContentPane().add(ps, BorderLayout.CENTER);
         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
         setVisible(true);
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    * Insert the type's description here.
    * Creation date: (03-12-2002 14:17:45)
    * @author: Alexandre Spain
    public class PreviewContainer extends JPanel {
         protected int H_GAP = 16;
         protected int V_GAP = 10;
    * PreviewContainer constructor comment.
    public PreviewContainer() {
         super();
    public void doLayout() {
         Insets ins = getInsets();
         int x = ins.left + H_GAP;
         int y = ins.top + V_GAP;
         int n = getComponentCount();
         if (n == 0)
              return;
         Component comp = getComponent(0);
         Dimension dc = comp.getPreferredSize();
         int w = dc.width;
         int h = dc.height;
         Dimension dp = getParent().getSize();
         int nCol = Math.max((dp.width-H_GAP)/(w+H_GAP), 1);
         int nRow = n/nCol;
         if (nRow*nCol < n)
              nRow++;
         int index = 0;
         for (int k = 0; k<nRow; k++) {
              for (int m = 0; m<nCol; m++) {
                   if (index >= n)
                        return;
                   comp = getComponent(index++);
                   comp.setBounds(x, y, w, h);
                   x += w+H_GAP;
              y += h+V_GAP;
              x = ins.left + H_GAP;
    public Dimension getMaximumSize() {
         return getPreferredSize();
    public Dimension getMinimumSize() {
         return getPreferredSize();
    public Dimension getPreferredSize() {
         int n = getComponentCount();
         if (n == 0)
              return new Dimension(H_GAP, V_GAP);
         Component comp = getComponent(0);
         Dimension dc = comp.getPreferredSize();
         int w = dc.width;
         int h = dc.height;
         Dimension dp = getParent().getSize();
         int nCol = Math.max((dp.width-H_GAP)/(w+H_GAP), 1);
         int nRow = n/nCol;
         if (nRow*nCol < n)
              nRow++;
         int ww = nCol*(w+H_GAP) + H_GAP;
         int hh = nRow*(h+V_GAP) + V_GAP;
         Insets ins = getInsets();
         return new Dimension(ww+ins.left+ins.right,
                                  hh+ins.top+ins.bottom);
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    * Insert the type's description here.
    * Creation date: (03-12-2002 14:17:06)
    * @author: Alexandre Spain
    public class PagePreview extends JPanel {
         protected int m_w;
         protected int m_h;
         protected Image m_source;
         protected Image m_img;
    * PagePreview constructor comment.
    * @param target java.awt.print.Printable
    public PagePreview(int w, int h, Image source) {
         m_w = w;
         m_h = h;
         m_source= source;
         m_img = m_source.getScaledInstance(m_w, m_h,
              Image.SCALE_SMOOTH);
         m_img.flush();
         setBackground(Color.white);
         setBorder(new MatteBorder(1, 1, 2, 2, Color.black));
    public Dimension getMaximumSize() {
         return getPreferredSize();
    public Dimension getMinimumSize() {
         return getPreferredSize();
    public Dimension getPreferredSize() {
         Insets ins = getInsets();
         return new Dimension(m_w+ins.left+ins.right,
                                  m_h+ins.top+ins.bottom);
    public void paint(Graphics g) {
         g.setColor(getBackground());
         g.fillRect(0, 0, getWidth(), getHeight());
         g.drawImage(m_img, 0, 0, this);
         paintBorder(g);
    public void setScaledSize(int w, int h) {
         m_w = w;
         m_h = h;
         m_img = m_source.getScaledInstance(m_w, m_h,
         Image.SCALE_SMOOTH);
         repaint();

Maybe you are looking for