myapplet.txt

来自「也是一个图片浏览器的源代码,希望可以帮到有需要的人」· 文本 代码 · 共 65 行

TXT
65
字号
import java.awt.*; 
import javax.swing.*; 
import java.awt.event.*; 
public class MyApple extends JApplet { 

	/** Creates a new instance of MyApplet */ 
	public  void MyApplet() { 
	} 

	public void init(){ 
	myFont = new Font("Dialog",Font.BOLD,16); 


	Bigger = new JButton("放大"); 
	Smaller = new JButton("缩小"); 
	jPanel1 = new JPanel(); 
	jPanel2 = new JPanel(); 
	jLabel1 = new JLabel("123"); 
	jLabel1.setFont(myFont); 

	jPanel1.setLayout(new FlowLayout()); 
	jPanel1.add(Bigger); 
	jPanel1.add(Smaller); 
	jPanel2.add(jLabel1); 

	Container cp= this.getContentPane(); 
	cp.setLayout(new BorderLayout()); 
	cp.add(jPanel1,BorderLayout.SOUTH); 
	cp.add(jPanel2,BorderLayout.CENTER); 

	Bigger.addActionListener(new ActionListener(){ 
	public void actionPerformed(ActionEvent evt) { 
	BiggerActionPerformed(evt); 
	} 
	}); 

	Smaller.addActionListener(new ActionListener(){ 
	public void actionPerformed(ActionEvent evt) { 
	SmallerActionPerformed(evt); 
	} 
	}); 

	this.setVisible(true); 
	} 


	private void BiggerActionPerformed(ActionEvent evt){ 
	int size = myFont.getSize()+2; 
	myFont = new Font("Dialog",Font.BOLD,size); 
	this.jLabel1.setFont(myFont); 
	} 

	private void SmallerActionPerformed(ActionEvent evt){ 
	int size = myFont.getSize()-2; 
	myFont = new Font("Dialog",Font.BOLD,size); 
	this.jLabel1.setFont(myFont); 
	} 

	private JButton Bigger,Smaller; 
	private JPanel jPanel1,jPanel2; 
	private JLabel jLabel1; 
	private Font myFont; 
	} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?