Click to See Complete Forum and Search --> : JTextPane?
Virtual24
Dec 3rd, 2003, 02:03 PM
I have a JTextPane added to a JInternalFrame. I sought to make the JTextPane stop its word wrapping by overriding the method getScrollableTracksViewportWidth() in JTextPane. This works, however, now the JTextPane simply resizes itself to the longest string it contains, and the rest of the JInternalFrame shows up gray. ( if there is nothing in the JTextPane, you can only se a sliver of white at the side of the window ) I want to make the background of the JInternalFrame white so you cant see this problem. I've tried setBackground( Color.white ); but it doesn't work. Anyone know why?
Dillinger4
Dec 9th, 2003, 12:59 AM
Yeah for some reason you cannot toggle the Line Wrap on and off like in a JTextArea. Why would you want to set LineWrapping off anyway? In the following code i added a JTextPane to a JInternalFrame in the upper region so the JTextPane does not take up the whole JInternalFrame. I then set the background color of the JInternalFrame to red. Everything seems to work fine.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Frame{
private JFrame jf;
private JDesktopPane jdp;
private JInternalFrame jif;
private JTextPane jtp;
private Container c;
public Frame(String title){
jf = new JFrame("JFrame");
jdp = new JDesktopPane();
jif = new JInternalFrame("InternalFrame",true,true,true,true);
jtp = new JTextPane();
}
public void addListener(){
jf.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent evt){
System.exit(0);
}
});
}
public void assemble(){
c = jf.getContentPane();
c.add(jdp,BorderLayout.CENTER);
jdp.add(jif);
jif.getContentPane().add(jtp, BorderLayout.NORTH);
jif.setBackground(Color.RED);
jf.setSize(550,350);
jif.setSize(200,150);
jf.setVisible(true);
jif.setVisible(true);
}
}
public class S{
public static void main(String[] args){
Frame f = new Frame("Example");
f.addListener();
f.assemble();
}
}
Virtual24
Dec 15th, 2003, 12:28 PM
I have a JScrollPane added in there, under the JTextPane... When text is entered that goes past the WIDTH of the window, it doesn't scroll horizontally, just word wraps. I want to turn this affect off.
When I tried to set the bg color of the jinternal, it didn't do anything... dunno why...
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.