craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > Printing issues Post New Topic   Post A Reply
Blank page after print printer friendly version
next newest post | next oldest post
Author Messages
Safaga38
Private

Gender: Male
Location:
Registered: Aug 2008
Status: Offline
Posts: 5

Click here to see the profile for Safaga38 Send email to Safaga38 Find more posts by Safaga38 Edit or delete this message Reply w/Quote
Posted Thursday, April 2, 2009 @ 08:38:00  

Dear Sirs,

I appreciate quicktable very much and it relieves me of a lot of work. Anyway I still have some problems which I have no solutions for. I checked the documentation as well as the forum for a solution, but to no avail.

Here are the two problems:

1. First of all whenever I print a table I always get a blank page after printing the table itself (it is definitely not a problem of the printer itself). I have defined the printing class as follows

class AuftragPrintProperties extends PrintProperties {
public static final long serialVersionUID = 73l;
String header = "Liste der nicht abgerechneten Auftraege";

public AuftragPrintProperties(int ausrichtung) {
super(ausrichtung);
}

public int getBorderWidth() {
return 30;
}

public int getBorderHeight() {
return 28;
}

public String getHeader() {
return header + "\n\n\n";
}

public String getFooter() {
DateFormat df = DateFormat.getDateInstance();
String s = df.format(new java.util.Date());
return "Seite: %1%\nDatum: " + s;
}

public int getHeaderAlign() {
return SwingUtilities.CENTER;
}

public int getFooterAlign() {
return SwingUtilities.CENTER;
}

public Color getHeaderColor() {
return Color.BLUE;
}

public Color getFooterColor() {
return Color.BLUE;
}
}

2. The second problem relates to the printing of a table with an appended summary row. If there are 20 single rows fitting on one page and the summary row is the 21st which should be printed on the second page, I only get the single rows printed on the one page, the summary row is then suppressed, no matter if I use the print mode or the print preview mode. The Print Properties Class is as listed above. I have used the method

auftragsTable.insertSilent(sumVector, anzZeilen);

for inserting a summary row.

Thanks a lot for Your valuable help!

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Thursday, April 2, 2009 @ 22:18:56  

we will investigate this problem.

Since we don't have the table data you are using , it might be difficult to reproduce this. Can you create a standalone code with some array data to reproduce this problem? We will immediately look into it.

Safaga38
Private

Gender: Male
Location:
Registered: Aug 2008
Status: Offline
Posts: 5

Click here to see the profile for Safaga38 Send email to Safaga38 Find more posts by Safaga38 Edit or delete this message Reply w/Quote
Posted Friday, September 18, 2009 @ 15:28:55  

Here is the code for the first problem (Blank page after print). I noticed that the blank page is sometimes printed before the table itself (?????):

import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

//Import der QuickTable-JavaBean
import quick.dbtable.*;

