0
큰 프로젝트의 일부인이 두 클래스가 있지만 이상한 이유로 브라우저에서 main()
을 실행하면 HTML 파일이 표시되지 않습니다.브라우저에서 HTML 파일을 표시하지 않습니다.
홈페이지 : 여기
은 두 클래스입니다import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class main {
public static void main(String[] args) {
BrowserFrame browser = new BrowserFrame();
JFrame mainFrame = new JFrame();
Thread browserThread = new Thread();
mainFrame.getContentPane().add(browser);
mainFrame.setSize(550,550);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
browserThread.start();
browser.setVisible(true);
mainFrame.setVisible(true);
}
}
BrowserFrame 내 코드의 일부는 약간 이상한/이상한로 건너 올 수 있습니다
import java.awt.BorderLayout;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
public class BrowserFrame extends javax.swing.JPanel {
public void BrowserFrame() {
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
URL url = null;
try {
url = new URL("file:///C:/PersonalWorkSpace/PrivateEyes/html/test.html");
} catch (MalformedURLException e) {
e.printStackTrace();
}
JEditorPane jEditorPane = new JEditorPane();
jEditorPane.setEditable(false);
JScrollPane jScrollPane = new JScrollPane(jEditorPane);
HTMLEditorKit kit = new HTMLEditorKit();
jEditorPane.setEditorKit(kit);
StyleSheet styleSheet = kit.getStyleSheet();
styleSheet.addRule("body {color:#000; font-family:times; margin: 4px;}");
styleSheet.addRule("h1 {color: blue;}");
styleSheet.addRule("h2 {color: #ff0000;}");
setLayout(new BorderLayout());
add(jEditorPane);
try {
jEditorPane.setPage(url);
} catch (IOException e) {
e.printStackTrace();
}
jEditorPane.setVisible(true);
jScrollPane.setVisible(true);
System.out.println("Browser Window Run");
}
});
}
}
,하지만 난 때문에 그건 몇 가지 일들을 시도하고 일부 잔재물이 남아 있습니다.
미리 감사드립니다.
오 마이 갓! 나는이 모든 시간을 비트를 추가하고 비트를 빼앗아 다녔다 고 생각하고 그것은 습관에서 추가 한 한 단어였습니다. 타이머가 만료되면 대답을 수락합니다. – RyanSoper
그런 일이 생길 때가 너무 싫지만, 나중에 두통이 생길 수있는 몇 가지 버그를 발견합니다. – aglassman