Print an invisible table

Hello

to print an invisible table must be defined before size:
    table.setSize(table.getPreferredSize());
But if the invisible table itself contains tables, this is not enough, it seems.
The following codes puts two visible tables in an invisible. But when
try to print this out, not only the output is too small and empty, but the
visible paintings disappears from the Panel as well. No idea why?
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import javax.swing.*;
import javax.swing.table.*;
 
public class TablesInInvisibleTable extends JFrame implements ActionListener {
  int height1, height2;
  JTable tbl1, tbl2;

  public TablesInInvisibleTable() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(210, 250);
    Container cp= getContentPane();
    cp.setLayout(new BorderLayout());
    JPanel centerPanel= new JPanel(new BorderLayout());

    String[][] data= new String[][]{{"1","Apple"},{"2","Cherry"},{"3","Grape"}};
    tbl1= createTable(data);
    JScrollPane scrollPane1= new JScrollPane(tbl1);
    int lineHeight= tbl1.getRowHeight();
    height1= tbl1.getRowCount()*lineHeight +20; // Header
    scrollPane1.setPreferredSize(new Dimension(200, height1));
    centerPanel.add(scrollPane1, BorderLayout.NORTH);
    
    data= new String[][]{{"50","Banana"}, {"16","Pineapple"}};
    tbl2= createTable(data);
    JScrollPane scrollPane2= new JScrollPane(tbl2);
    height2= tbl2.getRowCount()*lineHeight +20;
    scrollPane2.setPreferredSize(new Dimension(200, height2));
    centerPanel.add(scrollPane2, BorderLayout.SOUTH);
    cp.add(centerPanel, BorderLayout.CENTER);

    JButton bPrint= new JButton("Print");
    bPrint.addActionListener(this);
    cp.add(bPrint, BorderLayout.SOUTH);
    setVisible(true);
  }


  public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
      public void run() {
     new TablesInInvisibleTable();
      }
    });
  }


  public void actionPerformed(ActionEvent e) {
    DefaultTableModel dtm= new DefaultTableModel(
          new Object[][] {{tbl1},{""},{tbl2}}, new String[]{"Header"});
    JTable table= new JTable(dtm);
    table.getColumnModel().getColumn(0).setCellRenderer(new SubTableRenderer());
//    table.setTableHeader(null);
    table.setRowHeight(0, height1);
    table.setRowHeight(2, height2);
    System.out.println(table.getPreferredSize()); // width is too small.
    table.setSize(table.getPreferredSize());
//    table.doLayout();
    try {
      table.print();
    }
    catch(PrinterException ex) {
      System.out.println(ex);
    }
  }


  public JTable createTable(String[][] data) {
    return new JTable(data, new String[]{"Count", "Name"});
  }


  class SubTableRenderer implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value,
          boolean isSelected, boolean hasFocus, int row, int column) {
      if (row==0 || row==2) {
     return new JScrollPane((JTable)value);
//     return (JTable)value; // Table is visible, but no header.
      }
      else {
     return new JLabel();
      }
    }
  }

}

With 'invisible' I don't want no 'empty', but "not understood", "not displayed".

You can take the completed component but not visible:

//table.setSize(table.getPreferredSize());
table.setPreferredSize( new Dimension(300, table.getPreferredSize().height) );
JFrame frame = new JFrame();
frame.setContentPane( table );
frame.pack();

the width is too small.

This is because when you create a table, the width of each column as the default value of 75 pixels. If you want a larger table then override the default width (as demonstrated above).

but the visible tables disappear from the Panel as well. No idea why?

I have no idea why the table disappears from the image.

Tags: Java

Similar Questions

  • Java classes generic print view ADF Table object

    Good afternoon

    I would like to write a generic method that takes an object as a parameter and then prints an ADF table made from this view object.

    Did anyone done this before? And if you have, maybe you have an example? Or do you know where I could get something similar?

    Kind regards

    n0vice

    It won't work because the behavior of the printable page removes the page buttons as their print makes no sense. Are aware that you get only the visible part of the table and all the lines using this approach?

    If you really want to use the behavior of printable page, you have to set the confirmation in front of navigation before displaying the printable page. Here are some tips on how to do

    http://www.Oracle.com/technetwork/developer-tools/ADF/learnmore/95-printable-pages-1501392.PDF

    'How - to launch print dialog when displaying the printable page' in http://www.oracle.com/technetwork/developer-tools/adf/learnmore/sept2011-otn-harvest-508189.pdf

    "How to hide or show printable pages components" in http://www.oracle.com/technetwork/developer-tools/adf/learnmore/august2011-otn-harvest-457288.pdf

    'How to launch browser print dialogue when viewing the printable page' in http://www.oracle.com/technetwork/developer-tools/adf/learnmore/jan2011-otn-harvest-300940.pdf

    Another solution would be to generate a PDF from the VO in a generic way (for example by using itext, jasper reports or bipublisher).

    Timo

  • When I print a table (multiple pages) the text box under the table seems to be moving under the table and prints with the table of this overlap. My only solution is to push the text box further down the page before printing... Any advice?

    Im having problems shaped a text box so that my table does not print right on top of it. I want it inside of my table (it's 'tems and conditions' budget)

    Any advice would be great.

    I face the same problem as well. Would like to know if there is a better way to get the text box to move with the table instead of the effect that overlap. Have to manually adjust the layout, whenever I want to get a reasonable print of a document (or export it to PDF) seems counterintuitive, especially when it causes the document seem ill-disposed on screen.

    I am running version 3.6.2 of the numbers in the case where that matters.

  • How to print a long table on paper letter with titles (and feet page, if possible!) on every page?

    I can't find information anywhere and will appreciate the pointers.

    You can not do with the simplicity that you can do with software such as Microsoft Word.

    Only HTML cannot interact with a printer. You can print from a web browser, you can use the @media print CSS to specify the page layout for printing, but with HTML/CSS you cannot receive information and information of the printer and you can't control things like the size and orientation of the page (horizontal/vertical). The user's browser sends its own headers and footers with information such as the date, the page number and url. The user can disable them in the browser, but your web page cannot do this.

    If the table is generated by PHP, you can use PHP to count the rows of the table and add page breaks to the appropriate position. You can send a page break beforebreak with CSS, but if your table cell height, varies according to the amount of content, it would be impossible to calculate the right places to send the page break command. With PHP, you could also add the header and footer to the right positions.

    Even with all of the above variations, printers, operating systems and browsers would probably the printer document well in some environments and horribly in others.

    With Java or Javascript, you can control the interaction with the printer. There could be a framework like jQuery javascript that can do.

  • How can we do the invisible table cells (but not content) in DW CS5?

    How can you efficiently convert the table cells in invisible ones so that the content within these cells gets stand alone, visibility-wise, please?  I looked at so many different orders of Dreamweaver CS-5, but none seem to do the trick, at least do not apparently potentially compromising the existing content somehow.  Any thoughts, please?

    Change

    BORDER CELLPADDING = "0".

    TO

    BORDER = "0".

    See what for you.

    Gary

  • Printing of invisible fields

    I have a couple of forms that have invisible fields I have script to become visible only when the user selects 'Yes' on some radio buttons when you fill out the form in Reader. They work great, but the problem is that we have some "old school" users who still prefer to print the form and then fill them out by hand (sometimes you just can't teach old dogs new tricks!). We are ok with this, but it means that the invisible fields do not print. I thought maybe by switching 'Visible (printing only)' could solve this problem, but then they don't show up for the majority of users who actually fill the form digitally.

    Is it possible to set these fields so that they will display if the user prints a blank form to complete by hand?

    Maybe a script pre printed that said: "if [mandatory fields] is empty (which would mean that the user is most likely printing a blank form), then change the fields 'Invisible' to"Visible '?" What would this script?

    Or y at - it an easier way?

    Thanks for any help!

    JO

    I don't think that the option button has a value no value, try to test against.

    N.

  • Printing with color tables.

    Does anyone have an idea why the colorful shade of different parts of a table does not print after compilation? The footprints of the table, but none of the colors appear, I print to a color printer or grey. This page will be used as a form, and the different areas need to appear as different colors or at least as shades of gray. With the help of HR 7.00.145 - Lenda

    Hi zieglel

    Try to print after you have made the following changes to your Internet Explorer.

    Click Tools > Internet Options
    Click the Advanced tab
    Scroll down to the printing section
    Activate the option "print background colors and images"
    Click OK to close the dialog box

    Now, print and see if you have what you want.

    See you soon... Rick

  • Columns and lines of text (invisible table)

    I'm trying to create a text about 15 rows by 3 columns in an invisable table for a drinks menu with corresponding sizes of the drink (ml) and prices. I used the option Type > Options type of area and added a grid. I have encountered problems 2:
    First of all, disappears from the grid (or I just can not see) and secondly, I don't want the columns of equal size - I'm looking to achieve a ratio of 60% - 20% - 20%. I cannot find a way to resize the width of the columns, you would be grateful for any advice

    Tabs would be simpler; Here's how to use the tabs to make left-alignment:

    You can use the attribute Align on tab make forget the price line up along the comma.

  • Invisible tables in Dreamweaver CS3

    Hello - I have a problem with access to the appropriate table in Dreamweaver CS3. In the past that I've never had a problem with that now all of a sudden I can't figure out what I did to change this setting. I want my tables without borders, that I've accomplished by assigning null border... but now it completely disappears from the page so I'm working on it and I have nothing to set my table. In the past when working with zero borders it would define the structure of the table but didn't appear not when published on the web. I went in view / visual aids / and checked the table borders and still nothing. How can I check my table limits while working without a border? Years, I have had no problem with that and now I'm really confused as to what I did to change the setting. Please, if anyone can help I would appreciate it.

    Even with a black background, you should be able to see lines dotted around a table.

    I just tested with a black background with Visual AIDS > table borders turned on could see the outline and then borders , then Icertainly could not something :-)

    Looks like something is broken in DW If DW starts acting a little weird - it frequently means that you can have a personal configuration file corrupt.

    Close Dreamweaver, search the personal configuration file and rename it.

    When you restart Dreamweaver, it should create a new folder of configuration with all the default values of program.

    For more information on how to find the configuration file, see the next page in the Dreamweaver FAQ

    I hope this will fix the problem for you.

  • Everything is ok for 64-bit, printer INVISIBLE to 32-bit applications applications

    Hello

    I am running Win7Pro64SP1 on a Z800 work and recently had a crash of partial disc in which some areas followed her into oblivion - repair disk etc. and reinstalls a few, almost everything came back ok, but here and there I still stumble on a corrupted dll must be replaced.

    Today, I saw that Adobe Reader could not print on my OfficeJet Pro 8600 Plus, which is on the ethernet network. Never had a problem with the drive before... so I reinstalled everything to drive but nothing helped, even if Wordpad print without problem and I can scan with the printer (that is, communication with it's not a problem). So I installed the latest all-in-One driver for the printer, but always without success. Then I run the application "HP print and scan of doctor" who told me that everything was absolutely PERFECT... except that when I tried to print the test page, nothing came out of the printer. But the 'doctor' gave me the ability to print a "test internal page"... and this printed an ok!

    Then I noticed this: whenever I tried to print from a 64-bit (such as Wordpad) application, everything went very well... but for applications 32-bit (for example Adobe Reader) the printer is invisible! We are in the company of software development and have 32 and 64 bit versions of everything we do, so I tried to print from one of our software in Java: the 64-bit version printed ok, but gave me the 32-bit version of exactly the same pot

    java.awt.print.PrinterException: no printer found.

    So clearly, (1) the printer is ok, (2) communication with her is ok, but (3) the printer "does not exist" in 32 bit, even if it is in 64-bit! So I obviously tried to install at least the base of 32 bits for the printer drivers... but was advised to install the 64-bit version instead (which I already did, successfully).

    I know that drivers (such as printer drivers) are dll and you cannot mix many different bits in the same image, but given the number of applications that still exist in 32-bit only, I thought that the all-in-one installer for 64-bit (OJ8600_1315.exe) install them 63 AND 32 bit drivers?

    Any idea on how I can do 32-bit applications on top of the printer, too?

    Thank you very much for your advice!

    I have SOVED it:

    -remove the printer and then reinstalled by specifying "I'll connect LATER. I do not know if this installed the driver locally, but probably so: I was able to print the Test Page

    - then I spotted the Net for posts about similar problems and found that many people had the 32-bit spooler (splwow64.exe) if crush... so I checked where that file was on another Win7 machine and found that it is in C... If on Windows my computer the file was not there! It must have gone in the crash...

    -J' copied splwow64.exe on the other machine to C:\Windows and everything works well again in 32 and 64 bit

    Conclusion: the spools are not the same to print from applications of 32 and 64-bit, check both. Hope this can help some of you.

  • C310 Wireless of tables print does not correctly?

    We have a new C310 wireless that my wife and I use our Toshiba laptops to connect and print wireless.  We use Windows 7.  Everything seems to work fine until we try to print a MS Word document that contains a table.  When we do, the rows of the table are compensated and tortuous.  Lines go straight for about half an inch, then the spacing is off by just an anti-eraflures of lines a half inch, then back to continued straight.  It also causes printing up and down the page in line with where the lines are crroked, which would be offset.

    We tried to align the cartridges, clean, do the print list print status, everything we can think of.  If I print the same docs across our older printers HP, tables and averything else print correctly.

    Any ideas?

    Please help if you know what to do!

    It sounds like you are using 'Fast draft mode' print settings.  Try replacing 'Normal' or 'Best' when you print documents with tables.

  • How to MERGE when the target table contains invisible columns?

    Oracle running on Oracle Linux 6.4 12.1.0.2.0 database:

    During his studies of FUSION with invisible columns, I discovered that invisible columns in the target table cannot be read. Workaround seems to be

    MERGE INTO (SELECT <column list> FROM <target table>) AS <alias>
    

    However, the documentation does not seem to allow this. Here are the details.

    Test data

    > CREATE TABLE t_target(
      k1 NUMBER PRIMARY KEY,
      c1 NUMBER,
      i1 NUMBER invisible
    )
    
    table T_TARGET created.
    
    > INSERT INTO t_target (k1,c1,i1)
    SELECT 2, 2, 2 FROM dual
    UNION ALL
    SELECT 3, 3, 3 FROM dual
    UNION ALL
    SELECT 4, 4, 4 FROM dual
    
    3 rows inserted.
    
    > CREATE TABLE t_source(
      k1 NUMBER PRIMARY KEY,
      c1 NUMBER,
      i1 NUMBER invisible
    )
    table T_SOURCE created.
    
    > INSERT INTO t_source (k1,c1,i1)
    SELECT 1, 1, 1 FROM dual
    UNION ALL
    SELECT 2, 2, 9999 FROM dual
    UNION ALL
    SELECT 3, 3, 3 FROM dual
    
    3 rows inserted.
    

    First try

    Please note that I have a WHERE clause in the WHEN MATCHED clause. Its purpose is to avoid the update of a row when data are already correct. The WHERE clause is trying to read the invisible column of the target table.

    > MERGE INTO t_target o
    USING (
      SELECT k1, c1, i1 FROM t_source
    ) n
    ON (o.k1 = n.k1)
    WHEN MATCHED THEN UPDATE SET
      c1=n.c1, i1=n.i1
      WHERE 1 IN (
        decode(o.c1,n.c1,0,1),
        decode(o.i1,n.i1,0,1)
      )
    WHEN NOT MATCHED THEN INSERT
      (k1, c1, i1)
      VALUES(n.k1, n.c1, n.i1)
    ...
    Error at Command Line : 10 Column : 12
    Error report -
    SQL Error: ORA-00904: "O"."I1": invalid identifier
    

    As you can see, I put a subquery after the USING clause so that 'n.i1' would be 'visible', but this is not enough since the 'I1' column in the target table is always invisible.

    Second test

    > MERGE INTO (
      SELECT k1, c1, i1 FROM t_target
    ) o
    USING (
      SELECT k1, c1, i1 FROM t_source
    ) n
    ON (o.k1 = n.k1)
    WHEN MATCHED THEN UPDATE SET
      c1=n.c1, i1=n.i1
      WHERE 1 IN (
        decode(o.c1,n.c1,0,1),
        decode(o.i1,n.i1,0,1)
      )
    WHEN NOT MATCHED THEN INSERT
      (k1, c1, i1)
      VALUES(n.k1, n.c1, n.i1)
    
    2 rows merged.
    

    Here I used a subquery in the INTO clause thus, and it worked.

    Unfortunately, this does not seem to be admitted in the documentation: IN fact refers to a table or a view as schema objects.

    Description of merge.gif follows

    My question is:

    How can I refer to invisible columns in the target table without creating a new object? My workaround using a subquery solution seems to work very well, but can I recommend if it is not documented?

    Can I replace a "inline view" for a view and still be supported?

    During his studies of FUSION with invisible columns, I discovered that invisible columns in the target table cannot be read. Workaround seems to be

    However, the documentation does not seem to allow this. Here are the details.

    Here I used a subquery in the INTO clause thus, and it worked.

    Unfortunately, this does not seem to be admitted in the documentation: IN fact refers to a table or a view as schema objects.

    My question is:

    How can I refer to invisible columns in the target table without creating a new object? My workaround using a subquery solution seems to work very well, but can I recommend if it is not documented?

    Can I replace a "inline view" for a view and still be supported?

    But the documentation DO ALLOWS not only! You use a view - a view online and those that can be changed in a MERGE statement.

    All versions of the doc for FUSION since 9i specifically say this:

    INTO clause

    Use the INTO target clause to specify the table or view you are updating or inserting into. To merge the data in a view, the view must be updated. Please refer to the "Notes on the editable views" for more information.

    Here are the links for the doc. 9i, 10g, 11g and c 12, ALL OF THEM (the last three), except 9i have this EXACT clause above.

    SQL statements: INDICATED to ROLLBACK FALLS, 15 of 19

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/statements_9016.htm

    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9016.htm

    https://docs.Oracle.com/database/121/SQLRF/statements_9016.htm

    9i doc does not have this specific quote in the INTO clause section, but it doesn't have that quote a little later:

    Limitation of the update of a view
    • You cannot specify DEFAULT when refreshing a view.
    • You cannot update a column referenced in the ON condition clause.
    merge_insert_clause

    The merge_insert_clause specifies the values to insert into the column of the target table, if the condition of the ON clause is false. If the insert clause is executed, then all insert triggers defined on the target table are activated.

    Restrictions on the merger in a view

    You cannot specify DEFAULT when refreshing a view.

    If your "workaround" isn't really a workaround solution. You SHOULD use an inline view if you need to reference a column "invisible" in the target table, since otherwise, these columns are INVISIBLE!

    My workaround using a subquery solution seems to work very well, but can I recommend if it is not documented?

    You can recomment it because IT IS documented.

  • AF:table and printing

    So I try to print an af:table in ADF Rich Faces. The problem is that the table is very wide and he runs on the side of the page while printing.

    So I wonder if there is a way to print out so that the entire table is displayed. Can I reduce the size of the table or maybe have it wrap during printing?

    Hello

    You can always try CSS to manipulate the page output. CSS, the option to specify a style that applies to prints only (mediatype).

    However, a better approach would be to do not use a table element, but an af:iterator and then create a layout custom for printing which control the number of columns used

    Frank

  • Good unit test for HP Smart Printing

    When trying to print http://models2014.webs.upv.es/schedule.htm without smart printing, a single table shows, and all other pages are empty.

    Smart printing but also has problems with this page, not being able to print a part of the text below the second table.

    With some difficulty, you can select all the text, but it prints up on 'Session 9' and leaves two pages empty.

    While I recognize that this Web page is built quite strangely (absolute positioning of points throughout the page), I think it may be a good test for the team Smart Printing scenario.

    In case it's relevant: Smart Print v2.6, IE 11, W7x64.

    Kind regards

    Johan

    Hi Johan,.

    I understand that you have this page as a test case, and I appreciated that!  I wonder if you have tried to use Google Chrome HP Smart printing on this page?  Technically, HP Smart printing is compatible only with IE 9 and 10 and Google Chrome - chrome is the browser for the support in the future (at least this is what I've heard).  I was wondering if you get better results using Chrome.  Just a thought.

  • printer is intermittent

    I have a printer HP 1012 b/w laser, working since 2003 on my old eMac and my current iMac proven.  I use a USB connection wire.

    I am running 10.10.5, since August 15, 2015.  I installed the HP printer 3.1 update on October 10.

    In 3 or 4 months, the printer becomes 'invisible' to the iMac.  When the printer is, in fact, the software of the printer reports that it is 'offline' and does not print.  Sometimes, printing is normal.  Sometimes, the printer is reported as 'offline '.

    To resolve this problem, I have tried several things:

    The power of the printer.

    Remove and reconnect the printer cable.

    Use a different USB port on the back of the iMac.

    I used the system preferences to uninstall and reinstall the printer, except that it won't reinstall what he doesn't seem to see.

    None of them worked.

    What * has * worked, every time, is re-start the OS X software.  No need to turn off the iMac, just a restart and the printer is now visible and functional.

    Does anyone know how to fix this?

    Greetings VictorBK,

    Thank you for using communities Support from Apple!

    From your post, I can tell that you have a current frustrating printing problem and I want to help him. Looks like you did a lot of great troubleshooting already, but I'd read over and working through the information in the following article; There are a few steps register that you have not tried yet, such as resetting the printing system.

    Get help to solve the problems of printer on your Mac - Apple Support

    Have a great day!

Maybe you are looking for