Java 8 JTextPane - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JTextPane class.

This code example shows how to use the following methods:setBackground, setFont, setForeground
    catch (Exception e) {
      e.printStackTrace();
      props = new Properties();
    } 
     
    result = new JTextPane();
    if (props.getProperty("Syntax", "false").equals("true")) {
      doc    = new SyntaxDocument(props);
      result.setDocument(doc);
      result.setBackground(doc.getBackgroundColor());
    } 
    else { 
      result.setForeground(VisualizeUtils.processColour(props.getProperty("ForegroundColor", "black"), Color.BLACK));
      result.setBackground(VisualizeUtils.processColour(props.getProperty("BackgroundColor", "white"), Color.WHITE));
      result.setFont(new Font(props.getProperty("FontName", "monospaced"), Font.PLAIN, Integer.parseInt(props.getProperty("FontSize", "12"))));
    } 
     
    return result;
  } 
   
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setContentType, setText, getDocument, setEditable, setMargin
	String textValue = text.getText();
	if (! (textValue.startsWith("<html>") && textValue.endsWith("</html>"))) {
	    textValue = "<html><body>" + textValue + "</body></html>";
	} 
 
	textArea = new JTextPane();
	textArea.setContentType("text/html");
	textArea.setMargin(new Insets(0, 0, 0, 0));
	textArea.setEditable(false);
 
	Font font = UIManager.getFont("Label.font");
	String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }";
	HTMLDocument doc = (HTMLDocument) textArea.getDocument();
	doc.getStyleSheet().addRule(bodyRule);
 
	textArea.setText(textValue);
    } 
 
    @Override 
    public Component getComponent() {
	return textArea;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setText
      this.text = text;
      String htmltxt = "<html><font size=5>"+text+"</font></html>";
       
      super.setText(htmltxt);
       
      JTextPane tp = new JTextPane();
      tp.setText(htmltxt);
 
      if (getPreferredSize().getWidth() > maximum_width){
          
         htmltxt = "<html><div width='"+maximum_width+"'><font size=5>"+text+"</font></div></html>";
         super.setText(htmltxt);
      } 
       
      setSize(getPreferredSize());
   } 
       
    
   @Override 
   public String getText(){
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setBackground, setFont, setForeground
    catch (Exception e) {
      e.printStackTrace();
      props = new Properties();
    } 
     
    result = new JTextPane();
    if (props.getProperty("Syntax", "false").equals("true")) {
      doc    = new SyntaxDocument(props);
      result.setDocument(doc);
      result.setBackground(doc.getBackgroundColor());
    } 
    else { 
      result.setForeground(VisualizeUtils.processColour(props.getProperty("ForegroundColor", "black"), Color.BLACK));
      result.setBackground(VisualizeUtils.processColour(props.getProperty("BackgroundColor", "white"), Color.WHITE));
      result.setFont(new Font(props.getProperty("FontName", "monospaced"), Font.PLAIN, Integer.parseInt(props.getProperty("FontSize", "12"))));
    } 
     
    return result;
  } 
   
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setBackground, setPreferredSize, setText, setEditable, setHighlighter
  private Component createDocumentationPane()
  { 
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    String string = Messages.getInstance().getString("ConnectionEditorDialog.Documentation");
    JTextPane comp = new JTextPane();
    comp.setPreferredSize(new Dimension(600, 100));
    comp.setText(string);
    comp.setBackground(null);
    comp.setEditable(false);
    comp.setHighlighter(null);
    panel.add(comp, BorderLayout.CENTER);
    return panel;
  } 
 
  public void performEditConnections(final ReportDesignerContext context)
  { 
    if (performEdit() == false) 
    { 
      return; 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setContentType, setDocument
   * Sets the content type. 
   *  
   * @param type	the content type 
   */ 
  public void setContentType(String type) {
    m_PrintPane.setContentType(type);
  } 
 
  /** 
   * Returns the document to print. 
   *  
   * @return		the document or null 
   */ 
  public Document getDocument() {
    if (m_PrintPane != null) 
      return m_PrintPane.getDocument();
    else  
      return null; 
  } 
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setBackground, getDocument, setEditable
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setBackground, setText, setEditable
    txtReadyToGo.setEditable(false);
    txtReadyToGo.setBackground(UIManager.getColor("control"));
    txtReadyToGo.setText("We're ready to go!  Here's what to expect:");
    add(txtReadyToGo, "cell 0 0");
 
    JTextPane txtOptions = new JTextPane();
    txtOptions.setText("");
    txtOptions.setBackground(UIManager.getColor("control"));
    txtOptions.setEditable(false);
    add(txtOptions, "cell 0 1");
 
    StringBuilder text = new StringBuilder();
    int index = 1;
    if (model.isBuildEnabled()) {
      text.append(index++);
      text.append(") ");
      text.append(Messages.getString("RunPanel.BuildMessage"));
    } 
    if (model.isRunEnabled()) {
      if (text.length() > 0)

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setContentType, setText, setEditable
				setFont( null );
				super.updateUI(); 
				setFont( getFont().deriveFont( 32f ) );
			} 
		}; 
		JTextPane description = new JTextPane();
		description.setContentType( "text/html" );
		description.setEditable( false );
		 
		description.setText( demonstration.getHTML() );
		 
		JButton start = new JButton( "Startup" );
		 
		add( title, new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0, 
				GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,
				new Insets( 10, 10, 10, 10 ), 0, 0 ));
		add( image, new GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, 
				GridBagConstraints.NORTH, GridBagConstraints.NONE, 
				new Insets( 10, 10, 10, 10 ), 0, 0 ));
		add( new JScrollPane( description ), new GridBagConstraints( 0, 2, 1, 1, 100.0, 100.0, 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setContentType, setText, setEditable
See Code Examples for Java 8 JTextPane Methods: