home *** CD-ROM | disk | FTP | other *** search
Java Source | 2003-12-19 | 2.3 KB | 96 lines |
- import java.awt.*;
- import java.awt.event.*;
- import java.applet.*;
- import javax.swing.*;
- import javax.swing.text.*;
- import javax.swing.text.rtf.*;
-
- /**
- * <p>Titolo: RTFView</p>
- * <p>Descrizione: Visualizza RTF in pagine Web</p>
- * @author Gianluca Esposito (giaesp@tiscali.it)
- * @version 0.11.17.03
- */
-
- public class RTFView
- extends JApplet {
-
- private boolean isStandalone = false;
- JScrollPane rtfScroller = new JScrollPane();
- JTextPane rtfPane = new JTextPane();
-
- String RTFText;
- int bground;
-
- public String getParameter(String key, String def) {
- return isStandalone ? System.getProperty(key, def) :
- (getParameter(key) != null ? getParameter(key) : def);
- }
-
- public RTFView() {
- }
-
- public void init() {
- try {
- RTFText = this.getParameter("RTF",
- "Nessuna informazione da visualizzare.");
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- try {
- bground = Integer.parseInt(this.getParameter("bground", "FFFFFF"), 16);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- try {
- jbInit();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void jbInit() throws Exception {
- // this.setSize(new Dimension(width,height));
- rtfPane.setEditorKit(new RTFEditorKit());
- rtfPane.setEditable(false);
- rtfPane.setCaretPosition(0);
- rtfPane.setText(RTFText); // Inserimento del testo RTF
- this.getContentPane().add(rtfScroller, BorderLayout.CENTER);
- rtfScroller.getViewport().add(rtfPane, null);
- rtfPane.setBackground(new Color(bground));
- rtfScroller.setBackground(new Color(bground));
- this.setVisible(true);
- }
-
- public void start() {
- }
-
- public void stop() {
- }
-
- public void destroy() {
- }
-
- public String getAppletInfo() {
- return "RTFView 0.11.17.03 (Gianluca Esposito - giaesp@tiscali.it)";
- }
-
- public String[][] getParameterInfo() {
- String[][] pinfo = {
- { "RTF", "String", "Corpo dell'RTF"},
- { "bground", "hex int", "Colore di sfondo - Inserire sequenza esadecimale (come nell'HTML, ma senza \"#\")"},
- };
- return pinfo;
- }
-
- static {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- }
- catch (Exception e) {
- }
- }
- }