我的第一个用VE做出来的applet小程序

呵呵,试验成功,只要在init中加载applet即可。

package test;

import javax.swing.JApplet;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.Rectangle;
import javax.swing.JTextArea;


public class FirstTest extends JApplet{

 /**
  *
  */
 private static final long serialVersionUID = 5936617821137135838L;
 private JButton bt1 = null;
 private JApplet jApplet = null;  //  @jve:decl-index=0:visual-constraint="8,8"
 private JPanel jContentPane = null;
 private JButton bt11 = null;
 private JButton bt2 = null;
 private JTextArea jTextArea = null;
 /**
  * This method initializes
  *
  */
 public FirstTest() {
  super();
  
 }

 /**
  * This method initializes this
  *
  */
 public void init() {
        this.setSize(new Dimension(253, 157));  
        getContentPane().add(getJApplet());
 }

 /**
  * This method initializes jApplet 
  *  
  * @return javax.swing.JApplet 
  */
 private JApplet getJApplet() {
  if (jApplet == null) {
   jApplet = new JApplet();
   jApplet.setSize(new Dimension(257, 159));
   jApplet.setContentPane(getJContentPane());
  }
  return jApplet;
 }

 /**
  * This method initializes jContentPane 
  *  
  * @return javax.swing.JPanel 
  */
 private JPanel getJContentPane() {
  if (jContentPane == null) {
   jContentPane = new JPanel();
   jContentPane.setLayout(null);
   jContentPane.add(getBt11(), null);
   jContentPane.add(getBt2(), null);
   jContentPane.add(getJTextArea(), null);
  }
  return jContentPane;
 }

 /**
  * This method initializes bt11 
  *  
  * @return javax.swing.JButton 
  */
 private JButton getBt11() {
  if (bt11 == null) {
   bt11 = new JButton();
   bt11.setBounds(new Rectangle(21, 18, 92, 26));
   bt11.setText("添加文字");
   bt11.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent e) {
     getJTextArea().setText("添加了一行文字!");
    }
   });
  }
  return bt11;
 }

 /**
  * This method initializes bt2 
  *  
  * @return javax.swing.JButton 
  */
 private JButton getBt2() {
  if (bt2 == null) {
   bt2 = new JButton();
   bt2.setBounds(new Rectangle(127, 21, 91, 26));
   bt2.setText("删除文字");
   bt2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent e) {
     getJTextArea().setText("这个按键用来删除这行文字!");
    }
   });
  }
  return bt2;
 }

 /**
  * This method initializes jTextArea 
  *  
  * @return javax.swing.JTextArea 
  */
 private JTextArea getJTextArea() {
  if (jTextArea == null) {
   jTextArea = new JTextArea();
   jTextArea.setBounds(new Rectangle(35, 65, 193, 77));
  }
  return jTextArea;
 }


 
}  //  @jve:decl-index=0:visual-constraint="10,10"
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值