Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4133140

JTextPane horizontal scrolling not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.2.0
    • client-libs
    • 1.2fcs
    • x86
    • windows_95
    • Not verified



      Name: rk38400 Date: 04/28/98


      HORIZONTAL_SCROLLBAR_AS_NEEDED is not working:

      import com.sun.java.swing.*;
      import com.sun.java.swing.text.*;
      import java.awt.*;
      import java.io.*;

      // a JTextPane containing the contents of a file
      class FilePane extends JFrame {
        
        public static void main (String [] argv) {
          SystemLAF.setSystemLAF();
          String fileName = (argv.length > 0) ? argv[0] : "FilePane.java";
          new FilePane(fileName);
        }

        FilePane (String fileName) {
          byte [] contents = null;
          setName(fileName);
          setSize(300, 500);
          addWindowListener (new WindowCloser ());
          try {
            FileInputStream FIS = new FileInputStream(fileName);
            BufferedInputStream BS = new BufferedInputStream(FIS);
            int siz = BS.available();
            System.out.println("size=" + siz);
            contents = new byte[siz];
            int nread = BS.read(contents, 0, siz);
          } catch (Exception e) {
            e.printStackTrace();
            return;
          }

          JTextPane textPane = new JTextPane();
          textPane.setText(new String(contents));
          JScrollPane scroller = new JScrollPane(textPane,
      ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
      ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
          JPanel panel = new JPanel();
          panel.setLayout(new BorderLayout());
          panel.add(scroller, BorderLayout.CENTER);
          getContentPane().add(panel);
          setVisible(true);
        }
      }
      (Review ID: 29184)
      ======================================================================

            tprinzing Tim Prinzing (Inactive)
            rkarsunw Ralph Kar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: