Refine search
private void displayTsurgeonHelp() { if(tsurgeonHelpFrame != null) { tsurgeonHelpFrame.setVisible(true); } else { tsurgeonHelpFrame = new JFrame("TSurgeon Help..."); JEditorPane helpText = new JEditorPane(); helpText.setContentType("text/html"); // StringBuffer s = new StringBuffer(); // s.append(htmlTsurgeonHelp); helpText.setText(htmlTsurgeonHelp); helpText.setEditable(false); JScrollPane scroller = new JScrollPane(helpText); helpText.setCaretPosition(0); scroller.setPreferredSize(new Dimension(500,500)); tsurgeonHelpFrame.add(scroller); tsurgeonHelpFrame.pack(); tsurgeonHelpFrame.setBackground(Color.WHITE); tsurgeonHelpFrame.setVisible(true); } }
infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(infoLabel); JEditorPane pane = new JEditorPane("text/html", "<a href=\"https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle\">Dependency Management</a>"); pane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { pane.setEditable(false); pane.setOpaque(false); pane.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(pane);
private void updateHighlighting(Component component) { highlightingEditor.setText(""); try (CloseableIterator<ScannerReport.SyntaxHighlightingRule> it = reader.readComponentSyntaxHighlighting(component.getRef())) { while (it.hasNext()) { ScannerReport.SyntaxHighlightingRule rule = it.next(); highlightingEditor.getDocument().insertString(highlightingEditor.getDocument().getEndPosition().getOffset(), rule + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read syntax highlighting for " + getNodeName(component), e); } }
final JEditorPane editor = new JEditorPane(); editor.setEditorKit(JEditorPane.createEditorKitForContentType("text/html")); editor.setEditable(false);
JEditorPane pane = new new JEditorPane(); pane.setText("<html><font color=\"red\">hello world!</font></html>");
public void redraw() { String text = editorPane.getText(); taggedContents = null; untaggedContents = null; if (!editorPane.getContentType().equals("text/html")) { editorPane.setContentType("text/rtf"); Document doc = editorPane.getDocument(); try { doc.insertString(0, text, defaultAttrSet); } catch (Exception e) { throw new RuntimeException(e); } editorPane.revalidate(); editorPane.repaint(); editorPane.setEditable(true); htmlContents = null; } else { editorPane.setEditable(false); htmlContents = editorPane.getText(); } saveUntagged.setEnabled(false); saveTaggedAs.setEnabled(false); }
import java.io.*; import java.net.*; import java.util.regex.*; import javax.swing.*; public class webloader { static JComponent page; public static void loadcode(){ JEditorPane jep = new JEditorPane(); jep.setEditable(false); try { jep.setPage("http://(server):(port)/" + web.url); } catch (IOException e) { jep.setContentType("text/html"); jep.setText("<html>Could not load webpage</html>"); } JScrollPane scrollPane = new JScrollPane(jep); JFrame f = new JFrame(web.url); f.getContentPane().add(scrollPane); f.setSize(512, 342); f.show(); } }
import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextPane; public class TestLineBreak { public static void main(String[] args) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 10; i++) { sb.append("Text goes here <br>"); //<br> tag to insert line breaks } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane newsTextPane = new JTextPane(); newsTextPane.setContentType("text/html"); newsTextPane.setEditable(false); newsTextPane.setText(sb.toString()); JScrollPane scrollPane = new JScrollPane(newsTextPane); frame.add(scrollPane); frame.setSize(300, 200); frame.setVisible(true); } }
componentEditor = new JEditorPane(); componentDetailsTab.setViewportView(componentEditor); sourceEditor.setEditable(false); highlightingEditor = new JEditorPane(); symbolEditor = new JEditorPane(); coverageEditor = new JEditorPane(); duplicationEditor = new JEditorPane(); testsEditor = new JEditorPane(); issuesEditor = new JEditorPane(); externalIssuesEditor = new JEditorPane(); measuresEditor = new JEditorPane(); scmEditor = new JEditorPane(); activeRuleEditor = new JEditorPane(); adHocRuleEditor = new JEditorPane(); qualityProfileEditor = new JEditorPane();
import javax.swing.*; public class GetWebPage { public static void main(String args[]) throws Exception { JEditorPane website = new JEditorPane("http://www.google.com/"); website.setEditable(false); JFrame frame = new JFrame("Google"); frame.add(new JScrollPane(website)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); frame.pack(); } }
JTextArea ta = new JTextArea(); ta.setFont(font); ta.setText(fontText); ta.setEditable(false); JEditorPane op = new JEditorPane(); op.setContentType("text/html"); op.setEditable(false); op.setText(content); return new JScrollPane(op); JPanel fontNameCol = new JPanel(new GridLayout(0, 1, 2, 2)); JPanel fontExampleCol = new JPanel(new GridLayout(0, 1, 2, 2)); fontTable.add(fontNameCol, BorderLayout.WEST); fontTable.add(fontExampleCol, BorderLayout.CENTER); for (int ii = 0; ii < fonts.length; ii++) { fontNameCol.add(new JLabel(fonts[ii])); fontExampleCol.add(getExampleOfFont(fonts[ii])); tabPane.add("Fonts", new JScrollPane(fontTable));
private void init () { helpFrame = new JFrame("Quick Reference Manual"); Container contentPane = helpFrame.getContentPane(); contentPane.setLayout(new BorderLayout()); JEditorPane htmlPane = new JEditorPane(); EmptyBorder border = new EmptyBorder(5, 5, 5, 5); htmlPane.setBorder(border); htmlPane.setContentType("text/html"); htmlPane.setEditable(false); htmlPane.setPreferredSize(new Dimension(WIDTH, HEIGHT)); String html = this.getAboutHtml(); htmlPane.setText(html); htmlPane.setCaretPosition(0); JScrollPane scrollPane = new JScrollPane(htmlPane); contentPane.add(scrollPane, BorderLayout.CENTER); // Pack it, but don't show it yet. helpFrame.pack(); }
/** * Creates a new <code>DetailPanel</code> instance. * * @param aTable the table to listen for selections on * @param aModel the model backing the table */ DetailPanel(JTable aTable, final MyTableModel aModel) { mModel = aModel; setLayout(new BorderLayout()); setBorder(BorderFactory.createTitledBorder("Details: ")); mDetails = new JEditorPane(); mDetails.setEditable(false); mDetails.setContentType("text/html"); add(new JScrollPane(mDetails), BorderLayout.CENTER); final ListSelectionModel rowSM = aTable.getSelectionModel(); rowSM.addListSelectionListener(this); }
import java.io.IOException; import javax.swing.*; public class ExempleText { public static void main(String[] args) { String url = "C:/Users/Nimit/Desktop/n.txt"; try { JFrame frame=new JFrame("Hi"); JEditorPane Pane = new JEditorPane(url); Pane.setEditable(false); frame.add(new JScrollPane(Pane)); } catch(IOException ioe) { System.err.println("Error displaying " + url); ioe.printStackTrace(); } } }
private void buildContentPanel() { editorPane = new JEditorPane (); editorPane.setContentType("text/rtf"); editorPane.addKeyListener(new InputListener()); // defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes(); StyleConstants.setFontFamily(defaultAttrSet, "Lucida Sans"); Document doc = new DefaultStyledDocument(); editorPane.setDocument(doc); try { doc.insertString(0, initText, defaultAttrSet); } catch (Exception ex) { throw new RuntimeException(ex); } JScrollPane scrollPane = new JScrollPane(editorPane); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); editorPane.setEditable(true); }
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(200,200); getContentPane().setLayout(new BorderLayout()); JTextPane jtp = new JTextPane(); jtp.setEditorKit(new WrapEditorKit()); JScrollPane jsp = new JScrollPane(jtp); jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); getContentPane().add(jsp, BorderLayout.CENTER); jtp.setText("ExampleOfTheWrapLongWordWithoutSpaces"); setVisible(true);
JFrame frame = new JFrame(TestDifferentStyles.class.getSimpleName()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); textPane.setText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has " + "been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of " + "type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the " for (int i = 0; i < textPane.getDocument().getLength(); i++) { SimpleAttributeSet set = new SimpleAttributeSet(); frame.add(new JScrollPane(textPane)); frame.setSize(500, 400); frame.setVisible(true);
JFrame frame = new JFrame(); JTextPane textPane = new JTextPane(); textPane.setText("one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\n"); JScrollPane scrollPane = new JScrollPane(textPane); frame.add(scrollPane, BorderLayout.CENTER);// Highlight some text cyanPainter = new DefaultHighlighter.DefaultHighlightPainter(Color.cyan); redPainter = new DefaultHighlighter.DefaultHighlightPainter(Color.red); try { textPane.getHighlighter().addHighlight(0, 3, DefaultHighlighter.DefaultPainter); textPane.getHighlighter().addHighlight(8, 14, cyanPainter); textPane.getHighlighter().addHighlight(19, 24, redPainter); } catch (BadLocationException ble) { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(300, 200)); frame.setLocationRelativeTo(null); frame.pack(); frame.setVisible(true);
import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; public class GetWebPage { public static void main(String args[]) throws Exception { JEditorPane website = new JEditorPane("http://smo-gram.tumblr.com/"); website.setEditable(false); JFrame frame = new JFrame("Google"); frame.add(new JScrollPane(website)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(800, 600); frame.setVisible(true); } }
private JFrame frame = new JFrame(); private JTextPane jtp; private StyledDocument doc; jtp.setText("\ntype some text in the above empty line and check the wrapping behavior"); doc = jtp.getStyledDocument(); doc.addDocumentListener(new DocumentListener() { JScrollPane scroll = new JScrollPane(jtp); scroll.setPreferredSize(new Dimension(200, 200)); frame.add(scroll); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);