Table print() dialog behind alwaysOnTop Frame
I'm using windows Xp service Pack 2 , java 6
I got a JTable which is inside my always on Top JFrame,
if I call .print(), the user can't use the print dialog, because it is block by the JFrame.
Any Idea on how this can be fixed?
I think the JTable.print() dialog that appers dosen't have a createDialog( )?
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PrinterException;
import javax.swing.table.DefaultTableModel;
class TablePrintDialogBehind{
boolean x =false;
String[] cNames ={"A","B","C","D","E","F","G","H"};
Object[][] datos ={{"","","","","","","",""}};
TablePrintDialogBehind(){
final JFrame frame =new JFrame();
frame.setLayout(new BorderLayout());
DefaultTableModel model =new DefaultTableModel(datos ,cNames);
final JTable table =new JTable(model);
JButton print =new JButton("Print");
print.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
try{
table.print();
}catch(PrinterException a){
a.printStackTrace();
}
}});
JButton onTop =new JButton("onTop");
onTop.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
frame.setAlwaysOnTop(x);
frame.setTitle("ON TOP - "+x);
x = !x;
}
});
frame.add(table, BorderLayout.CENTER);
frame.add(print, BorderLayout.SOUTH);
frame.add(onTop, BorderLayout.NORTH);
frame.setSize(400,400);
frame.setVisible(true);
}
publicstaticvoid main(String [] args){
SwingUtilities.invokeLater(new Runnable(){
publicvoid run(){
new TablePrintDialogBehind();
}});
}
}

