-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.3.0
-
x86
-
generic
Name: jbT81659 Date: 04/06/2000
Using the mouse or Shift + right (left)arrow to select text causes the
text to disappear under all platforms.
To reproduce bug:
Compile and run attached code.
Try selecting text using mouse.
Note that text disappears.Try selecting text using Shift + right( left) arrowes
Note that text disappears.
-----Code--------
/* Copyright (c) Sun Microsystems 1999
$Header: /home/sun/src/JDK1.2/jTextPane.java,v 1.17 2000/03/30 08:13:08 isam Exp $
*/
import java.awt.*;
import java.awt.font.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.text.*;
public class jTextPane extends JApplet
{
public void init()
{
jTextPane1 jpane = new jTextPane1();
getContentPane().add(jpane);
}
public static void main(String[] args)
{
JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
frame.setContentPane(new jTextPane1());
frame.pack();
frame.setVisible(true);
frame.addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent e)
{
System.exit(0);
}
});
}
}
class jTextPane1 extends JPanel
{
public jTextPane1()
{
JLabel l;
JPanel p;
JTextField field;
JTextArea area;
JTextPane pane;
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
l = new JLabel("JTP1 implicit, left");
pane = new JTextPane();
pane.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
l.setVerticalAlignment(SwingConstants.BOTTOM);
l.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
pane.setPreferredSize(new Dimension(320, 320));
pane.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
p.add(l);
p.add(pane);
p.setPreferredSize(new Dimension(450,450));
panel.add(p);
p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
l = new JLabel("JTP2 explicit RTL, left");
pane = new JTextPane();
pane.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
l.setVerticalAlignment(SwingConstants.BOTTOM);
l.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
pane.setPreferredSize(new Dimension(320, 320));
pane.setText("\u0053\u0074\u0061\u0072\u0074\u0020\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
p.add(l);
p.add(pane);
p.setPreferredSize(new Dimension(500,500));
panel.add(p);
p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
l = new JLabel("JTP3 explicit RTL, right");
l.setVerticalAlignment(SwingConstants.BOTTOM);
l.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
pane = new JTextPane();
pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
MutableAttributeSet rightStyle;
rightStyle = new SimpleAttributeSet();
StyleConstants.setAlignment(rightStyle,StyleConstants.ALIGN_RIGHT);
StyledDocument doc = pane.getStyledDocument();
SimpleAttributeSet a = new SimpleAttributeSet();
//pane.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
pane.setText("\u0053\u0074\u0061\u0072\u0074\u0020\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
pane.setParagraphAttributes(rightStyle,true);
p.setPreferredSize(new Dimension(500,500));
p.add(l);
p.add(pane);
pane.setPreferredSize(new Dimension(320, 320));
panel.add(p);
p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
l = new JLabel("JTP4 explicit LTR, left");
l.setVerticalAlignment(SwingConstants.BOTTOM);
l.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
pane = new JTextPane();
pane.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
pane.setPreferredSize(new Dimension(320, 320));
pane.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
p.add(l);
p.add(pane);
p.setPreferredSize(new Dimension(500,500));
panel.add(p);
panel.setPreferredSize(new Dimension(500,2000));
JScrollPane scroll = new JScrollPane(panel);
scroll.setPreferredSize(new Dimension(650,450));
add(scroll);
}
}
WorkAround:
======================================================================
- duplicates
-
JDK-4327136 MerlinF-Text Selection-Not able to select all text-Stylepad Demo
-
- Closed
-