관리 메뉴

취미개발 블로그와 마음수양

자바 JEditorPane을 이용한 기초 브라우저..(그냥..읽기만하는;;) 본문

Language/java소스

자바 JEditorPane을 이용한 기초 브라우저..(그냥..읽기만하는;;)

아라한사 2014. 4. 18. 23:07

아주 열악한 환경의 브라우저 (?) ㅋㅋㅋ


책들에는 보통 잘 안나와잇는데..외국 사이트에서 조금씩 퍼옴 ㅋㅋ




package 챕25네트웤;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;

class MyFrame extends JFrame implements ActionListener {
	JButton button;
	JTextField tf;
	JEditorPane jep;
	
	public MyFrame(){
		//스크롤 패널에 들어갈 내용들
		jep = new JEditorPane();
		jep.setEditable(false);   
			     
		try {
			jep.setPage("http://www.google.com/");
		}catch (IOException e) {
			jep.setContentType("text/html");
			jep.setText("Could not load http://www.google.com/ ");
		} 
		tf = new JTextField(50);
		button = new JButton("이동");
		button.addActionListener(this);
			       
		//패널 생성
		JScrollPane scrollPane = new JScrollPane(jep);   
		JPanel panel = new JPanel();
		panel.add(tf);
		panel.add(button);
		
		//프레임 생성
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		add(panel, BorderLayout.NORTH);
		add(scrollPane);
		setSize(1024, 768);
		setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource()==button){
			try {
				jep.setPage(tf.getText());
			} catch (IOException e1) {
				jep.setContentType("text/html");
				jep.setText("Could not load http://www.google.com/ ");
			}
		}	
	}
}

public class Quest01 {
	public static void main(String[] args) {
		new MyFrame();
	}

}


'Language > java소스' 카테고리의 다른 글

자바 파일 전송 간단하게 해보기  (0) 2014.04.19
자바 1:1 GUI 채팅 프로그램..  (1) 2014.04.19
자바 채팅 기초 - 콘솔 채팅  (0) 2014.04.18
자바 행맨  (0) 2014.04.18
자바 문자열 비교 프로그램  (0) 2014.04.18