⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fontdialog.java

📁 用java编写的一个记事本程序,具有和windows Notepad相似的功能
💻 JAVA
字号:
 import java.awt.*;
import java.awt.event.*;
import javax.swing.JTextArea;
import java.awt.datatransfer.*;
import java.io.*;
import java.awt.datatransfer.*;
import javax.swing.*;
import javax.swing.border.*;
 class FontDialog extends Dialog implements ActionListener
 {	
 	static final int YES=1,NO=0;
 	int message=1;
 	Button yes,no;
 	Image im;
    FontPanel fontPanel;
    Panel panel;
    Button okButton;
    Button cancelButton;
    static int tempsize=20;
    JTextArea mytext;
 FontDialog(Frame f,JTextArea text)
 {
 	super(f);
 	mytext=text;
 	this.setTitle("字体对话框");
 	this.setModal(true);
 	this.setLayout(new FlowLayout());
 	this.setBounds(350,280,340,230);
 	okButton=new Button("确定");
 	cancelButton=new Button("取消");
 	okButton.addActionListener(this);
 	cancelButton.addActionListener(this);
 	panel=new Panel(new GridLayout(1,2));
 	panel.add(okButton);
 	panel.add(cancelButton);
 	
 	this.setLayout(new BorderLayout());
 	fontPanel=new FontPanel();
   
    add(panel,BorderLayout.SOUTH);
    add(fontPanel,BorderLayout.CENTER);

 //	im=Toolkit.getDefaultToolkit().createImage("d:\\help.jpg");
 	addWindowListener(new WindowAdapter()
 	{
 		public void windowClosing(WindowEvent e)
 		{
 			dispose();
 		}
 	});
 	

 }
 public void actionPerformed(ActionEvent e1)
 {
 	String name;
	int size=20;
 	if(e1.getSource()==okButton)
 	{
 		
       name=fontPanel.fontList.getSelectedItem();
		Font f=new Font(name,Font.PLAIN,fontPanel.tempsize);
        mytext.setFont(f);

		MyFrame.font=f;	
		this.setVisible(false);	
		
	  
 	}
 	if(e1.getSource()==cancelButton)
 	{

 		mytext.setFont(MyFrame.font);
 	    this.setVisible(false);
 	}
 }

 
 }
 	
 	

⌨️ 快捷键说明

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