-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.3.0
-
x86
-
generic
Name: jbT81659 Date: 08/30/2000
OS: Win98 (English, Arabic, Hebrew)
JDK: jdk1.3.0-FCS_C
Printing bidi text displayed in JTextPane fails.Bidi text is not printed.
To reproduce bug:
1- Compile and run the folowing code
2- To print frame, press the "Print entire frame" button
3- Compare the printed frame with the frame displayed on screen.
4- Note that bidi text displayed in JTextPane did not print on paper.
---------Code----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.GridLayout;
import java.util.*;
import java.awt.font.*;
import javax.swing.text.*;
public class JTP1_implicit_left extends JFrame implements ActionListener
{
JLabel l, label, label2;
JLabel whatisIt;
JButton printFrame, printInside;
JPanel panel;
JPanel p;
JTextPane pane;
public JTP1_implicit_left()
{
super("JTP1_implicit_left");
printFrame = new JButton("Print entire frame ");
printInside = new JButton("print components inside frame");
printFrame.addActionListener(this);
printInside.addActionListener(this);
panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
l = new JLabel("JTP1 implicit, leftt");
pane = new JTextPane();
pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,10));
l.setVerticalAlignment(SwingConstants.BOTTOM);
l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,10));
pane.setPreferredSize(new Dimension(180,250));
pane.setText("This is a test \u0647\u0630\u0627\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641");
p.add(l);
p.add(pane);
p.setPreferredSize(new Dimension(175,160));
panel.add(p);
whatisIt = new JLabel("This example prints JTextPane, implicit, leftt");
panel.add(printFrame);
panel.add(printInside);
panel.add(whatisIt);
panel.setPreferredSize(new Dimension(200,1900));
JScrollPane scroll = new JScrollPane(panel);
scroll.setPreferredSize(new Dimension(300,260));
getContentPane().add(scroll);
}
public void actionPerformed(ActionEvent e)
{
printFrame.setEnabled(false);
printInside.setEnabled(false);
Properties prnProp = new Properties();
PrintJob prnJob = Toolkit.getDefaultToolkit().getPrintJob(JTP1_implicit_left.this, "TEST", prnProp);
if (prnJob != null)
{
JButton b = (JButton)e.getSource();
Component c;
Graphics prnGr = prnJob.getGraphics();
c = JTP1_implicit_left.this;
//Print inside the center of the page
if (b == printInside)
{
Dimension od = c.getSize(); //Object size
Dimension pd = prnJob.getPageDimension(); //Page size
prnGr.translate((pd.width-od.width)/2, (pd.height-od.height)/2);
//c.printAll(prnGr);
c.print(prnGr);
prnGr.dispose(); //Prints here
prnJob.end(); //Release printer
}
else
if (b == printFrame)
{
Dimension od = c.getSize(); //Object size
Dimension pd = prnJob.getPageDimension(); //Page size
prnGr.translate((pd.width-od.width)/2, (pd.height-od.height)/2);
c.printAll(prnGr);
prnGr.dispose(); //Prints here
prnJob.end(); //Release printer
}
printFrame.setEnabled(true);
printInside.setEnabled(true);
}
}
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch (Exception e)
{
System.err.println("Couldn't use the cross-platform look and feel: " + e);
}
JFrame frame = new JTP1_implicit_left();
WindowListener l = new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
};
frame.addWindowListener(l);
frame.pack();
frame.setVisible(true);
}
}
-----------------------
WorkAround:
======================================================================