• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can you help me to remove this border?

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}
}

 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The default Border for JComponents are defined by the current look and fell. If you don't want any border (which is around your JScrollPane) just set the Border to null thus:

Hope this helps.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes,u can set the components border to null or
create a Empty border as follows...
paneScrollPane.setBorder(BorderFactory.createEmptyBorder());
 
Do you pee on your compost? Does this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic