티스토리 뷰
- AppletTest.java
----------------------------------------------------------
package j0523;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class AppletTest extends Applet implements ActionListener{
JPanel northp;
JCheckBox cb1,cb2;
JTextArea ta;
JScrollPane scrol;
public void init(){
northp = new JPanel();
cb1 = new JCheckBox("사과");
cb2 = new JCheckBox("딸기");
ta = new JTextArea();
scrol = new JScrollPane(ta);
northp.setBackground(Color.orange);
northp.add(cb1);
northp.add(cb2);
setLayout(new BorderLayout());
add("North",northp);
add("Center",scrol);
setVisible(true);
cb1.addActionListener(this);
cb2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
JCheckBox cb = (JCheckBox)e.getSource();//cb<-----cb1,cb2
if(cb.isSelected()){//체크박스가 선택되었을때
ta.append(cb.getText() + "가 선택\n");
}else{
ta.append(cb.getText() + "가 해제\n");
}
}
}
----------------------------------------------------------
- AppletTest.html
----------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>애플릿테스트</title>
</head>
<!-- 0523/AppletTest.html -->
<body>
<center>
<h3>애플릿테스트</h3>
<hr>
<applet code="j0523.AppletTest.class" width="300" height="300"></applet>
</center>
</body>
</html>
----------------------------------------------------------
'휴지통 > JSP' 카테고리의 다른 글
forward와 redirect의 차이점 (0) | 2013.05.24 |
---|---|
jsp:useBean (0) | 2013.05.23 |
jsp:forword (0) | 2013.05.23 |
<%@ include %>, 액션include 차이점 (0) | 2013.05.23 |
JSP 액션 (0) | 2013.05.23 |