package cn.ac.catarc.swing.demo;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.UIManager;
public class CmesApplet extends JApplet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Constructor of the applet.
*
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
*/
public CmesApplet() throws HeadlessException {
super();
}
/**
* Called by the browser or applet viewer to inform
* this applet that it is being reclaimed and that it should destroy
* any resources that it has allocated. The <code>stop</code> method
* will always be called before <code>destroy</code>. <p>
*
* A subclass of <code>Applet</code> should override this method if
* it has any operation that it wants to perform before it is
* destroyed. For example, an applet with threads would use the
* <code>init</code> method to create the threads and the
* <code>destroy</code> method to kill them. <p>
*/
public void destroy() {
// Put your code here
}
/**
* Returns information about this applet. An applet should override
* this method to return a <code>String</code> containing information
* about the author, version, and copyright of the applet. <p>
*
* @return a string containing information about the author, version, and
* copyright of the applet.
*/
public String getAppletInfo() {
return "This is my default applet created by Eclipse";
}
/**
* Called by the browser or applet viewer to inform
* this applet that it has been loaded into the system. It is always
* called before the first time that the <code>start</code> method is
* called. <p>
*
* A subclass of <code>Applet</code> should override this method if
* it has initialization to perform. For example, an applet with
* threads would use the <code>init</code> method to create the
* threads and the <code>destroy</code> method to kill them. <p>
*/
public void init() {
// Put your code here
super.init();
Container contentPane = this.getContentPane();
JLabel label1 = new JLabel("Label 1", JLabel.CENTER);
label1.setBackground(Color.green);
label1.setOpaque(true);// setOpaqueIture)方法的目的是让组件变成不透明,这样我们在JLabel上所设置的颜色
String[] s1={"公司文件","个人信件","私人文件"};
String[] s2={"本机磁盘(C:)","本机磁盘(D:)","本机磁盘(E:)"};
String[] s3={"奇摩站","职棒消息","网络书店"};
Hashtable hashtable1=new Hashtable();
Hashtable hashtable2=new Hashtable();
hashtable1.put("我的公文包",s1);
hashtable1.put("我的电脑",s2);
hashtable1.put("收藏夹",hashtable2);
hashtable2.put("网站列表",s3);
Font font = new Font("Dialog", Font.PLAIN, 12);
Enumeration keys = UIManager.getLookAndFeelDefaults().keys();
/**定义widnows界面**/
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (UIManager.get(key) instanceof Font) {
UIManager.put(key, font);
}
}
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}catch(Exception el){
System.exit(0);
}
JTree tree=new JTree(hashtable1);
JScrollPane scrollPane=new JScrollPane();
scrollPane.setViewportView(tree);
contentPane.add(scrollPane);
// 才能显示出来。
JLabel label2 = new JLabel("Label 2", JLabel.CENTER);
label2.setBackground(Color.pink);
label2.setOpaque(true);
JLabel label3 = new JLabel("Label 3", JLabel.CENTER);
label3.setBackground(Color.yellow);
label3.setOpaque(true);
/*
* 加入label1,label2到splitPane1中,并设置此splitPane1为水平分割且具有Continuous Layout的
* 功能。
*/
JSplitPane splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
false, tree, label2);
/*
* 设置splitPane1的分隔线位置,0.3是相对于splitPane1的大小而定,因此这个值的范围在0.0~1.0
* 中。若你使用整数值来设置splitPane的分隔线位置,如第34行所示,则所定义的值以pixel为计算单位
*/
splitPane1.setDividerLocation(100);
/*
* 设置JSplitPane是否可以展开或收起(如同文件总管一般),设为true表示打开此功能。
*/
splitPane1.setOneTouchExpandable(true);
splitPane1.setDividerSize(10);// 设置分隔线宽度的大小,以pixel为计算单位。
JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
false, splitPane1, label3);
splitPane2.setDividerLocation(700);
// 设置JSplitPane是否可以展开或收起(如同文件总管一般),设为true表示打开此功能.
splitPane2.setOneTouchExpandable(false);
splitPane2.setDividerSize(5);
contentPane.add(splitPane2);
this.setSize(1000, 800);
}
/**
* Called by the browser or applet viewer to inform
* this applet that it should start its execution. It is called after
* the <code>init</code> method and each time the applet is revisited
* in a Web page. <p>
*
* A subclass of <code>Applet</code> should override this method if
* it has any operation that it wants to perform each time the Web
* page containing it is visited. For example, an applet with
* animation might want to use the <code>start</code> method to
* resume animation, and the <code>stop</code> method to suspend the
* animation. <p>
*/
public void start() {
// Put your code here
}
/**
* Called by the browser or applet viewer to inform
* this applet that it should stop its execution. It is called when
* the Web page that contains this applet has been replaced by
* another page, and also just before the applet is to be destroyed. <p>
*
* A subclass of <code>Applet</code> should override this method if
* it has any operation that it wants to perform each time the Web
* page containing it is no longer visible. For example, an applet
* with animation might want to use the <code>start</code> method to
* resume animation, and the <code>stop</code> method to suspend the
* animation. <p>
*/
public void stop() {
// Put your code here
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Applet整合到web环境 (159个子文件)
java.policy.applet 141B
jre6u12.CAB 13.76MB
SelectionModelDemo.class 4KB
AddRemoveCells.class 4KB
CmesApplet.class 4KB
CmesApplet.class 4KB
JTabbedPane2.class 3KB
JScrollpane2.class 3KB
JList8.class 3KB
JScrollBar1.class 3KB
TreeDemo1.class 3KB
JPasswordField3.class 3KB
JLayeredPane1.class 3KB
JCheckBox2.class 3KB
JComboBox3.class 3KB
JScrollpane1.class 3KB
JList2.class 2KB
JInternalFrame1.class 2KB
TableModel2.class 2KB
TreeDemo2.class 2KB
ColumnModelTest.class 2KB
ColumnModelTest$MyTable.class 2KB
TableModel2$MyTable.class 2KB
JPanel1.class 2KB
EventDemo6.class 2KB
JComboBox1.class 2KB
JComboBox7.class 2KB
JSplitPane1.class 2KB
SimpleTable.class 2KB
JList5.class 2KB
JComboBox2.class 2KB
JList6.class 2KB
JList3.class 2KB
BorderDemo.class 2KB
InitalTree.class 2KB
JFrame1.class 1KB
TableModel1.class 1KB
JPasswordField3$JPasswordField3_OnlyNumberDocument.class 1KB
MyTable.class 1KB
CellRenderer.class 1KB
ToggleRovllover.class 1KB
SimpleBorder.class 1KB
ImageIconDemo.class 1KB
JComboBox2$UserDefineComboBoxModel.class 1KB
JList3$DataModel.class 1KB
DataModel.class 1KB
SelectionModelDemo$1.class 789B
ColumnModelTest$1.class 771B
JInternalFrame1$1.class 771B
AddRemoveCells$1.class 765B
JLayeredPane1$1.class 759B
JScrollpane1$1.class 753B
JScrollpane2$1.class 753B
JTabbedPane2$1.class 753B
SimpleTable$1.class 747B
JScrollBar1$1.class 747B
TableModel1$1.class 747B
TableModel2$1.class 747B
JSplitPane1$1.class 747B
InitalTree$1.class 741B
JComboBox7$1.class 741B
JComboBox3$1.class 741B
JComboBox2$1.class 741B
JCheckBox2$1.class 741B
TreeDemo1$1.class 735B
TreeDemo2$1.class 735B
JFrame1$1.class 723B
JPanel1$1.class 723B
JList5$1.class 717B
JList6$1.class 717B
JList3$1.class 717B
JList8$1.class 717B
JPasswordField3$1.class 685B
ToggleRovllover$1.class 685B
JList8$DataModel.class 678B
ImageIconDemo$1.class 677B
SimpleBorder$1.class 673B
JComboBox3$AModel.class 670B
BorderDemo$1.class 665B
JComboBox1$1.class 665B
JList2$1.class 649B
.classpath 2KB
org.eclipse.wst.jsdt.ui.superType.container 49B
jackson-mapper-asl-1.9.6.jar 761KB
spring-context-3.0.5.RELEASE.jar 653KB
commons-collections.jar 558KB
spring-beans-3.0.5.RELEASE.jar 542KB
spring-webmvc-3.0.5.RELEASE.jar 409KB
spring-web-3.0.5.RELEASE.jar 386KB
spring-core-3.0.5.RELEASE.jar 373KB
log4j-1.2.12.jar 350KB
spring-aop-3.0.5.RELEASE.jar 314KB
commons-lang-2.4.jar 256KB
jackson-core-asl-1.9.6.jar 223KB
commons-beanutils.jar 184KB
spring-expression-3.0.5.RELEASE.jar 166KB
spring-context-support-3.0.5.RELEASE.jar 99KB
servlet-api-2.3.jar 76KB
commons-logging-1.1.1.jar 59KB
spring-asm-3.0.5.RELEASE.jar 52KB
共 159 条
- 1
- 2
资源评论
山塘小鱼儿
- 粉丝: 289
- 资源: 82
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功