Skip to main content

EditorPane loading a HTML file

3 replies [Last post]
leonardoreyes
Offline
Joined: 2007-09-25

Hello, i got a frame that have an EditorPane where i load a html file, and navigate between others html files, but in the lower part, the EditorPane it's jumpin, like blinking.

This it's the code for the EditorPane:

View {
transform: translate(10, 26)
content: EditorPane {
opaque: true
preferredSize: {height: 436 width: 608}
contentType: HTML
editable: false
text: bind navi.contenido
}
}

If i comment the line of preferredSize, and put size, the EditorPane change the size after the html file.

The EditorPane i have it insade a SplitPane.

By the way i'm using the interpreter version of JavaFX and running the program with javafxpad.

Can someone help me?, please.

Here it's the complete code i'm using.

-------

import javafx.ui.*;
import javafx.ui.canvas.*;
import java.lang.StringBuffer;
import java.io.*;
import java.net.URL;
import java.lang.Math;

public class NavUrl {
attribute contentPos: Integer;
attribute contenido:String;
attribute urls:String+;

operation fisrt();
operation ultimo();
operation next();
operation previous();
operation getResourceAsString(urlStr: String);
}

attribute NavUrl.urls = ["http://localhost:8080/TutorWS/MetododeBiseccion01.html",
"http://localhost:8080/TutorWS/MetododeBiseccion02.html",
"http://localhost:8080/TutorWS/MetododeBiseccion03.html"];

attribute NavUrl.contentPos = 0;
attribute NavUrl.contenido = getResourceAsString("http://localhost:8080/TutorWS/MetododeBiseccion01.html");

operation NavUrl.fisrt(){
contentPos = 0;
contenido = getResourceAsString(urls[contentPos]);
}
operation NavUrl.ultimo(){
var n = sizeof urls;
contentPos = n-1;
contenido = getResourceAsString(urls[contentPos]);
}
operation NavUrl.next(){
var n = sizeof urls;
if (contentPos == (n-1)){
contentPos = n-1;
}else {
contentPos = contentPos + 1;
}
contenido = getResourceAsString(urls[contentPos]);
}
operation NavUrl.previous(){
if (contentPos == 0){
contentPos = 0;
}else {
contentPos = contentPos - 1;
}
contenido = getResourceAsString(urls[contentPos]);
}

operation NavUrl.getResourceAsString(urlStr: String) {
var buf = new StringBuffer();
do {
var url = new URL(urlStr);
var reader = new BufferedReader(new InputStreamReader(url.openStream()));
while (true) {
var line = reader.readLine();
if (line == null) {
break;
}
buf.append(line);
buf.append("\n");
}
}
return buf.toString();
}

var temas = ["tema1", "tema2", "tema3", "tema4", "tema5"];
var selectedTema: Number;
var titulo = "Tema Actual: tema1";
var navi:NavUrl = new NavUrl();

Frame {
width: 794
height: 510
title: "Text Sampler"
visible: true
content: SplitPane {
orientation: HORIZONTAL
content:
[SplitView {
weight: 0.2
content:
BorderPanel {
center: BorderPanel {
border: CompoundBorder {
borders:
[TitledBorder {
title: "Temas"
},
EmptyBorder {
top: 5
left: 5
bottom: 5
right: 5
}]
}
center: BorderPanel {
background: new Color(.8,.8,.1,0)
center: ListBox {
selection: selectedTema
cells: bind foreach (emp in temas)
ListCell {
text: "{emp}"
}
action: operation() {}
}
bottom: FlowPanel {
content:
[Button {
text: "Seleccionar Tema"
action: operation() {}
}]
}
}
}
}
},
SplitView {
weight: 0.8
content: Canvas {
border: CompoundBorder {
borders:
[TitledBorder {
title: bind titulo
},
EmptyBorder {
top: 5
left: 5
bottom: 5
right: 5
}]
}
content:
[View {
transform: translate(10, 26)
content: EditorPane {
opaque: true
preferredSize: {height: 436 width: 608}
contentType: HTML
editable: false
text: bind navi.contenido
}
},
View {
transform: translate(10, 470)
content: Button {
text: "First"
cursor: DEFAULT
action: operation(){
navi.fisrt();
}
}
},
View {
transform: translate(62, 470)
content: Button {
text: "Prev"
cursor: DEFAULT
action: operation(){
navi.previous();
}
}
},
View {
transform: translate(116, 470)
content: Button {
text: "Next"
cursor: DEFAULT
action: operation(){
navi.next();
}
}
},
View {
transform: translate(170, 470)
content: Button {
text: "Last"
cursor: DEFAULT
action: operation(){
navi.ultimo();
}
}
}]
}
}]
}
}

Message was edited by: leonardoreyes:
Formating the message

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
leonardoreyes
Offline
Joined: 2007-09-25

i forgot to say that this only happens when the content of the html file it's bigger that the size of the EditorPane.

alexsch
Offline
Joined: 2007-07-12

The interpreter version of JavaFX Script language has not been supported anymore.
Please, use the compiler one.

leonardoreyes
Offline
Joined: 2007-09-25

Ok, i'l start the migration.

By the way, there is another object that EditorPane that load a HTML file?