MultiColumn text in JEditorPane.

I'd like to represent solution for the multi column text. It may be used in JEditorPane and JTextPane.
Opinions?
regards,
Stas
import javax.swing.*;
import javax.swing.text.*;
import view.*;
public class Application extends JFrame {
    JEditorPane edit=new JEditorPane();
    public Application() {
        super("Multicolumn text example");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        edit.setEditorKit(new MultiColumnEditorKit());
        this.getContentPane().add(new JScrollPane(edit));
        this.setSize(200,200);
    public static void main(String[] args) {
        Application application1 = new Application();
        application1.show();
class MultiColumnEditorKit extends StyledEditorKit {
    ViewFactory defaultFactory=new MultiColumnFactory();
    public ViewFactory getViewFactory() {
        return defaultFactory;
class MultiColumnFactory implements ViewFactory {
    public View create(Element elem) {
        String kind = elem.getName();
        if (kind != null) {
            if (kind.equals(AbstractDocument.ContentElementName)) {
                return new LabelView(elem);
            } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
                return new MultiColumnParagraphView(elem);
            } else if (kind.equals(AbstractDocument.SectionElementName)) {
                return new MultiColumnView(elem, View.Y_AXIS);
            } else if (kind.equals(StyleConstants.ComponentElementName)) {
                return new ComponentView(elem);
            } else if (kind.equals(StyleConstants.IconElementName)) {
                return new IconView(elem);
        // default to text display
        return new LabelView(elem);
// root (section) view class
import java.awt.*;
import javax.swing.text.*;
public class MultiColumnView extends BoxView {
    int columnWidth=100;
    int columnHeight=100;
    int majorTargetSpan=0;
    int[] majorOffsets=null;
    int[] majorSpans=null;
    int minorTargetSpan=0;
    int[] minorOffsets=null;
    int[] minorSpans=null;
    Point[] starts;
    int columnCount=1;
    public MultiColumnView(Element elem, int axis) {
        super(elem, axis);
    protected void layout(int width, int height) {
        columnHeight=height;
        super.layout(columnWidth,height);
    protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans) {
        super.layoutMajorAxis(targetSpan,axis,offsets,spans);
        majorTargetSpan=targetSpan;
        majorOffsets=offsets;
        majorSpans=spans;
        performMultiColumnLayout();
        for (int i=0; i<offsets.length; i++) {
            spans=columnHeight;
offsets[i]=0;
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) {
super.layoutMinorAxis(targetSpan,axis,offsets,spans);
minorTargetSpan=targetSpan;
minorOffsets=offsets;
minorSpans=spans;
performMultiColumnLayout();
for (int i=0; i<offsets.length; i++) {
View v=getView(i);
if (v instanceof MultiColumnParagraphView) {
MultiColumnParagraphView par=(MultiColumnParagraphView)v;
spans[i] = par.columnCount*columnWidth;
offsets[i]=par.columnNumber*columnWidth;
protected void performMultiColumnLayout() {
if (majorOffsets==null || minorOffsets==null || minorOffsets.length!=majorOffsets.length) {
return;
int childCount=majorOffsets.length;
int verticalStartOffset=0;
int columnNumber=0;
starts=new Point[childCount];
for (int i=0; i<childCount; i++) {
View v=getView(i);
starts[i]=new Point();
if (v instanceof MultiColumnParagraphView) {
MultiColumnParagraphView par=(MultiColumnParagraphView)v;
par.verticalStartOffset=verticalStartOffset;
par.columnWidth=columnWidth;
par.columnHeight=columnHeight;
par.columnNumber=columnNumber;
par.performMultiColumnLayout();
starts[i].y=verticalStartOffset;
starts[i].x=columnNumber*columnWidth;
verticalStartOffset=columnHeight-par.restHeight;
columnNumber+=par.columnCount-1;
columnCount = columnNumber + 1;
public float getPreferredSpan(int axis) {
if (axis==View.Y_AXIS) {
return columnHeight;
else {
return columnWidth*columnCount;
public float getMinimumSpan(int axis) {
if (axis==View.Y_AXIS) {
return columnHeight;
else {
return columnWidth*columnCount;
public float getMaximumSpan(int axis) {
if (axis==View.Y_AXIS) {
return columnHeight;
else {
return columnWidth*columnCount;
public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) {
//define child container
if (starts!=null) {
for (int i=starts.length-1; i>0; i--) {
if ((starts[i].x<x && starts[i].y<y)
|| (starts[i].x+columnWidth<x)
return getView(i).viewToModel(x,y,a,bias);
return getView(0).viewToModel(x,y,a,bias);
public void paint(Graphics g, Shape a) {
super.paint(g,a);
Rectangle r=a.getBounds();
int shift=columnWidth;
g.setColor(new Color(240,240,240));
while (shift<r.width) {
g.drawLine(r.x+shift,r.y,r.x+shift,r.y+r.height);
shift+=columnWidth;
//paragraph view class
import java.awt.*;
import javax.swing.text.*;
public class MultiColumnParagraphView extends ParagraphView {
protected int verticalStartOffset=0;
protected int columnCount=1;
protected int columnNumber=0;
protected int restHeight=0;
int[] majorOffsets=null;
int[] majorSpans=null;
int[] minorOffsets=null;
int[] minorSpans=null;
protected int columnWidth=100;
protected int columnHeight=100;
Point[] starts;
public MultiColumnParagraphView(Element elem) {
super(elem);
protected void layout(int width, int height) {
super.layout(columnWidth,0);
protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans) {
super.layoutMajorAxis(targetSpan,axis,offsets,spans);
majorOffsets=offsets;
majorSpans=spans;
performMultiColumnLayout();
offsets=majorOffsets;
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) {
super.layoutMinorAxis(targetSpan,axis,offsets,spans);
minorOffsets=offsets;
minorSpans=spans;
performMultiColumnLayout();
offsets=minorOffsets;
protected void performMultiColumnLayout() {
if (majorOffsets==null || minorOffsets==null || minorOffsets.length!=majorOffsets.length) {
return;
int childCount=majorOffsets.length;
int vo=verticalStartOffset;
int cc=1;
starts=new Point[childCount];
for (int i=0; i<childCount; i++) {
starts[i]=new Point();
if (vo+majorSpans[i]>columnHeight) {
cc++;
vo=0;
starts[i].y=vo;
starts[i].x=(columnNumber+cc-1)*columnWidth;
majorOffsets[i]=vo;
vo+=majorSpans[i];
restHeight=columnHeight-vo;
minorOffsets[i]=(cc-1)*columnWidth;
if (columnCount!=cc) {
columnCount = cc;
preferenceChanged(getView(0),true,true);
public float getPreferredSpan(int axis) {
if (axis==View.Y_AXIS) {
return columnHeight;
else {
return columnWidth*columnCount;
public float getMinimumSpan(int axis) {
if (axis==View.Y_AXIS) {
return columnHeight;
else {
return columnWidth*columnCount;
public float getMaximumSpan(int axis) {
if (axis==View.Y_AXIS) {
return columnHeight;
else {
return columnWidth*columnCount;
public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) {
int ind=getViewIndexAtPoint((int)x,(int)y,a.getBounds());
View v=getViewAtPoint((int)x,(int)y,a.getBounds());
Shape childAlloc=getChildAllocation(ind,a);
return v.viewToModel(x,y,childAlloc,bias);
protected int getViewIndexAtPoint(int x, int y, Rectangle alloc) {
if (starts!=null) {
for (int i=starts.length-1; i>0; i--) {
if ((starts[i].x<x && starts[i].y<y)
|| (starts[i].x+columnWidth<x)){
return i;
return 0;
protected View getViewAtPoint(int x, int y, Rectangle alloc) {
if (starts!=null) {
for (int i=starts.length-1; i>0; i--) {
if ((starts[i].x<x && starts[i].y<y)
|| (starts[i].x+columnWidth<x)){
return getView(i);
return getView(0);
public Shape getChildAllocation(int index, Shape a) {
Rectangle r=super.getChildAllocation(index,a).getBounds();
r.x=starts[index].x+3;
r.y=starts[index].y+3;
return r;

If you want to replace the existing text then just use:
setText(DAT);

Similar Messages

  • Highlighting text in JEditorPane using HTMLEditorPane

    I am using JEditorPane extending HTMLEditorkit. In the HTMLEditorkit when we use the span tag for highlighting the text of a line, it is just not showing it. It starts the color and ends it there and then. It looks like a small dot and doesnot spans the whole line.
    Is this a bug or something in JAVA 1.3.1. If anyone of you knows how to do it please let me know.
    I need it for a project which has a deadline.
    Thanks.

    JEditorPane is not rendering and HTMLDocument.HTMLReader is not reading the SPAN tag. In other words, the SPAN tag is not supported in Java. You can still use it by overriding the mentioned classes. My application SimplyHTML gives an example of how this can be done. Please visit http://www.lightdev.com/dev/sh.htm
    Ulrich

  • Find caret position of search text in jEditorPane

    Hi All,
    I am looking for a way to find the Caret position in a jeditor pane for the search text that i supply. The Jeditor pain is setup for text/html and when i find the index of my search text "ANCHOR_d" in the jeditor pane is 27000 something but the caret position is 7495 how do you find the caret position of the search text ??
    Any help is appriciated.
    I am also looking into getting abnchoring to work in the jeditorpane html text but as of yet i have been unsuccessful.
    Kind Regards,
    Wurns

    Search the underlying document, not the editor pane. Play around with this example, which I threw together the other day for a somewhat similar problem with JTextPane involving newlines, and modified for your need.
    Note: Please do not program by exception.import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import javax.swing.JButton;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    import javax.swing.text.Document;
    public class SearchEditorPane {
       JFrame frame = new JFrame ("Search JTextPane Test");
       String html = "<HTML><BODY><P>This is <B>some</B>" +
                    " <I>formatted</I>" +
                    " <FONT color=#ff0000>colored</FONT>" +
                    " html.</P>" +
                    "<P>This is a <FONT face=Comic Sans MS>" +
                    "comic <br>\n<br>\nsans ms</FONT> section</P><div>" +
                    "And this is a new division</div>" +
                    "</BODY></HTML>";
       JEditorPane editorPane = new JEditorPane ("text/html", html);
       JPanel panel = new JPanel ();
       JTextField textField = new JTextField (10);
       JButton button = new JButton ("Find");
       Document doc = editorPane.getDocument ();
       void makeUI () {
          editorPane.setText ("<HTML><BODY><P>This is <B>some</B>" +
                " <I>formatted</I>" +
                " <FONT color=#ff0000>colored</FONT>" +
                " html.</P>" +
                "<P>This is a <FONT face=Comic Sans MS>" +
                "comic <br>\n<br>\nsans ms</FONT> section</P><div>" +
                "And this is a new division</div>" +
                "</BODY></HTML>");
          button.addActionListener (new ActionListener () {
             public void actionPerformed (ActionEvent e) {
                // Programming by exception is BAD, don't copy this style
                // This is just to illustrate the solution to the problem at hand
                // (Sorry, uncle-alice, haven't reworked it yet)
                try {
                   Matcher matcher = Pattern.compile (textField.getText ())
                   .matcher (doc.getText (0, doc.getLength ()));
                   matcher.find ();
                   editorPane.setCaretPosition (matcher.start ());
                   editorPane.moveCaretPosition (matcher.end ());
                   editorPane.requestFocus ();
                } catch (Exception ex) {
                   JOptionPane.showMessageDialog (frame, "Not Found!\n" + ex.toString ());
                   //ex.printStackTrace();
          panel.add (textField);
          panel.add (button);
          panel.setPreferredSize (new Dimension (300, 40));
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          frame.setSize (300, 300);
          frame.add (editorPane, BorderLayout.CENTER);
          frame.add (panel, BorderLayout.SOUTH);
          frame.setLocationRelativeTo (null);
          frame.setVisible (true);
       public static void main (String[] args) {
          SwingUtilities.invokeLater (new Runnable () {
             public void run () {
                new SearchEditorPane ().makeUI ();
    }db

  • Can't display Persian text in JEditorPane

    Hi
    I created html pages with Persian and English text. It displays Persian characters with no problem, however when i get the local html file to display in JEditorPane the Persian chracters appear as ????
    can any one help?

    I installed the persian font and thats how i get the html file
    ep = new JEditorPane();
              ep.setEditable(false);
              ep.setFont(new java.awt.Font("BCompaBd",java.awt.Font.PLAIN,18));
              ep.setContentType("text/rtf");
              URL url = PersianTutor.class.getResource("Copyright.html");
              try {
                   ep.setPage(url);
              catch (IOException e) {
         e.printStackTrace();
         JScrollPane jp = new JScrollPane(ep);
    jp.setPreferredSize(new Dimension (500, 500));
    ep.addHyperlinkListener(new Link(ep));

  • Trouble inserting text into JEditorPane

    Hello.
    I am trying to use a URL Connection and the read method to produce an HTML page in a JEditorPane.
         purlRec is a data record that contains information relating to the URL in question.
         pis is an input stream create from the URLConnection.getInputStream() method
    private void loadFromURL(UrlRecord purlRec, InputStream pis ) {
    URL url;
    String tmpStr = (String)purlRec.getUrlName();
    String baseUrl = (String)purlRec.getUrlName();
    setContentType("text/html");
    try {
    HTMLDocument doc = (HTMLDocument)getDocument();
    doc.setBase(new URL(baseUrl));
    this.read(is,doc);
    repaint();
    catch (Exception e) {
    System.err.println("Couldn't create URL: " + tmpStr);
    System.out.println("error:"+e.getMessage());
    I get the following when I execute the code. Am I not using this correctly or is there something I am missing? I am using the read from input stream so that I can connnect to url that require authentication. I know that the URL connection works because I am able to write the output of the stream to a text file in a test function.
    Couldn't create URL: http://www.google.com
    java.lang.RuntimeException: Must insert new content into body element-
         at javax.swing.text.html.HTMLDocument$HTMLReader.generateEndsSpecsForMidInsert(HTMLDocument.java:1878)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1854)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1729)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1724)
         at javax.swing.text.html.HTMLDocument.getReader(HTMLDocument.java:125)
         at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:228)
         at javax.swing.JEditorPane.read(JEditorPane.java:504)
         at javax.swing.JEditorPane.read(JEditorPane.java:478)
         at com.UrlChecker.panels.HTML.EditorPane._$34246(EditorPane.java:105)
         at com.UrlChecker.panels.HTML.EditorPane.changeUrls(EditorPane.java:142)
         at com.UrlChecker.demo.UrlChecker.changeHtml(UrlChecker.java:131)
         at com.UrlChecker.panels.Report.URLTabView.mouseClicked(URLTabView.java:91)
         at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:208)
         at java.awt.Component.processMouseEvent(Component.java:5096)
         at java.awt.Component.processEvent(Component.java:4890)
         at java.awt.Container.processEvent(Container.java:1566)
         at java.awt.Component.dispatchEventImpl(Component.java:3598)
         at java.awt.Container.dispatchEventImpl(Container.java:1623)
         at java.awt.Component.dispatchEvent(Component.java:3439)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3174)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
         at java.awt.Container.dispatchEventImpl(Container.java:1609)
         at java.awt.Window.dispatchEventImpl(Window.java:1585)
         at java.awt.Component.dispatchEvent(Component.java:3439)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    error:Must insert new content into body element-
    Thank you

    I tried using this, but I get an UNAUTHORIZED Status code (401) indicating request requires HTTP authentication. ( HttpServletResponse error code ). This is why the encoded authentication is used. It works when I try to just read from the url using an InputStream but not when I try passing the same InputStream to the JEditorPane.
    Any Idea of how to use JEditorPane.read(InputStream in , Object desc) or why it would work in one instance and not in the other?
    Thanks

  • Can I append the text in JEditorPane?

    Hi,
    I can do append text into JTextArea e.g.
    textarea.append(string);
    but in JEditorPane, it only support setText()
    setText() will replace the existing text with the new text but not appended.
    Any ideas?
    thanks.

    Document doc=jep.getDocument();
    doc.insertString(doc.getLength(), stringToInsert, null/*or whatever*/);

  • Suppressing certain HTML tags before setting text to JEditorPane

    Sir,
    I am setting the text(html format) for JEditorPane using the setText(String) method. But I need to suppress all the <IMG> tags that are present in this text before setting it to JEditorPane. Is there any way in which I can write my extended HTMLEditorKit wherein I can check for specific HTML.Tag and prevent it from getting added to the document.
    Can you please help me out with some example.
    Regards,
    Alex

    Instead of trying to extend the HTMLEditorKit, you don't you add a normal method to scan the text for the <IMG> tag and get rid of it yourself before putting it in the JEditorPane using the setText() method. You can try something like this:
    public String removeImgTag(String text) {
       String tmp=text.toLowerCase();
       int i=tmp.indexOf("<img");
       if (i<0) return text;
       int j=tmp.substring(i).indexOf(">");
       return tmp.substring(0,i-1)+tmp.substring(i+j);
    };o)
    V.V.

  • Best of way of storing texts for JEditorPane.

    I'm developing a small GUI. It has a combobox and a JEditorPane. I want the editorPane poupulated with text (html if possible) according to the selection of the combobox.
    My question is now: Whats the best way of storing those texts???
    It should be static text, (explanation of the selection) so it can be hardcoded. Should I just create another class that only contains the texts?
    So this is not a 'how can I...'-question, but more a 'what's the way to..'-question!
    Let's hear some opinions! ;-)

    Thanks Mike, I am still exploring on this issue. I shall try that cache funda.
    Ashok Gupta
    "Mike Reiche" <mreiche@newsgroup_only.com> wrote:
    >
    >
    >
    If you would like to put a DB in between LD an MS-Excel, simply configure
    Caching
    for the DataView that retrieves the spreadsheet. LD will automatically
    catch
    the DataView in your cache database (SQL Server or Oracle). The only
    drawback
    is that your data will only be as recent as the last cache refresh.
    Before I made the MS-Excel demo, I did look at other Java-COM bridge
    products.
    JCOM was by far the easiest to use. The way the custom function is written,
    it
    retrieves the whole worksheet. If you want to write another custom function
    that
    takes row and column parameters, I'm sure it would be much quicker.
    "Ashok Gupta" <[email protected]> wrote:
    Hello,
    I am working on a solution to use Excel Files (yes, multiple) as Data
    Source in
    Liquid Data for a portal running on Web Logic Server (ver 7). The web
    application
    (will be mostly in JSP) will be executing the XQueries (some combination
    of one
    or mutiple worksheets from one or multiple Excel Files) and will need
    out out
    in XML. As I understand the input (XQry) and output (XML) is what fits
    properly
    in Liquid Data, the problem is with the efficiently using/accessingmultiple
    Excel
    files as Data Source with Liquid Data.
    I have been thinking following versions:
    1. Let it be some intermediate DB (say SQL Server, or...) communicate
    with Liquid
    Data and let SQL Server communicate with MS Excel. So aviding direct
    communication
    between Liquid Data and Excel (but how it to be?).
    2. Let Liquid Data communicate with Excel directly but use some efficient
    way
    of it (but what?)
    Can anyone please help me with this issue? As this decisions is going
    to efftect
    my big application (yes it will be a big web application).
    Thanks in advance,
    Ashok Gupta

  • Display Non-English Text in JEditorPane in Linux

    I want to display chinese in JEditorPane under Linux OS.
    However, i just found that they all display as a square box.
    I have tried to use both big5, and unicode(utf8), but it doesn't seem work.
    Do anyone know how to solve it ? Any method that can make them display ??
    Thank You!!

    Hi,
    just a guess, i think u can use setContentType to set the MIME type
    Ashish

  • Multiple text colors in a JTextArea

    i created a JTextArea in a frame --- // JTextArea ta = new JTextArea();
    and wrote some words onto it with codes like: ta.append("abcd");
    ta.append("efg");
    how to make the color of the words "abcd" different from "efg"?

    JTextArea doesn't support multiple fonts and colours. Have a look at JTextPane or JEditorPane which allow more flexibility in formatting your text. JEditorPane also supports HTML.

  • I can't add simple HTML link to HTMLDocument in jEditorPane

    h5. How to construct a link to make it work?
    HTMLDocument doc = (HTMLDocument) jEditorPane.getDocument();
    String link = dialogSlownikEkranow.getLink();
    SimpleAttributeSet tag = new SimpleAttributeSet();
    SimpleAttributeSet attrs = new SimpleAttributeSet();
    tag.addAttribute(HTML.Tag.A, attrs);
    attrs.addAttribute(HTML.Attribute.HREF, link);
    +try {+
    + doc.insertString(jEditorPane.getCaretPosition(), "some link", tag);+
    +} catch (BadLocationException e1) {+
    + e1.printStackTrace();+
    +}+
    h5. As a result I get
    <+a href="\mw\client\cd\plytacd.html"><p></a>+
    h5. but I require something like
    <+a href="\mw\client\cd\plytacd.html">some link</a>+

    Hi,
    nirgal wrote:
    h5. How to construct a link to make it work?
    HTMLDocument doc = (HTMLDocument) jEditorPane.getDocument();
    SimpleAttributeSet tag = new SimpleAttributeSet();
    SimpleAttributeSet attrs = new SimpleAttributeSet();
    tag.addAttribute(HTML.Tag.A, attrs);
    attrs.addAttribute(HTML.Attribute.HREF, link);
    I don't believe that SimpleAttributeSet is right for HTMLDocument. In your code, you regard a HTML.Tag as a AttributeSet. Apparently this is not the absolute truth. May be I'm wrong, then one may correct me.
    My suggest�on is to use string concatenation to make the HTML for the link and then use HTMLEditorKit.read to put this HTML into the HTMLDocument on caret position.
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import javax.swing.text.*;
    public class JEditorPaneSample {
      private static void createAndShowGUI() {
        JFrame frame = new JFrame("FrameDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JEditorPane jeditorpane = new JEditorPane();
        jeditorpane.setContentType("text/html");
        jeditorpane.setText("<p>Hello World</p>");
    //insert a link on caret position
    String link = "mw/client/cd/plytacd.html";
    String htmlstring = "<a href=\"";
    htmlstring += link + "\">";
    htmlstring += "some link" + "</a>";
    try {
      jeditorpane.getEditorKit().read(new StringReader(htmlstring), jeditorpane.getDocument(), jeditorpane.getCaretPosition());
    } catch (BadLocationException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
        System.out.println(jeditorpane.getText());
        frame.getContentPane().add(jeditorpane, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
      public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            createAndShowGUI();
    }greetings
    Axel

  • Problem with JEditorPane

    Hello
    I want to display an arabic text on JEditorPane
    I retrive this text fom database as byte[]
       byte[] arObj = rset.getBytes("ArFirstname");
       String myStr =(new String(arObj,"UTF-8")).toString().trim();
       StringBuffer buff = new StringBuffer()
       buff.append("<html><head><title></title></head><body>")
       buff.append("<h2>"+ myStr + </h2>");
       buff.append("</body></html>")
      myJEP.setPage(buff.toString());but I see only ???
    what is wrong
    thanks

    Hello
    I want to display an arabic text on JEditorPane
    I retrive this text fom database as byte[]
    byte[] arObj = rset.getBytes("ArFirstname");
    String myStr =(new String(arObj,"UTF-8")).toString().trim();
    StringBuffer buff = new StringBuffer()
    buff.append("<html><head><title></title></head><body>")
    buff.append("<h2>"+ myStr + "</h2>");
    buff.append("</body></html>")
    myJEP.setPage(buff.toString());but I see only ???
    what is wrong
    thanks

  • Display HTML in JEditorPane

    Hi
    I am trying to display a String containing HTML text on a JEditorPane.
    I have downloaded the HTML from a webpage using sockets, and now I want to display the downloaded page. I have a project in school about sockets.
    This is why I can't use getPage(URL);
    The following is the code I am using:
    String temp = "String with HTML text"
    HTMLEditorKit htmlEdKit = new HTMLEditorKit();
    JEditorPane.setEditorKit(htmlEdKit);
    JEditorPane.setContentType("text/html");
    JEditorPane.setEditorKitForContentType("text/html", htmlEdKit);
    JEditorPane.setContentType("text");
    JEditorPane.setText(temp);
    When I run the code, all that is displaying is the raw HTML code, with all the tags. As I understand it, this is how it should be done.
    What is wrong, would appreciate some help.
    /David Mossberg

    it's not necessary to use socket but if use socket get the inputstream from it.
    in = socket.getinputstream(); //return inputstream from socket
    htmldoc = JEditorPane.getDocument(); //return the htmldoc in JEditorPane
    if(htmldoc.getlength()>0)
    htmldoc.remove(0,htmlDoc.getLength());//if the htmldoc has some content then remove it
    reader = new InputStreamReader(in);//construct a new reader from in
    JEditorPane.getEditorKit.read(reader,htmldoc,0); //read new content into the htmldoc from reader
    Hope the above code helps you.
    joney

  • Korean text in photo book print (Aperture)

    Hi, I want to know if Korean language text will be printed on my photobook created by Aperture.
    To make this post helpful for others, is there any language not supported by Aperture/iPhoto?
    FYI, I'm ordering from the United States.
    Thank you.

    The Print Product page
    http://www.apple.com/sg/aperture/resources/print-products.html
    says:
    Hardcover and softcover books.
    Create a beautiful, one-of-a-kind hardcover book of your summer travel photos. Or a set of impressive softcover books of your work to give to clients. Aperture 3 makes it easy with 11 professionally designed themes. You can customise each template by resizing and repositioning the photo and text boxes, and create borders of any width or colour on photo boxes. For text, you can use any font, size or style, and design multicolumn text boxes. And the books are available in various sizes, from an extra-large 33-by-25.4-cm format to small books that fit in your pocket.
    I take that to mean, you can use any font, that comes preinstalled by Apple.  Does your Korean font show, when you preview the page, as described here?
    iPhoto, Aperture: Previewing an order in iPhoto or Aperture
    The preview is supposed to look exactly, as the printed book will look.
    To be on the safe side, call the Print Products Store Support - use the phone number given at the top of this page.  Apple Print Products - Apple Store (U.S.)
    --  Léonie

  • How to set Color of Specific String in JEditorPane?

    I have tried using jp1.setForeground(Color.red) but all the text in JEditorPane are set to red. I want the JEditorPane to display red for all text except a particular string 'xyz'. Can anyone pls help me?
    Thank you.

    Its easier to use a JTextPane. Read this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html]Using Text Components.
    And here's another thread that will help:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=342068

Maybe you are looking for

  • Block Planning Display block options eg Percent of block utilised and Qtys?

    Any hints how to display block quantities and percent utilised in PPDS area? I have managed so far to get the following for blocks that cross between months. 1. Resource table. (/SAPAPO/RPT - Resource Planning Table )Can highlight both columns that t

  • Few questions about apex + epg and cookie blocked by IE6

    Hi, I would like to ask a few questions about apex and epg. I have already installed and configured apex 3.2 on oracle 10g (on my localhost - computer name 'chen_rong', ip address -192.168.88.175 ), and enable anonymous access xdb http server. now, 1

  • Confirm Delete in a JSP Application

    Working in a JSP application I need to show a delete confirmation when the user clicks on the red button (delete) in JS Navigator Bar Web Bean. How delete works behind this button? Code that implements the delete confirmation (a custom web bean, for

  • Filling out a pdf form with C#

    We have some pdf forms that I have put textboxes, checkboxes, etc on with LiveCycle. I want to write a C# program that will ask the user some questions and send the pdf form the data to fill it out. On my development machine I have VS 2005, .Net plat

  • How can I know which line contains the error in JSP

    Hello, I got following compiling error: ava.lang.NullPointerException      at org.apache.jsp.temp1Public_jsp._jspService(temp1Public_jsp.java:252)" Is there a way I can know in which line of the jsp page the null pointer exception occurs. "line 252 "