Note that there are some explanatory texts on larger screens.

plurals
  1. POJTextPane doesn't display JScrollPane and doesn't Wrap Text
    primarykey
    data
    text
    <p>I need to display links so I'm using JTextPane with setContentType. However, the content doesn't wrap and there's no scroll. The content of JTextPane will be returned from a RSS feed. Here's the full code: </p> <pre><code>import java.awt.*; import javax.swing.*; class Main extends JFrame { JFrame frame; JTabbedPane tabbedPane; JPanel home, news; public Main() { setTitle("My Title" ); setSize( 900, 600 ); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); home(); news(); tabbedPane = new JTabbedPane(); tabbedPane.addTab( " Home", home ); tabbedPane.addTab( "News", news ); JPanel framePanel = new JPanel(); framePanel.setLayout(new BorderLayout()); framePanel.add( tabbedPane, BorderLayout.CENTER ); getContentPane().add( framePanel ); } public void home() { home = new JPanel(); // some stuffs here } public void news() { news = new JPanel(); JTextPane newsTextPane = new JTextPane(); newsTextPane.setContentType("text/html"); newsTextPane.setEditable(false); JScrollPane scrollPane = new JScrollPane(newsTextPane); scrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); news.add(scrollPane); RSS reader = RSS .getInstance(); reader.writeNews(); String rssNews = reader.writeNews(); newsTextPane.setText(rssNews); } public static void main( String args[] ) { RSS reader = RSS.getInstance(); reader.writeNews(); Main mainFrame = new Main(); mainFrame.setVisible( true ); mainFrame.setDefaultCloseOperation( EXIT_ON_CLOSE ); } } </code></pre> <p>My result: <img src="https://i.stack.imgur.com/nQD3r.png" alt="Screenshot"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload