import javax.swing.text.html.HTMLEditorKit;출력:
import javax.swing.*;
import java.io.*;
import java.net.URL;
import java.awt.*;
public class JEditorTest {
public static void main(String[] args) {
JEditorPane jep = new JEditorPane();
jep.setEditable(거짓);
jep.setBackground(Color.WHITE);
jep.setBounds(316, 110, 598, 545);
HTMLEditorKit 키트 = new HTMLEditorKit();
jep.setEditorKit(키트);
{
jep.setPage(새 URL("http://imss-www.upmf-grenoble.fr/prevert/Prog/Java/swing/JEditorPane.html"));
}
catch (IOException e) {
jep.setContentType("text/html ");
jep.setText("문서를 볼 수 없습니다");
}
JScrollPane scrollPane = new JScrollPane(jep);
JFrame f = 새로운 JFrame();
// 다음 줄에는 Java 1.3
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(scrollPane);
f.setSize(512, 342);
f.show();
}
}
jep.addHyperlinkListener(new HyperlinkListener() {JEditorPane을 사용하면 정보를 얻거나 웹 페이지를 편집할 수도 있습니다.
public void hyperlinkUpdate(HyperlinkEvent e) {
if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
JEditorPane jepane = (JEditorPane)e.getSource();
시도 {
jepane.setPage(e.getURL());
}catch (IOException ex) {
jepane.setText("오류: "+ex.getMessage());
}
}
}
});
가져오기 java.awt.BorderLayout;
가져오기 javax.swing.JComponent;
가져오기 javax.swing.JFrame;
가져오기 javax.swing.JPanel;
가져오기 javax.swing.SwingUtilities;
가져오기 chrriis.common.UIUtils;
가져오기 chrriis.dj.nativeswing.swtimpl.NativeInterface;
가져오기 chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
public class JWebBrowser {
public static JComponent createContent() {
JPanel contentPane = new JPanel(new BorderLayout());
JWebBrowser webBrowser = new JWebBrowser();
webBrowser.navigate("http://www.orange.fr");
contentPane.add(웹 브라우저);
반환 contentPane;
}
public static void main(String[] args) {
NativeInterface.open();
UIUtils.setPreferredLookAndFeel();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame 프레임 = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(createContent(),
BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
});
NativeInterface.runEventPump();
}
}
import java.awt.BorderLayout;
import javax.swing.JFrame;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
public class JxBrowserTest {
public static void main(String[] args) {
브라우저 브라우저 = new Browser();
BrowserView view = new BrowserView(browser);
JFrame 프레임 = new JFrame();
frame.add(보기, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setVisible(true);
browser.loadURL("http://www.youtube.com");
}
}
Please disable your ad blocker and refresh the window to use this website.