public class OrderList extends JFrame implements ActionListener {
public static final long serialVersionUID = 93l;
static final String status_OFF = "OFF";
static final String status_GLF = "GLF";
static final String status_ERL = "ERL";
static final String status_NAF = "NAF";
static final String status_RUF = "RUF";
static final String status_STO = "STO";
static final String status_VSB = "VSB";
static final String status_BEZ = "BEZ";
static final String status_NBEZ = "Not BEZ";
static final String status_OVNGR = "OFF, VSB, NAF, GLF, RUF";

String filterString;
DBTable orderTable;
JButton printButton;
JButton previewButton;
JButton refreshButton;
JComboBox statusCombo;
JButton filterButton;
JLabel filterLabel;
JTextField filterText;
OrderListModel myCellModel = new OrderListModel();
OrderPrintProperties printProp = new OrderPrintProperties(PrintProperties.LANDSCAPE);

Object[][] data = {
{"Mueller", "5164", null, null, "31", "Aalen", "open", null, "0", "0", "0.00", "0", null, null, null},
{"Weber", "2439", null, null, "31", "Berlin", "open", null, "0", "0", "0.00", "0", null, null, null},
{"Massena", "8797", "08.05.2009", "05.05.09", "19", "New York", "open", null, "0", "1", "348.20", "3", null, null, null},
{"Bonaparte", "9876", "11.05.2009", "08.05.09", "19", "London", "open", null, "0", "1", "573.17", "3", null, null, null},
{"Trogler", "9172", "14.05.2009", null, "20", "Paris", "open", null, "0", "0", "0.00", "0", "0", "Wenger", null, null},
{"Hansen", "3261", "15.05.2009", "14.05.09", "20", "Antwerp", "open", null, "0", "0", "0.00", "3", null, null, null},
{"Anderson", "1821", "28.05.-29.05.2009", null, "22", "Brussels", "open", null, "0", "0", "0.00", "3", null, null, null},
{"Lye", "7320", "02.06.2009", null, "23", "Tokio", "open", "4M/2T", "0", "0", "0.00", "3", null, null, null},
{"Boguslawski", "8374", "05.06.2009", "28.05.09", "23", "Beijing", "open", "3M 0,5T", "0", "0", "0.00", "0", null, null, null},
{"Bauer", "9910", "15.07.2009", "13.07.09", "29", "New Delhi", "open", "2M/1T", "0", "0", "0.00", "3", null, null, null},
{"Friedrich", "8155", null, null, "30", "Moskow", "open", null, "0", "0", "0.00", "0", "Flowers", null, null},
{"Sixpack", "7171", null, null, "30", "Moskow", "open", null, "0", "0", "0.00", "0", "Flowers", null, null},
{"Johnson", "6127", null, null, "30", "Antwerp", "open", null, "0", "0", "0.00", "0", "Deejay", null, null}
};

public OrderList(String title) {
super(title);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
setSize((int)(dim.getWidth() - 20), 614);
setResizable(false);
setLocation((int)(dim.getWidth() - (dim.getWidth() - 20))/2, (int)(dim.getHeight() - 614)/2);

try {
orderTable = new DBTable();
JTable jTable = orderTable.getTable();
JTableHeader jTableHeader = jTable.getTableHeader();
jTableHeader.setBorder(new javax.swing.border.LineBorder(Color.GRAY, 1));
getContentPane().add(orderTable, BorderLayout.CENTER);
orderTable.setSkin(new StatusSkin());
orderTable.setDBTableLocale(Locale.GERMAN);
createToolBar();
showAuftraege(status_OVNGR);
}
catch(SQLException sqle) {
}
}

public void actionPerformed(ActionEvent e) {
if(e.getSource() == printButton) {
orderTable.setSkin(new PrintSkin());
orderTable.setCellPropertiesModel(myCellModel);
orderTable.print(printProp);
}
else if(e.getSource() == previewButton) {
orderTable.setSkin(new PrintSkin());
orderTable.setCellPropertiesModel(myCellModel);
orderTable.printPreview(printProp);
}
else if(e.getSource() == refreshButton) {
try {
filterText.setText("");
statusCombo.setSelectedItem(status_OVNGR);
orderTable.refresh();
}
catch(SQLException sqle) {
}
}
else if(e.getSource() == filterButton) {
filterString = filterText.getText().toUpperCase();

if(filterString != null && !("".equals(filterString))) {
orderTable.filter(new MarketFilter());
}
else {
orderTable.filter(null);
}
}
else if(e.getSource() == statusCombo) {
String selection = (String)statusCombo.getSelectedItem();

if(selection.equals(status_OFF)) {
try {
showAuftraege(status_OFF);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_GLF)) {
try {
showAuftraege(status_GLF);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_ERL)) {
try {
showAuftraege(status_ERL);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_NAF)) {
try {
showAuftraege(status_NAF);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_RUF)) {
try {
showAuftraege(status_RUF);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_STO)) {
try {
showAuftraege(status_STO);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_VSB)) {
try {
showAuftraege(status_VSB);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_BEZ)) {
try {
showAuftraege(status_BEZ);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_NBEZ)) {
try {
showAuftraege(status_NBEZ);
}
catch(SQLException sqle) {
}
}
else if(selection.equals(status_OVNGR)) {
try {
showAuftraege(status_OVNGR);
}
catch(SQLException sqle) {
}
}
}
}

private void showAuftraege(String afStati) throws SQLException {
String searchString = null;

if(afStati.equals(status_OFF) || afStati.equals(status_GLF) || afStati.equals(status_ERL) ||
afStati.equals(status_NAF) || afStati.equals(status_RUF) || afStati.equals(status_STO) ||
afStati.equals(status_VSB) || afStati.equals(status_BEZ)) {
searchString = "AND status.status_knz = '" + afStati + "' ";
}
else if(afStati.equals(status_NBEZ)) {
searchString = "AND status.status_knz <> '" + status_BEZ + "' ";
}
else if(afStati.equals(status_OVNGR)) {
searchString = "AND status.status_knz IN('OFF', 'VSB', 'NAF', 'GLF', 'RUF') ";
}

orderTable.clearAllSettings();

// SQL string for showing table data
/* orderTable.setSelectSql("SELECT afg_matchcode, auf_ext_afnr, auf_termin, auf_lieftermin, " +
"auf_ausfkw, markt_matchcode, status_text, auf_zeitaufw, auf_anz_colli, " +
"auf_anz_paletten, auf_wert, auf_skonto, mitarb_matchcode, " +
"CONCAT(SUBSTR(auf_termin, LENGTH(auf_termin) - 3, 4), " +
"SUBSTR(auf_termin, LENGTH(auf_termin) - 6, 2), " +
"SUBSTR(auf_termin, LENGTH(auf_termin) - 9, 2), " +
"IFNULL(mitarb_matchcode, ' ')) as normaldate, " +
"CONCAT(SUBSTR(auf_termin, LENGTH(auf_termin) - 3, 4), " +
"SUBSTR(auf_termin, 4, 2), SUBSTR(auf_termin, 1, 2), " +
"IFNULL(mitarb_matchcode, ' ')) as zeitraum " +
"FROM afgeber, markt, status, mitarbeiter " +
"right join auf_kopf on auf_mitarb_id1 = mitarb_id " +
"WHERE auf_kopf.auf_afgeber_id = afgeber.afg_id " +
"AND auf_kopf.auf_markt_id = markt.markt_id " +
"AND auf_kopf.auf_status_id = status.status_id " +
"AND auf_ext_afnr NOT LIKE 'VDS%' " +
searchString +
"ORDER BY CASE WHEN LENGTH(auf_termin) <= 10 " +
"THEN normaldate ELSE zeitraum END"); */

// Loading of model for the display of the table data
// orderTable.createColumnModelFromQuery();

// Loading of the selected data into the table
try {
orderTable.refresh(data);
}
catch(Exception e) {
}

// Formatting of 0. column (afg_matchcode)
Column c = orderTable.getColumn(0);
c.setReadOnly(true);
c.setHeaderValue("Customer");
c.setPreferredWidth(819/10);

// Formatting of 1. column (auf_ext_afnr)
c = orderTable.getColumn(1);
c.setReadOnly(true);
c.setHeaderValue("Order No.");
c.setPreferredWidth(819/14);

// Formatting of 2. column (auf_termin)
c = orderTable.getColumn(2);
c.setReadOnly(true);
c.setHeaderValue("FT");
c.setPreferredWidth(819/12);

// Formatting of 3. column (auf_lieftermin)
c = orderTable.getColumn(3);
c.setReadOnly(true);
c.setType(java.sql.Types.DATE);
c.setDateFormat("dd.MM.yy");
c.setHeaderValue("LT");
c.setPreferredWidth(819/20);

// Formatting of 4. column (auf_ausfkw)
c = orderTable.getColumn(4);
c.setReadOnly(true);
c.setType(Types.NUMERIC);
c.setHeaderValue("KW");
c.setPreferredWidth(819/30);

// Formatting of 5. column (markt_matchcode)
c = orderTable.getColumn(5);
c.setReadOnly(true);
c.setHeaderValue("Market");
c.setPreferredWidth(819/6);

// Formatting of 6. column (status_text)
c = orderTable.getColumn(6);
c.setReadOnly(true);
c.setHeaderValue("Status");
c.setPreferredWidth(819/22);

// Formatting of 7. column (auf_zeitaufw)
c = orderTable.getColumn(7);
c.setReadOnly(true);
c.setHeaderValue("Time");
c.setPreferredWidth(819/12);

// Formatting of 8. column (auf_anz_colli)
c = orderTable.getColumn(8);
c.setReadOnly(true);
c.setType(Types.NUMERIC);
c.setHeaderValue("Colli");
c.setPreferredWidth(819/30);

// Formatting of 9. column (auf_anz_paletten)
c = orderTable.getColumn(9);
c.setReadOnly(true);
c.setType(Types.NUMERIC);
c.setHeaderValue("Pal.");
c.setPreferredWidth(819/30);

// Formatting of 10. column (auf_wert)
c = orderTable.getColumn(10);
c.setReadOnly(true);
c.setType(Types.DOUBLE);
c.setPrecision(9);
c.setScale(2);
c.setHeaderValue("WW €");
c.setPreferredWidth(819/18);

// Formatting of 11. column (auf_skonto)
c = orderTable.getColumn(11);
c.setReadOnly(true);
c.setType(Types.NUMERIC);
c.setHeaderValue("Sk %");
c.setPreferredWidth(819/30);

// Formatting of 12. column (auf_mitarb_id1 => mitarb_matchode)
c = orderTable.getColumn(12);
c.setReadOnly(true);
c.setHeaderValue("Staff");
c.setPreferredWidth(819/9);

// Formatting of 13. column (normaldate)
c = orderTable.getColumn(13);
c.setVisible(false);

// Formatting of 14. column (zeitraum)
c = orderTable.getColumn(14);
c.setVisible(false);

orderTable.setSkin(new PrintSkin());
orderTable.setCellPropertiesModel(myCellModel);
}

class OrderListModel extends CellPropertiesModel {
public static final long serialVersionUID = 94l;

public int getAlignment(int row, int col) {
if(col == 1 || col == 2 || col == 3 || col == 4 || col == 6)
return SwingConstants.CENTER;
else if(col == 7 || col == 8 || col == 9 || col == 10 || col == 11)
return SwingConstants.RIGHT;
else
return SwingConstants.LEFT;
}

public Color getBackground(int row, int col) {
if(row %2 == 0)
return null;
else
return new Color(215, 222, 242);
}

public Color getSelectionForeground(int row, int col) {
return new Color(247, 71, 40);
}

public Color getSelectionBackground(int row, int col) {
return new Color(249, 252, 112);
}
}

class MarketFilter implements Filter {
public static final long serialVersionUID = 87l;

public int[] filter(TableModel tm) {
Pattern pattern = null;
Matcher matcher = null;
boolean b = false;
Vector<Integer> v = new Vector<Integer>();

// Search all lines for the given value
for(int i = 0; i < tm.getRowCount(); i++) {
try{
pattern = Pattern.compile(filterString);
matcher = pattern.matcher(((String)tm.getValueAt(i, 6)).toUpperCase());
b = matcher.find();
}
catch(PatternSyntaxException pse){
}
if(b == true) {
v.addElement(new Integer(i));
}
}

// Construction of the array containing the filtered lines
int arr[] = new int[v.size()];
for(int i = 0; i < v.size(); i++) {
arr[i] = ((Integer)v.elementAt(i)).intValue();
}

return arr;
}
}

class OrderPrintProperties extends PrintProperties {
public static final long serialVersionUID = 95l;
String header = "Order list";

public OrderPrintProperties(int ausrichtung) {
super(ausrichtung);
}

public int getBorderWidth() {
return 29;
}

public int getBorderHeight() {
return 32;
}

public String getHeader() {
return header + "\n\n\n";
}

public String getFooter() {
DateFormat df = DateFormat.getDateInstance();
String s = df.format(new java.util.Date());
return "\nPage: %1%\nDate: " + s;
}

public int getHeaderAlign() {
return SwingUtilities.CENTER;
}

public int getFooterAlign() {
return SwingUtilities.CENTER;
}

public Color getHeaderColor() {
return Color.BLUE;
}

public Color getFooterColor() {
return Color.BLUE;
}
}

class StatusSkin extends Skin {
public static final long serialVersionUID = 19l;

@SuppressWarnings("unchecked")
public StatusSkin() {
put(Skin.TABLE_FOREGROUND, new Color(68, 105, 199));
put(Skin.TABLE_FONT, new Font("Arial",Font.BOLD,12));
put(Skin.HEADER_FOREGROUND, new Color(98, 99, 15));
put(Skin.HEADER_FONT, new Font("Arial",Font.BOLD,12));
put(Skin.FOCUS_CELL_FOREGROUND, new Color(247, 71, 40));
put(Skin.FOCUS_CELL_BACKGROUND, new Color(249, 252, 112));
put(Skin.FOCUS_CELL_HIGHLIGHT_BORDER, new LineBorder(new Color(68, 105, 199), 1));
}
}

class PrintSkin extends Skin {
public static final long serialVersionUID = 75l;

@SuppressWarnings("unchecked")
public PrintSkin() {
put(Skin.TABLE_FOREGROUND, Color.BLACK);
put(Skin.TABLE_FONT, new Font("Arial", Font.BOLD, 7));
put(Skin.HEADER_FOREGROUND, Color.BLACK);
put(Skin.HEADER_FONT, new Font("Arial", Font.BOLD, 7));
}
}

private void createToolBar() {
JToolBar jb = new JToolBar();
Insets ins = new Insets(0, 0, 0, 0);
printButton = new JButton(new ImageIcon(this.getClass().getResource("/images/print.gif")));
printButton.setToolTipText("Print");
printButton.setMargin(ins);
printButton.setAlignmentY(Component.CENTER_ALIGNMENT);
printButton.addActionListener(this);
jb.add(printButton);

previewButton = new JButton(new ImageIcon(this.getClass().getResource("/images/print.gif")));
previewButton.setToolTipText("Print preview");
previewButton.setMargin(ins);
previewButton.setAlignmentY(Component.CENTER_ALIGNMENT);
previewButton.addActionListener(this);
jb.add(previewButton);

refreshButton = new JButton(new ImageIcon(this.getClass().getResource("/images/refresh.gif")));
refreshButton.setToolTipText("Refresh");
refreshButton.setMargin(ins);
refreshButton.setAlignmentY(Component.CENTER_ALIGNMENT);
refreshButton.addActionListener(this);
jb.add(refreshButton);

jb.addSeparator();
jb.addSeparator();

filterLabel = new JLabel("Market ");
filterLabel.setAlignmentY(Component.CENTER_ALIGNMENT);
jb.add(filterLabel);

filterText = new JTextField();
filterText.setMaximumSize(new Dimension(195, 20));
filterText.setColumns(60);
filterText.setAlignmentY(Component.CENTER_ALIGNMENT);
jb.add(filterText);

filterButton = new JButton(" Search ");
filterButton.setMargin(ins);
filterButton.setAlignmentY(Component.CENTER_ALIGNMENT);
filterButton.addActionListener(this);
jb.add(filterButton);

jb.addSeparator();
jb.addSeparator();

JLabel j2 = new JLabel("Status ");
j2.setAlignmentY(Component.CENTER_ALIGNMENT);
jb.add(j2);

statusCombo = new JComboBox();
statusCombo.setMaximumSize(new Dimension(160,20));
statusCombo.setAlignmentY(Component.CENTER_ALIGNMENT);
statusCombo.addItem("OFF");
statusCombo.addItem("GLF");
statusCombo.addItem("ERL");
statusCombo.addItem("NAF");
statusCombo.addItem("RUF");
statusCombo.addItem("STO");
statusCombo.addItem("VSB");
statusCombo.addItem("BEZ");
statusCombo.addItem("Nicht BEZ");
statusCombo.addItem("OFF, VSB, NAF, GLF, RUF");
statusCombo.addActionListener(this);
statusCombo.setSelectedItem(status_OVNGR);
jb.add(statusCombo);

getContentPane().add(jb, BorderLayout.NORTH);
}

public static void main(String[] args) {
OrderList orderList = new OrderList("Order list");
orderList.setVisible(true);
}
}

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Monday, September 6, 2010 @ 11:57:16  

This issue is fixed. Please download latest version.
Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios