원하는 동작을 얻으려면 편집기 창에 URL을 설정하고 진행 막대가있는 브라우저가 있어야합니다. brwoser 코딩은 고통스럽고 복잡한 작업이며 JEditorPane입니다. 가능한 모든 가능성을 다루고 있습니다.
그러나 귀하의 필요를 충족시키기 위해 귀하가 직접 (소켓 또는 httpclient 또는 다른 lib를 사용하여) 표시하려고하는 페이지의 내용을 가져와야한다고 생각합니다. 서버에서 바이트를 수신하는 동안 진행 막대를 업데이트 할 수 있습니다. 모든 바이트를받은 후에 한 단계에서 내용을 표시 할 창으로 내용을 설정합니다.
편집 : 사용하여 소켓 당신은 (이 신속하고 더러운는 오류 처리의 어떤 종류없이 참고) 다음을 수행해야합니다 꽤 많이
// Suppose you want to display http://www.target.com/page
Socket s = new Socket("target.com", 80);
PrintWriter out = new PrintWriter(s.getOutputStream());
// Tell the server you want to get "/page"
out.println("GET /page HTTP/1.1");
out.println("Host: target.com");
out.println();
// The target-Server now send you the content of "/page"
// Now you need to know a little about the HTTP-Protocol.
// In short: The server sends you a header and a body.
// The header and the body is separated using two newlines.
// You need to read line by line from the server until the
// body starts and interpret the stuff from the header because it
// contains the information how many bytes you will receive with the body
// (-> Content-Length: xyz)
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
// Read the Header and interpret that stuff.
doReadHeader(in);
// Now, because of the Content-Length Header you know how many bytes you need to read
// from the InputStream until all the bytes are receive. Thus you can update your
// progressbar while receiving the bytes
doReadBody(in);
즉. 이 모든 것을받은 후에 EditorPane에 본문 1 : 1을 설정할 수 있습니다. 그러나 EditorPane은 HTML과 CSS를 거의 다루지 않습니다. 그래서 FlyingSaucer 나 CSSBox와 같은 다른 HTML 창으로 가야 할 수도 있습니다 ...
'setPage'는 페이지가 편집기에 의해로드 될 때까지 블로킹 메소드입니다. ... – MadProgrammer
@MadProgrammer 그래서! 해결책은 무엇입니까? – Ahmed
아, 이제는 이해합니다 ... 아마 EditorPane에 DocumentListener를 추가하고 들어오는 Text를 수신 한 다음 진행률 막대를 업데이트 할 수 있습니다. 그러나 당신은 어쩌면 얼마나 많은 문자가 예상되는지 알 수 없으므로 이산 값으로 JProgressBar를 업데이트 할 수 없습니다. –