-
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 english (LTR) only text from JTextField with explicit RTL is broken.
To reproduce bug:
1- Compile and run the following code:
2- Press the "Print entire Frame" to print the application frame
3- Compare the printed JTextField with the displayed JTextField
4- Note that English text displayed in JTextField is not printed
------------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 JTF2_explicit_RTL_right extends JFrame implements ActionListener
{
JLabel l, label, label2;
JLabel whatisIt;
JButton printFrame, printInside;
JPanel panel;
JTextField field;
JPanel p;
JTextArea area;
JTextPane pane;
public JTF2_explicit_RTL_right()
{
super("JTF2_explicit_RTL_right");
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 GridLayout(2,1));
l = new JLabel("JTF2, explicit RTL, right");
l.setVerticalAlignment(SwingConstants.BOTTOM);
l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,10));
field = new JTextField(10);
field.setHorizontalAlignment(JTextField.RIGHT);
field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,10));
field.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
field.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(field);
p.setPreferredSize(new Dimension(200, 50));
panel.add(p);
whatisIt = new JLabel("This example prints JTextField, explicit RTL, right");
panel.add(printFrame);
panel.add(printInside);
panel.add(whatisIt);
panel.setPreferredSize(new Dimension(150,150));
JScrollPane scroll = new JScrollPane(panel);
scroll.setPreferredSize(new Dimension(250,250));
getContentPane().add(scroll);
}
public void actionPerformed(ActionEvent e)
{
printFrame.setEnabled(false);
printInside.setEnabled(false);
Properties prnProp = new Properties();
PrintJob prnJob = Toolkit.getDefaultToolkit().getPrintJob(JTF2_explicit_RTL_right.this, "TEST", prnProp);
if (prnJob != null)
{
JButton b = (JButton)e.getSource();
Component c;
Graphics prnGr = prnJob.getGraphics();
c = JTF2_explicit_RTL_right.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 JTF2_explicit_RTL_right();
WindowListener l = new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
};
frame.addWindowListener(l);
frame.pack();
frame.setVisible(true);
}
}
----------------------------------
WorkAround:
======================================================================