[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

HTML in a JEditer Pane?

Posted on 1999-12-14
2
Medium Priority
?
666 Views
Last Modified: 2013-12-14
Could someone please tell me how to add HTML code to a JEditer Pane?
And have it read only a not editable?
Please include code for the 30 points!!
0
Comment
Question by:dvd99
2 Comments
 
LVL 5

Accepted Solution

by:
sgoms earned 120 total points
ID: 2282722
Try,

import java.awt.*;
import javax.swing.*;
import java.net.*;
import javax.swing.text.html.*;
import java.io.*;

class Pane extends JFrame{
  Pane(){
        setSize(300,300);
    JEditorPane editorPane=new JEditorPane();
            editorPane.setEditorKitForContentType("text/html", new HTMLEditorKit());
            editorPane.setEditable(false);
            URL content=null;
            try{
                content=new URL("file:///c:/tmp/test.html");
            }catch(Exception e){e.getMessage();}
            try {
           editorPane.setPage(content);
    }  catch(IOException io ) {
           System.err.println( "Could not load content from the URL\n" +content );
            }
            JScrollPane pane=new JScrollPane(editorPane);
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add("Center",pane);
      }
      public static void main(String args[]){
        (new Pane()).setVisible(true);
      }
}

instead of a loacl URL that i have specified u can specify another URL & check it out.

-sgoms
0
 
LVL 1

Author Comment

by:dvd99
ID: 2285664
Thanks it works just like I wanted to know!!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question