|
-
Dec 3rd, 2003, 03:03 PM
#1
Thread Starter
Addicted Member
JTextPane?
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?
To protect time is to protect everything...
-
Dec 9th, 2003, 01:59 AM
#2
Dazed Member
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.
Code:
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();
}
}
-
Dec 15th, 2003, 01:28 PM
#3
Thread Starter
Addicted Member
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...
To protect time is to protect everything...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|