Hi,
I was trying the following code and it sucessfully but there is a problem it gives me a border around the container. I failed to understand how to remove it. Can you please help me?
regards,
Arun
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class testJTextPane extends JFrame
{
JTextPane jtp;
public testJTextPane()
{
Containercont = getContentPane();
cont.setBackground(new Color(140,199,222));
cont.setFont(new Font("arial",Font.BOLD,11));
cont.setLayout(null);
jtp = new JTextPane();
jtp.setEditable(false);
jtp.setBackground(new Color(140,199,222));
JScrollPane paneScrollPane = new JScrollPane(jtp);
paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
paneScrollPane.setPreferredSize(new Dimension(250, 155));
paneScrollPane.setMinimumSize(new Dimension(10, 10));
paneScrollPane.setBounds(50,30,200,200);
cont.add(paneScrollPane);
Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
Style regular = jtp.addStyle("regular", def);
StyleConstants.setFontFamily(def, "SansSerif");
Style s = jtp.addStyle("italic", regular);
StyleConstants.setItalic(s, true);
StyleConstants.setForeground(s,Color.red);
Style s1 = jtp.addStyle("bold", regular);
StyleConstants.setBold(s, true);
Document doc = jtp.getDocument();
String msg = "This is a test msessage to check the JTextPane capability.Again repeating for checking for scroll pane This is a test msessage to check the JTextPane capability. once Again repeating for checking for scroll pane This is a test msessage to check the JTextPane capability. one more time Again repeating for checking for scroll pane This is a test msessage to check the JTextPane capability";
try
{
String msg1 = msg.substring(0,10);
String msg2 = msg.substring(10,23);
String msg3 = msg.substring(23);
doc.insertString(doc.getLength(),msg1,s);
doc.insertString(doc.getLength(),msg2,s1);
doc.insertString(doc.getLength(),msg3,s);
}
catch (BadLocationException ble)
{
System.err.println("Couldn't insert initial text.");
}
}
public static void main(String[] args)
{
//testJTextPane xx = new testJTextPane();
JFrame xx = new testJTextPane();
xx.setSize(300,300);
xx.show();
}
}